Linq - check condition in where clause if field can be null

后端 未结 3 1319
攒了一身酷
攒了一身酷 2021-01-26 11:55

I have question - how to check condition in where clause even when item has no reference?

Most basic way - I am checking field from my Class, which can be null. When I j

3条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-26 12:24

     var soldOutProducts = from p in list 
                where p.destinataire != null && p.destinataire.StartsWith("D") 
                select p; 
    

提交回复
热议问题