1.语法
public object Evaluate(
Type objectType,
CriteriaOperator expression,
CriteriaOperator criteria
);
Type objectType,
CriteriaOperator expression,
CriteriaOperator criteria
);
Parameters
objectType
A System.Type object that identifies the type of objects against which the expression will be evaluated.
- expression
- A DevExpress.Data.Filtering.CriteriaOperator object that specifies the expression to evaluate.
- criteria
- A DevExpress.Data.Filtering.CriteriaOperator object that specifies the filter criteria. The objects that match this criteria will be used to evaluate the expression.
Return Value
The value evaluated.
2.用法
<1>
代码
using DevExpress.Xpo;
using DevExpress.Data.Filtering;
// A custom XPobject
class Person : XPObject {
//...
bool isMale;
public bool IsMale {
get { return isMale; }
set { isMale = value; }
}
}
// Calculate the number of objects.
object count = Session.DefaultSession.Evaluate(typeof(Person), CriteriaOperator.Parse("Count()"),
CriteriaOperator.Parse("IsMale = true"))
using DevExpress.Data.Filtering;
// A custom XPobject
class Person : XPObject {
//...
bool isMale;
public bool IsMale {
get { return isMale; }
set { isMale = value; }
}
}
// Calculate the number of objects.
object count = Session.DefaultSession.Evaluate(typeof(Person), CriteriaOperator.Parse("Count()"),
CriteriaOperator.Parse("IsMale = true"))
<2>
代码
using DevExpress.Data.Filtering;
//...
decimal sumPaid = (decimal)session.Evaluate<Order>(CriteriaOperator.Parse("Sum(OrderTotals)"),
new BinaryOperator("OrderDate", DateTime.Today.AddDays(-10), BinaryOperatorType.Greater));
//...
decimal sumPaid = (decimal)session.Evaluate<Order>(CriteriaOperator.Parse("Sum(OrderTotals)"),
new BinaryOperator("OrderDate", DateTime.Today.AddDays(-10), BinaryOperatorType.Greater));