The entity cannot be constructed in a LINQ to Entities query

前端 未结 14 2081
失恋的感觉
失恋的感觉 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:41

    You can use this and it should be working --> You must use toList before making the new list using select:

    db.Products
        .where(x=>x.CategoryID == categoryID).ToList()
        .select(x=>new Product { Name = p.Name}).ToList(); 
    

提交回复
热议问题