I made an extension method for EF objects:
public static IEnumerable<T> WildcardSearch<T>(this IEnumerable<T> entity, string param, Func<T, string> selector) { return entity.Where(l => SqlFunctions.PatIndex(param, selector(l)) > 0); }
I get the exception above if I try to use it.
However, if I run (as I assume) the same code directly in my collection, it works as intentional.
Why am I getting an exception, and is there a way to fix this?
Similar topics suggest changing the type to IQueryable , but it doesn't seem to help.
//this works result = context.FOO.Where(x => SqlFunctions.PatIndex(id, x.Id) > 0).ToList();
Johan source share