1

When I try to execute this ESQL (Cast int to string) with dynamic linq (from this link)

queryable.Where("CAST(PositionID AS Edm.String).Contains(@0)", paramsObj); //PositionID is Int32

it throw exception

')' or ',' expected

My Entity Framework version is 4.0. Any idea how to resolve this problem ?

Thanks in advance,

Brian

Hensembryan
  • 1,067
  • 3
  • 14
  • 31

1 Answers1

0

you cann't use as inside function call, try change your code like this

queryable.Where("(PositionID.ToString().Contains(@0))", paramsObj); //PositionID is Int32

UPDATE:

most likely in your case may have to use custom function from db

UPDATE 2:
i think you cann't use esql with Dynamic LINQ, because it parse string conditions by self rules, so syntax edsl may be wrong for Dynamic LINQ, also not all SQL constructions implement in LINQ to Entities, so if you want use like operator you must use Contains, StartsWith, EndsWith functions that work only with string
So for solve this you can use storage procedures and functions, or eSQL command, or raw sql

Grundy
  • 13,356
  • 3
  • 35
  • 55