我一直在尝试使用 Linq 将表达式的动态列表传递给 MongoDB C# 驱动程序查询......例如,此方法适用于针对 ORM 的常规 Linq 查询,但在应用于 MongoDB 查询时会导致错误...(仅供参考:我也在使用 LinqKit 的 PredicateBuilder)
//
// I create a List of Expressions which I can then add individual predicates to on an
// "as-needed" basis.
var filters = new List<Expression<Func<Session, Boolean>>>();
//
// If the Region DropDownList returns a value then add an expression to match it.
// (the WebFormsService is a home built service for extracting data from the various
// WebForms Server Controls... in case you're wondering …Run Code Online (Sandbox Code Playgroud)