The entity cannot be constructed in a LINQ to Entities query

前端 未结 14 2347
失恋的感觉
失恋的感觉 2020-11-21 06:04

There is an entity type called Product that is generated by entity framework. I have written this query

public IQueryable GetProdu         


        
14条回答
  •  遥遥无期
    2020-11-21 06:45

    only add AsEnumerable() :

    public IQueryable GetProducts(int categoryID)
    {
        return from p in db.Products.AsEnumerable()
               where p.CategoryID== categoryID
               select new Product { Name = p.Name};
    }
    

提交回复
热议问题