XAF-内置初始化数据 (XPO)
Open the Updater.cs (Updater.vb) file, located in the MySolution.Module project's Database Update folder. Add the following code to the ModuleUpdater.UpdateDatabaseAfterUpdateSchema method.
打开位于 MySolution.模块项目的数据库更新文件夹中的Updater.cs(Updater.vb)文件。将以下代码添加到模块更新器.更新数据库后更新架构方法。
using MySolution.Module.BusinessObjects;
//... public class Updater : DevExpress.ExpressApp.Updating.ModuleUpdater {
//...
public override void UpdateDatabaseAfterUpdateSchema() {
base.UpdateDatabaseAfterUpdateSchema(); Contact contactMary = ObjectSpace.FindObject<Contact>(
CriteriaOperator.Parse("FirstName == 'Mary' && LastName == 'Tellitson'"));
if (contactMary == null) {
contactMary = ObjectSpace.CreateObject<Contact>();
contactMary.FirstName = "Mary";
contactMary.LastName = "Tellitson";
contactMary.Email = "tellitson@example.com";
contactMary.Birthday = new DateTime(, , );
}
//...
ObjectSpace.CommitChanges();
}
}
After adding the code above, the Contact object will be created in the application database, if it does not already exist.
添加上述代码后,如果联系人对象不存在,将在应用程序数据库中创建该对象。
Each time you run the application, it compares the application version with the database version and finds changes in the application or database. If the database version is lower than the application version, the application raises the XafApplication.DatabaseVersionMismatch event. This event is handled by the WinForms and ASP.NET applications in a solution template. When the application runs in debug mode, this event handler uses the built-in Database Updater to update the application's database. After the database schema is updated, the ModuleUpdater.UpdateDatabaseAfterUpdateSchema method is called. In this method, you can save the required business objects to the database.
每次运行应用程序时,它都会将应用程序版本与数据库版本进行比较,并在应用程序或数据库中查找更改。如果数据库版本低于应用程序版本,则应用程序将引发 XafApplication.DatabaseVersion 不匹配事件。
此事件由 WinForms 处理,并在解决方案模板中ASP.NET应用程序。
当应用程序在调试模式下运行时,此事件处理程序使用内置的数据库更新程序来更新应用程序的数据库。更新数据库架构后,将调用模块更新器.Updatedatabase 后更新架构方法。在此方法中,可以将所需的业务对象保存到数据库中。
As you can see in the code above, eXpressApp Framework (XAF) uses an Object Space object to manipulate persistent objects (see Create, Read, Update and Delete Data).
如上述代码所示,eXpressApp 框架 (XAF) 使用对象空间对象操作持久对象(请参阅创建、读取、更新和删除数据)
To specify the criteria passed as a parameter in the BaseObjectSpace.FindObject method call, the CriteriaOperator is used. Its CriteriaOperator.Parse method converts a string, specifying a criteria expression to its CriteriaOperator equivalent. To learn more on how to specify criteria, refer to the Ways to Build Criteria topic.
- 要指定在 BaseObjectSpace.FindObject 方法调用中作为参数传递的条件,将使用条件运算符。其 CriteriaOperator.Parse 方法转换字符串,将条件表达式指定为其条件运算符等效项。要了解有关如何指定条件的详细信息,请参阅生成条件的方法主题。
- Run the WinForms or ASP.NET application. Select the Contact item in the navigation control. Notice that the new contact, "Mary Tellitson", appears in the list to the right.
运行 WinForms 或ASP.NET应用程序。选择导航控件中的"联系人"项。请注意,新的联系人"玛丽·特利森"出现在右侧的列表中。

