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', ' ...
随机推荐
- Java 后台请求第三方系统接口详解
//调用第三方系统接口 PrintWriter out = null; BufferedReader in = null; JSONObject jsonObject = null; Closeabl ...
- 在python函数中默认参数的一些坑
一.默认参数 python为了简化函数的调用,提供了默认参数机制: 这样在调用pow函数时,就可以省略最后一个参数不写: 在定义有默认参数的函数时,需要注意以下: 必选参数必须在前面,默认参数在后: ...
- ES6 -箭头函数 ,对象的函数解构
ES6 -箭头函数: //es6 中的箭头函数和扩展 //es5的写法 // function add(a,b){ // return a + b; // } // add(1,2); //3 fun ...
- apk系统签名小技巧
前言 对于经常和android系统打交道的攻城狮来说,给app打系统签名一定是日常操作啦.由于最近使用的比较多,特此总结一下,减少复制粘贴的操作,通过命令行来搞定. 简化前的操作 1.Android ...
- Http相关小知识点笔记咯~
协议 先来说说什么是协议,协议其实指的是通信协议(Communications Protocol),也称传输协议.Wiki中的描述的是这样的,通信协议定义了通信中的语法学,语义学和同步规则以及可能存在 ...
- android binder 进程间通信机制5-Service注册和代理对象的获取
ServiceManager,其实也是一个Service,不过它的Server端实现并未使用Binder库的结构实现,而是直接打开binder/dev进行通信的,不具有普遍性. 下面以MediaSer ...
- android-ramdisk.img分析、recovery.img&boot.img执行过程【转】
一.ramdisk介绍 ramdisk通过直面意思就大概能理解意思,ram disk虚拟内存盘,将ram模拟成硬盘来使用的文件系统.对于传统的磁盘文件系统来说,这样做的好处是可以极大提高文件访问速度: ...
- Win10家庭版激活方法
由于电脑换过主板,系统过了段时间显示未激活的状态,当时没注意随着主板口袋里的密匙,当作垃圾一起扔了,在网上试了几种方式,以下这个方法让我成功激活了系统 对开始菜单点击右键,选择Windows Powe ...
- LeetCode 1248. 统计「优美子数组」
地址 https://www.acwing.com/solution/leetcode/content/5801/ 题目描述给你一个整数数组 nums 和一个整数 k. 如果某个子数组中恰好有 k 个 ...
- Vue 知识点个人总结
Vue 脚手架 脚手架 3 的版本 ---- webpack 4 cnpm install -g @vue/cli-----全局安装组件 vue create myapp-----命令行创建项目 或者 ...