有什么不同 ?在获取数据并将它们存储在内存之前,是否都用于在sql端执行功能?
PS:
两者都用于linq.
我收到错误:
LINQ to Entities does not recognize the method 'Int32 LastIndexOf(System.String)'
method, and this method cannot be translated into a store expression.
Run Code Online (Sandbox Code Playgroud)
使用此代码判断某人的姓氏是否以某些字符开头时:
persons = persons.Where(c => c.FullName.IndexOf(" ") > 0 &&
c.FullName.Substring(c.FullName.LastIndexOf(" ")+1).StartsWith(lastNameSearch));
Run Code Online (Sandbox Code Playgroud)
任何线索如何在不使用LastIndexOf()的情况下实现这一目标?也许在使用ToList()从数据库中获取结果后,我必须检查这个?