Entity Framework Code First IQueryable

后端 未结 2 1055
甜味超标
甜味超标 2021-01-12 05:23

I am using Entity Framework Code First and ran into a small road block. I have a class \"Person\" defined as such:

public class Person
{
    public Guid Id          


        
2条回答
  •  一整个雨季
    2021-01-12 06:06

    Because you are querying an IEnumerable (ie: LINQ to Objects) not IQueryable (ie: LINQ to Entities) given by EF.

    Instead you should use

    IEnumerable results = context.History.Where(h => h.Person.Id = "sfssd").OrderBy(h => h.OnDate).Take(50)
    

提交回复
热议问题