You can use criteria models and manage your query.
In Trivial.Data
namespace of Trivial.dll
library.
The PropertyCriteria
class is a kind of criteria containing a single property.
The CollectionCriteria
class is a kind of criteria containing a group of property criteria and/or collection criteria with boolean operation.