LINQ where or filter c#

后端 未结 5 1342
故里飘歌
故里飘歌 2021-01-24 04:29

I have a collection being returned by a web service. A property of this collection is \"StatusCode\" which is a string value that can be anywhere from 0 to 5 (don\'t ask me why

5条回答
  •  春和景丽
    2021-01-24 04:38

    var wo = from w in workOrders 
             where new[]{"0", "1", "2"}.Contains(w.StatusCode)
             select w;
    

    BTW, if you were using an ORM, you could do it in LINQ (like the above) and only pull the 20% from the database ;)

提交回复
热议问题