IsNull and nullable types in LINQ

前端 未结 2 510
遇见更好的自我
遇见更好的自我 2021-01-28 16:10

I am trying to convert the following line of SQL to LINQ code :

AND IsNull(Deleted,0) = 0

I have tried by doing this :

&&a         


        
相关标签:
2条回答
  • 2021-01-28 17:08

    You can use

    && Deleted.GetValueOrDefault(false) == false

    0 讨论(0)
  • 2021-01-28 17:12

    linq;

    where !(u.Deleted ?? false)

    sql output:

    WHERE (CASE WHEN ([Extent1].[Deleted] IS NULL) THEN cast(0 as bit) ELSE [Extent1].[Deleted] END) <> cast(1 as bit)

    0 讨论(0)
提交回复
热议问题