LINQ: How can I do a 'contains' on an integer field?
I was trying to write a LINQ query to mimic a string Contains value. The code seemed easier enough: use a lamba and use the same way you would in standard c# (x => x.Code.ToString().Contains("MySearchString").
No good. LINQ complained and I was stuck.
One workaround is to use SqlFunctions.StringConvert to convert the field.
So, my lamba became x=> SqlFunctions.StringConvert((double)e.Code).Contains("MySearchString")
No good. LINQ complained and I was stuck.
One workaround is to use SqlFunctions.StringConvert to convert the field.
So, my lamba became x=> SqlFunctions.StringConvert((double)e.Code).Contains("MySearchString")
Comments
Post a Comment