Using “where”: Cannot convert lambda expression to type 'bool'

前端 未结 5 1183
感动是毒
感动是毒 2021-01-07 00:35

I have entity framework code as shown below.I am getting following error in where condition.

Cannot convert lambda expression to type \'bool\' because

5条回答
  •  爱一瞬间的悲伤
    2021-01-07 01:36

    Instead of where (p => p.ClubName == "club1") use:

    var query = from o in db.Clubs
                where  o.ClubName == "club1"
                select o;
    

    May be you are confused with method chaining where it would be:

    var query = db.Clubs.Where(p => p.ClubName == "club1");
    

提交回复
热议问题