LINQ Where with AND OR condition

后端 未结 3 1324
轮回少年
轮回少年 2021-02-12 01:22

So I have managed to get this query working

List listStatus = new List() ; 
listStatus.add(\"Text1\");

List listMercha         


        
3条回答
  •  梦如初夏
    2021-02-12 02:14

    from item in db.vw_Dropship_OrderItems
        where (listStatus != null ? listStatus.Contains(item.StatusCode) : true) &&
        (listMerchants != null ? listMerchants.Contains(item.MerchantId) : true)
        select item;
    

    Might give strange behavior if both listMerchants and listStatus are both null.

提交回复
热议问题