Cannot implicitly convert type 'System.Linq.IQueryable' to 'System.Data.Entity.DbSet'

前端 未结 4 1825
陌清茗
陌清茗 2020-12-03 09:58

I\'m new in Linq and so I have these situation below.

Now below error during compilation, says Cannot implicitly convert type \'System.Linq.IQuery

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-03 10:35

    var query = _db.Products.Where(x => true);
    if (bool) {
      query = query.Where(p => p.Id == id);
    }
    

提交回复
热议问题