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

前端 未结 4 1836
陌清茗
陌清茗 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:41

    It's because _db.Products isn't a query, it is a DbSet.

    The second block works because you are casting it to IQueryable, and the last one works because it is an actual query.

提交回复
热议问题