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

前端 未结 5 1150
感动是毒
感动是毒 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:11

    In asp mvc Razor while i tried:

    @if (modelItem => item.Id == 1)
     {
    
    Approved 
    
     }
    

    Cannot convert lambda expression to type 'bool' because it is not a delegate type

    Solution:

    @if (Model.FirstOrDefault().Id == 1)
    {
    
    Approved
    
    }
    

    Hope helps someone.

提交回复
热议问题