You can see the code for this tutorial in the MySolution.Module | Database Update | Updater.cs (Updater.vb) file of the Main Demo installed with XAF. The MainDemo application is installed in %PUBLIC%\Documents\DevExpress Demos 19.2\Components\eXpressApp Framework\MainDemo by default. The ASP.NET version is available online at http://demos.devexpress.com/XAF/MainDemo/
您可以在 MySolution.模块中查看本教程的代码。数据库更新 |Updater.cs (Updater.vb) 文件的主演示安装与 XAF.默认情况下,主演示应用程序安装在%PUBLIC%\Documents\DevExpress Demos 19.2\Components\eXpressApp Framework\MainDemo 中。ASP.NET版本可在 http://demos.devexpress.com/XAF/MainDemo/ 在线获取
.
XAF-内置初始化数据 (XPO)的更多相关文章
- php内置的数据结构函数使用小事例
1.栈数据结构 $stack = new splstack(); $stack->push("data1"); $stack->push("data2&quo ...
- 深入浅出CChart 每日一课——快乐高四第九课 于无声处,CChart内置功能介绍之数据存取篇
笨笨长期以来一直使用Origin软件画图和处理数据,但Origin软件没有编程语言的接口.笨笨开发CChart的一个潜在的目标.是想实现Origin软件的功能.当然这是一个不可能达到的目标.Origi ...
- 莫烦scikit-learn学习自修第四天【内置训练数据集】
1. 代码实战 #!/usr/bin/env python #!_*_ coding:UTF-8 _*_ from sklearn import datasets from sklearn.linea ...
- XAF应用开发教程-内置Attribute功能列表
在 XAF 框架,一些用来生成一个业务应用程序的信息是在Attribute中指定.您可以将属性应用到业务类 (或它的成员) 指定验证规则,指定如何对数据进行显示. 设置关系类等.本主题提供了有关在何处 ...
- JSP第四篇【EL表达式介绍、获取各类数据、11个内置对象、执行运算、回显数据、自定义函数、fn方法库】
什么是EL表达式? 表达式语言(Expression Language,EL),EL表达式是用"${}"括起来的脚本,用来更方便的读取对象! EL表达式主要用来读取数据,进行内容的 ...
- python面向对象的基础语法(dir内置函数、self参数、初始化方法、内置方法和属性)
面相对象基础语法 目标 dir 内置函数 定义简单的类(只包含方法) 方法中的 self 参数 初始化方法 内置方法和属性 01. dir 内置函数(知道) 在 Python 中 对象几乎是无所不在的 ...
- echarts 柱状图 X(Y)轴数据过多时,滑动以及内置缩放的问题
前言:在开发中碰到的情况(菜鸟出门). 在使用echarts 图表的时候发现要展示的数据过多,但是系统留的展示框太小,造成数据都挤压在一块(不好看而且新感觉很不专业). ...
- Webform(五)——内置对象(Response、Request)和Repeater中的数据增删改
一.内置对象 (一)Response对象 1.简介:response 对象在ASP中负责将信息传递给用户.Response对象用于动态响应客户端请求,并将动态生成的响应结果返回到客户端浏览器中,使用R ...
- 利用jQuery内置的data()方法存储数据
jQuery提供了内置的data()方法,与DOM元素不同的是,它可以用来存储key/value类型的数据.数据的存储是很容易的: $('#myDiv').data('currentState', ' ...
随机推荐
- 创建多进程之multiprocess包中的process模块
创建多进程之multiprocess包中的process模块 1.process模块是一个创建进程的模块 Process([group [, target [, name [, args [, kwa ...
- 【UWP】仅在TextBlock文本溢出时显示Tooltip
前言 这是我今天在回答SO问题时偶然遇到的,觉得可能还比较通用,就记录下来以供参考. 通常,我们使用ToolTip最简单的方式是这样: <TextBlock Text="Test&qu ...
- ASP.NET Core 2.2 WebApi 系列【九】使用SignalR
1.添加 SignalR 客户端库 右键点击项目->然后选择“添加” >“客户端库” 提供程序选择:unpkg ,库选择:@aspnet/signalr@1.1.4 选择“选择特定文件” ...
- C# 模拟Windows键盘事件
发送键盘消息 [DllImport("user32.dll", EntryPoint = "keybd_event", SetLastError = true) ...
- PlayJava Day021
容器: Collection接口:定义了存取一组对象的方法,其子接口Set和List分别定义了存储方式 List:存储数据有序且可重复 ----> ArrayList Set:存储数据无序且不可 ...
- console的各种输出格式
console.log('%c',CSS样式)输出css样式 console.log('%s',字符串) 字符串格式化 %d%i 整数格式化: console.log('%o',节点) 可扩展的dom ...
- docker 踩坑日记The last packet sent successfully to the server was 0 milliseconds ago.
The last packet sent successfully to the server was 0 milliseconds ago. 今日遇到了这个坑,看似平白无奇. 首先,我定位到是数据库 ...
- 动态构建Lambda表达式实现EF动态查询
在使用Entity Framework做数据查询的时候,查询条件往往不是固定的,需要动态查询.可以通过动态构建Lamda表达式来实现动态查询. Lamda表达式 使用Lamda表达式可以很方便的按条件 ...
- python简单处理excel方法
python自带xlrd和xlwt模块用来处理excel,但总觉得xlwt模块用着别扭,于是按自己的习惯重新封装了一个 # coding=utf- import xlrd # 读模块 import x ...
- export 与 export default区别
export 输出对应 import 语句需要使用大括号 { } export 命令后面是输出指定对外接口,实质是在接口名与模块内部变量之间建立一一对应的关系 export 命令可以出现在模块的任何位 ...