How do you add dynamic 'where' clauses to a linq query?

后端 未结 6 1069
伪装坚强ぢ
伪装坚强ぢ 2020-12-05 07:19

I\'ve got a User table with a bitmask that contains the user\'s roles. The linq query below returns all the users whose roles include 1, 4 or 16.

var users          


        
6条回答
  •  失恋的感觉
    2020-12-05 07:52

    You can use the PredicateBuilder class.

    PredicateBuilder has been released in the LINQKit NuGet package

    LINQKit is a free set of extensions for LINQ to SQL and Entity Framework power users.

提交回复
热议问题