I'm trying to build a search page using LINQ to Entities, but the following code is giving me a runtime error about l.t.e. not recognising 'Boolean StartsWith(). The code compiles just fine. How can I work around this better than shipping the StartsWith filtering out to a stored proc?
return from dp in dents.DirectoryPersonEntrySet
where
((dp.LastName.StartsWith(searchTerm, StringComparison.CurrentCultureIgnoreCase)) ||
(dp.Department.StartsWith(searchTerm, StringComparison.CurrentCultureIgnoreCase)) ||
dp.Extension.StartsWith(searchTerm, StringComparison.CurrentCultureIgnoreCase))
select dp;
See Question&Answers more detail:os