문제

I have the following query

var query = (from b in db.StudentProgressPerDay
             where b.Student.Equals(InputStudent)
             orderby b.Date
             select b);

and the following command which is runs ok

var dates = query.Select(x => EntityFunctions.DiffDays(query.Min(y => y.Date), x.Date));

When I add a toList() command at the end, the aforementioned function does not work but instead it gives an exception

An exception of type 'System.NotSupportedException' occurred in System.Data.Entity.dll but was not handled in user code

도움이 되었습니까?

해결책

EntityFunctions is specific to Linq-to-Entities. ToList creates a regular List, so any queries on the list will be Linq-to-Objects from that point.

Try the following:

var query = (from b in db.StudentProgressPerDay
                         where b.Student.Equals(InputStudent)
                         orderby b.Date
                         select b).ToList();

var dates = list.Select(x => (x.Date - query.Min(y => y.Date)).Days);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top