using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Xpo;
using DevExpress.Xpo;
using System;
using System.Collections;
using System.Configuration;
using System.Windows.Forms;
using XSToolSet.Module.BusinessObjects;
namespace SuperNest_DB_Test
{
public partial class Form1 : Form
{
String XSXafDBString;
//数据库访问供应商提供者
XPObjectSpaceProvider osProvider;
//数据库的对象空间(每一个)
IObjectSpace objectSpace;//SYS_User
/// <summary>
///
/// </summary>
public Form1()
{
InitializeComponent();
//获取XPO信息源(必带)
XpoTypesInfoHelper.GetXpoTypeInfoSource();
//申明引用的数据对象
XafTypesInfo.Instance.RegisterEntity(typeof(SYS_User));
XafTypesInfo.Instance.RegisterEntity(typeof(SYS_UserRole));
XafTypesInfo.Instance.RegisterEntity(typeof(SYS_Role));
//给XPO的数据对象指定数据库链接字符串
XSXafDBString = ConfigurationManager.ConnectionStrings["XSToolSet"].ConnectionString;
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button2_Click(object sender, EventArgs e)
{
this.osProvider = new XPObjectSpaceProvider(@XSXafDBString, null);
//获取到数据对象
objectSpace = osProvider.CreateObjectSpace();
IList Users = objectSpace.GetObjects(typeof(SYS_User));
MessageBox.Show($"Users Count:{Users.Count}");
}
}
}
查找数据对象,可以使用FindObject,FindObjects,并使用filter,包括条件过滤,排序等操作。与XAF环境中一样对BO对象操作。

本文介绍了如何在ExpressApp中使用DevExpress的XPO库进行数据库连接,创建对象空间,并演示了如何通过`XSXafDBString`获取数据并进行用户列表查询。重点展示了对象空间操作和数据过滤的基本实践。
7万+

被折叠的 条评论
为什么被折叠?



