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 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…