您的位置:首页 > 其它

The entity cannot be constructed in a LINQ to Entit

2017-12-28 11:18 316 查看
public IQueryable GetProducts(int categoryID)

{

    var productList = db.Products

        .Where(p => p.CategoryID == categoryID)

        .ToList()

        .Select(item => 

            new Product

            {

                Name = item.Name

            })

        .AsQueryable(); // actually it's not useful after "ToList()" :D

    return productList;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