我想为 Subsonic 3.0.0.3“构建”一个组合查询,最好的方法是什么?
我试过了;
Expression<Func<Person, bool>> exp = p => true;
Expression<Func<Person, bool>> fContinent = p => p.ContinentID == 1;
Expression<Func<Person, bool>> fType = p => p.TypeID == 1;
exp = Expression.Lambda<Func<Person, bool>>(Expression.AndAlso(exp, fContinent), exp.Parameters);
exp = Expression.Lambda<Func<Person, bool>>(Expression.AndAlso(exp, fType), exp.Parameters);
var personList = Person.Find(exp);
但这将给出异常“二元运算符 AndAlso 未定义......”
我也尝试使用谓词,但这也会引发异常(不支持Expression.Invoke)。
在亚音速 2 中,我会使用 SqlQuery 对象,但我想知道在版本 3 中使用 linq / 表达式的正确方法。