标签:XPO XPView 笔记 XPCollection 客户端 new Name 排序 session1
XPO数据排序支持服务端排序和客户端排序,它们都依赖于以下数据集组件中的Sorting属性
- XPCollection服务端
- XPCollection客户端
- XPView服务端
- XPView客户端
- XPCursor
- XPDataView
它们不同区别和使用如下:
/// <summary>
/// XPCollection服务端
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnCollectionServer_Click(object sender, EventArgs e)
{
XPCollection xpc = new XPCollection(session1, typeof(Customer));
xpCustomer.Sorting.Add(new SortProperty("Name", DevExpress.Xpo.DB.SortingDirection.Ascending));
xpCustomer.TopReturnedObjects = 500;//XPCollection服务端设置,设置一次读取或写入的最大数据集数量
gridControl3.DataSource = xpc;
}
/// <summary>
/// XPCollection客户端
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnCollectionClient_Click(object sender, EventArgs e)
{
XPCollection xpc = new XPCollection(session1, typeof(Customer));
xpCustomer.Sorting.Add(new SortProperty("Name", DevExpress.Xpo.DB.SortingDirection.Descending));
xpCustomer.TopReturnedObjects = 0;//XPCollection客户端设置0或者不设。
gridControl3.DataSource = xpc;
}
/// <summary>
/// XPView服务端
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnXPViewServer_Click(object sender, EventArgs e)
{
XPView xpv = new XPView(session1, typeof(Customer));
xpv.Properties.AddRange(new ViewProperty[]
{
new ViewProperty("Oid", SortDirection.None, new OperandProperty("Oid"), false, true),
new ViewProperty("Name", SortDirection.Ascending, new OperandProperty("Name"), false, true),
new ViewProperty("Age", SortDirection.Descending, new OperandProperty("Age"), false, true)
});
gridControl3.DataSource = xpv;
}
/// <summary>
/// XPView客户端
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnXPViewClient_Click(object sender, EventArgs e)
{
XPView xpv = new XPView(session1, typeof(Customer));
SortingCollection sc1 = new SortingCollection();
sc1.Add(new SortProperty("Name", DevExpress.Xpo.DB.SortingDirection.Descending));
xpv.Sorting = sc1;
gridControl3.DataSource = xpv;
}
/// <summary>
/// XPCursor排序
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnXPCursor_Click(object sender, EventArgs e)
{
XPCursor xps = new XPCursor(session1, typeof(Customer));
xps.PageSize = 50;
xps.Sorting.Add(new SortProperty("Name", DevExpress.Xpo.DB.SortingDirection.Ascending));
gridControl3.DataSource = xps;
}
/// <summary>
/// XPDataView排序
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnXPDtataView_Click(object sender, EventArgs e)
{
//只支持客户端排序
XPDataView xpdv = new XPDataView(session1.Dictionary, session1.GetClassInfo<Customer>());
xpdv.LoadData(session1.ExecuteQuery("select * from Customer"));//如果需要在服务商排序,可以SQL语句里填写select * from Customerorder by Name asc
xpdv.Sorting.Add(new SortProperty("Name", DevExpress.Xpo.DB.SortingDirection.Descending));
gridControl3.DataSource = xpdv;
}
标签:XPO,XPView,笔记,XPCollection,客户端,new,Name,排序,session1 来源: https://www.cnblogs.com/east115/p/16683936.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。