一般条件:Name为A XPCollection xp = SpecialPlayNu.GetByCompany(DataBase.XpoSession,int.Parse(Session["CompanyId"].ToString()));
GroupOperator gxp = new GroupOperator();
gxp.Operands.Add(new BinaryOperator("Name", "A"));
xp.Filter = gxp;
或条件:Name为A或B XPCollection xpClasses2 = PlayeType.GetAll(DataBase.XpoSession);//得到记录集
xpClasses2.Sorting.Add(new SortProperty("Name", SortingDirection.Ascending));//设定排序规则
GroupOperator gxp = new GroupOperator();
gxp.Operands.Add(new GroupOperator(GroupOperatorType.Or, new BinaryOperator("Name", "A"), new BinaryOperator("Name", "B")));
xpClasses2.Filter = gxp;
大小条件:
GroupOperator gxp = new GroupOperator(); Money大于或等于1
gxp.Operands.Add(new BinaryOperator("Money", 1, BinaryOperatorType.GreaterOrEqual)); Money等于1
gxp.Operands.Add(new BinaryOperator("Money", 1, BinaryOperatorType.Equal)); Money大于1
gxp.Operands.Add(new BinaryOperator("Money", 1, BinaryOperatorType.Greater)); Money小于或等于1
gxp.Operands.Add(new BinaryOperator("Money", 1, BinaryOperatorType.LessOrEqual)); Money小于1
gxp.Operands.Add(new BinaryOperator("Money", 1, BinaryOperatorType.Less));
模湖条件:
Name值包含ABC的数据 gxp.Operands.Add(new BinaryOperator("Name","%ABC%",BinaryOperatorType.Like));
时间条件:
CreatTime时间在starttime到endtime
string format = "yyyy-MM-dd 0:0:0";
DateTime dt1 = DateTime.Now;
dt1 = dt1.AddDays(-1);
starttime = dt1.Date.ToString(format);
format = "yyyy-MM-dd 23:59:59";
dt1 = dt1.AddDays(+1);
endtime = dt1.Date.ToString(format); group.Operands.Add(new BinaryOperator("CreatTime", starttime, BinaryOperatorType.GreaterOrEqual));
group.Operands.Add(new BinaryOperator("CreatTime", endtime, BinaryOperatorType.LessOrEqual));
//设定排序条件
private void SetSorts(XPCollection aXp)
{
SortingCollection sorts = new SortingCollection();
sorts.Add(new SortProperty("Id", SortingDirection.Descending));
aXp.Sorting.Add(sorts);
}
aXp.Sorting.Add(new SortProperty("Name",SortingDirection.Ascending));//设定排序规则
|