LINQ to Entities does not recognize the method

让人想犯罪 __ 提交于 2019-11-29 04:33:50
Steven K.

Your select statement cannot be translated due to the nature of how IQueryable<T> and the query providers work: see this thread for more info What is the difference between IQueryable<T> and IEnumerable<T>?

You can 'help' the linq provider by dividing your expression into separate statements like this:

var ems = unitOfWork.Employees.FindAll();
var tcs = unitOfWork.TimeCards.FindAll();

var query = from e in ems
            from tc in tcs
            where tc.Employee.Id == e.Id && e.Name.StartsWith("C")
            select tc;

Or you can let FindAll() return IEnumerable<T> instead of IQueryable<T> and then your original expression should work.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!