开发者论坛

 找回密码
 注册 (请使用非IE浏览器)
查看: 14461|回复: 2

xpo 条件查询

[复制链接]

0

精华

379

贡献

793

赞扬

帖子
367
软币
7240
在线时间
785 小时
注册时间
2013-6-8
发表于 2016-5-8 12:07:40 | 显示全部楼层 |阅读模式
一般条件: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));//设定排序规则

评分

参与人数 1赞扬 +1 收起 理由
三生 + 1 很给力

查看全部评分

回复

使用道具 举报

0

精华

518

贡献

356

赞扬

正版授权组

Rank: 14Rank: 14Rank: 14Rank: 14

帖子
213
软币
7131
在线时间
1173 小时
注册时间
2013-6-9
发表于 2017-4-7 10:26:20 | 显示全部楼层
不错 希望多一些这种资料
回复

使用道具 举报

Archiver|手机版|小黑屋|开发者网 ( 苏ICP备08004430号-2 )
版权所有:南京韵文教育信息咨询有限公司

GMT+8, 2024-4-26 13:51

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表