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")

Comments

Popular posts from this blog

SharePoint 2013: Error updating managed account credentials

Error deploying Nintex workflow: An item with the same key has already been added