DA LINQ error with Contains()

I have a DA service up and running and have developed several apps in Oxygene that run against it and its performing spectacularly. Today I started work on another app and had to build a simple database lookup window for the app, and for that I wanted to use DA LINQ to do the equivalent of an SQL LIKE command. Here is a code snippet I wrote in a test console app:

class method Program.Main(args: array of String): Int32;
begin
  var UserClientText := 'NEW YORK';

  var fDataModule := new lpv8oelib.DataModule;

  var cq := from crec in fDataModule.DataAdapter.GetTable<lpv8oelib.Data.client>
          where crec.ClientName.Contains(UserClientText)
          select new class(crec.ClientNumber,crec.ClientName);

  var cList := cq.ToList;
  for each rec in cList do
    Console.WriteLine(rec.ClientNumber+' - '+rec.ClientName.Trim);
end;

When I run this against my service, I got an error quite unexpectedly:

Unhandled Exception: RemObjects.SDK.Types.ServerException: An exception occurred
 on the server: ERROR [42000] [Pervasive][ODBC Client Interface][LNA][Pervasive]
[ODBC Engine Interface]Syntax Error: SELECT "t0"."ClientName", "t0"."ClientNumbe
r" FROM "client" "t0" WHERE ("t0"."ClientName" LIKE << ??? >>(('%' + ?) + '%'))
   at RemObjects.SDK.Message.ProcessException()
   at RemObjects.SDK.BinMessage.InternalReadFromStream(Stream stream)
   at RemObjects.SDK.IpHttpClientChannel.IntDispatch(Stream request, IMessage re
sponse)
   at RemObjects.SDK.ClientChannel.Dispatch(IMessage message)
   at RemObjects.SDK.DynamicRequest.InternalMakeRequest()
   at RemObjects.DataAbstract.Linq.LinqRemoteDataAdapter.FetchData(TableRequestI
nfo[] Request, String[] Name, Action`3 aFillMethod)
   at RemObjects.DataAbstract.Linq.RemoteTable`1.Execute(Expression expression,
DataParameter[] parameters)
   at RemObjects.DataAbstract.Linq.RemoteTable`1.Execute(Expression expression)
   at RemObjects.DataAbstract.Linq.RemoteTableQuery`1.GetEnumerator()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at LikeTest.Program.Main(String[] args) in D:\dev\miller\curry\LikeTest\Progr
am.pas:line 26

The SQL shown in that exception doesn’t make much sense to me. It appears if the LIKE command wasn’t properly translated from DALINQ?

Here are my particulars:

Elements version 8.1.83.1751
DA/ROSDK 8.1.85.1143
Visual Studio 2013
Windows 7

Hello

That’s not exactly a bug - generated SQL is considered valid by all other DBMS. However, given the generated SQL could be optimized to provide better compatibility with Pervasive I’ve logged the issue ‘72008: DA LINQ produces non-optimal SQL for .Contains string operations’

Please send a mail to support@ with your account name so we’ll be able to provide you the updated build once the issue is fixed (this requires some changes in the DA LINQ engine).

Regards