Sometimes we need to use a LINQ expression in xaf and also use the xaf criteriaoperator. In addition to system. LINQ, we also need to use the content in these four namespaces.
using DevExpress.Xpo;using DevExpress.Data.Filtering;using DevExpress.Data.Linq;using DevExpress.Data.Linq.Helpers;
The following is an example of using LINQ and criteriaoperator as additional filter conditions:
XPQuery<Customer> _customer = new XPQuery<Customer>(((XPObjectSpace)ObjectSpace).Session); var query = from c in _customer where c.Id > 10 select c; CriteriaToExpressionConverter converter = new CriteriaToExpressionConverter(); BinaryOperator bo = new BinaryOperator("Text", "s%",BinaryOperatorType.Like); IQueryable<Customer> filteredData = query.AppendWhere(converter, bo) as IQueryable<Customer>; foreach (var i in filteredData) Console.WriteLine(i.Id + " " + i.Text);