cancel
Showing results for 
Search instead for 
Did you mean: 

SQL Anywhere 17 and EF6 - linq .contains() showing SQL error

Former Member
2,285

hi. I believe I have found a bug in iAnywhere17.

I have some simple code

from a in db.ActiveLoginKeys   
where a.lok_key.Contains(key)
select a

This worked fine under iAnywhere12 and EF5 but now I've upgraded to 17 and ef6 I get this error whenever I do a .contains linq command

"internalexception": {
          "message": **"Cannot convert '%' to a numeric",**
          "type": "Sap.Data.SQLAnywhere.SAException",
          "stacktrace": "   at Sap.Data.SQLAnywhere.SACommand._ExecuteReader(CommandBehavior commandBehavior, Boolean isExecuteScalar, Boolean isBeginExecuteReader)\\r\\n   at Sap.Data.SQLAnywhere.SACommand.ExecuteDbDataReader(CommandBehavior behavior)\\r\\n   at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)\\r\\n   at System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.<reader>b__c(DbCommand t, DbCommandInterceptionContext`1 c)\\r\\n   at System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TTarget,TInterceptionContext,TResult](TTarget target, Func`3 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed)\\r\\n   at System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.Reader(DbCommand command, DbCommandInterceptionContext interceptionContext)\\r\\n   at System.Data.Entity.Internal.InterceptableDbCommand.ExecuteDbDataReader(CommandBehavior behavior)\\r\\n   at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)\\r\\n   at System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)"

if I replace my code with

from a in db.ActiveLoginKeys   
where a.lok_key == key
select a

this works fine

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member

The setup steps for EF6 suppport are a little different than before.

For one thing there is an extra /v EF6 required that wasn't before.

If that isn't the issue you might want to verify the SQL as it arrives at the server. Adding the -zr SQL+HOSTVARS switch to the server cmdline you should be able to determine what is causing the parser error. Please share what you find out.

Former Member
0 Kudos

Yeah without the EF6 switch I cannot run any queries against the DB. I set it up with the /v ef6 switch after days of searching.

This is an entirely different problem. Where using

a == "SomeValuw" in linq statements work fine but

.contains("somevalue") does not.

it's as if the SQL being generated is incorrect.

interestingly .contains("somevalue".ToString())

will work but that is not ideal and is not workable when using an OData Dataservice.

Former Member
0 Kudos

Anything helpful from your request logging ?

Former Member

Hmm. found my problem. I'm trying to use the new ef6 drivers (which are great by the way) with an older legacy versioned DB of sybase.

is there any way I can get the SQL to generate correctly for these older db's?