• 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)的更多相关文章

  1. php内置的数据结构函数使用小事例

    1.栈数据结构 $stack = new splstack(); $stack->push("data1"); $stack->push("data2&quo ...

  2. 深入浅出CChart 每日一课——快乐高四第九课 于无声处,CChart内置功能介绍之数据存取篇

    笨笨长期以来一直使用Origin软件画图和处理数据,但Origin软件没有编程语言的接口.笨笨开发CChart的一个潜在的目标.是想实现Origin软件的功能.当然这是一个不可能达到的目标.Origi ...

  3. 莫烦scikit-learn学习自修第四天【内置训练数据集】

    1. 代码实战 #!/usr/bin/env python #!_*_ coding:UTF-8 _*_ from sklearn import datasets from sklearn.linea ...

  4. XAF应用开发教程-内置Attribute功能列表

    在 XAF 框架,一些用来生成一个业务应用程序的信息是在Attribute中指定.您可以将属性应用到业务类 (或它的成员) 指定验证规则,指定如何对数据进行显示. 设置关系类等.本主题提供了有关在何处 ...

  5. JSP第四篇【EL表达式介绍、获取各类数据、11个内置对象、执行运算、回显数据、自定义函数、fn方法库】

    什么是EL表达式? 表达式语言(Expression Language,EL),EL表达式是用"${}"括起来的脚本,用来更方便的读取对象! EL表达式主要用来读取数据,进行内容的 ...

  6. python面向对象的基础语法(dir内置函数、self参数、初始化方法、内置方法和属性)

    面相对象基础语法 目标 dir 内置函数 定义简单的类(只包含方法) 方法中的 self 参数 初始化方法 内置方法和属性 01. dir 内置函数(知道) 在 Python 中 对象几乎是无所不在的 ...

  7. echarts 柱状图 X(Y)轴数据过多时,滑动以及内置缩放的问题

    前言:在开发中碰到的情况(菜鸟出门).           在使用echarts 图表的时候发现要展示的数据过多,但是系统留的展示框太小,造成数据都挤压在一块(不好看而且新感觉很不专业).       ...

  8. Webform(五)——内置对象(Response、Request)和Repeater中的数据增删改

    一.内置对象 (一)Response对象 1.简介:response 对象在ASP中负责将信息传递给用户.Response对象用于动态响应客户端请求,并将动态生成的响应结果返回到客户端浏览器中,使用R ...

  9. 利用jQuery内置的data()方法存储数据

    jQuery提供了内置的data()方法,与DOM元素不同的是,它可以用来存储key/value类型的数据.数据的存储是很容易的: $('#myDiv').data('currentState', ' ...

随机推荐

  1. 利用百度文字识别API识别图像中的文字

      本文将会介绍如何使用百度AI开放平台中的文字识别服务来识别图片中的文字.百度AI开放平台的访问网址为:http://ai.baidu.com/ ,为了能够使用该平台提供的AI服务,你需要事先注册一 ...

  2. CPU异常分析(以trap00为例)

    Windows内核分析索引目录:https://www.cnblogs.com/onetrainee/p/11675224.html CPU异常的记录(trap00为例) 一.CPU检测到除零异常的执 ...

  3. C#斐波那契数列求法(比较阶乘和循环所用时间)

    using System; namespace ConsoleApp3 { class Program { static void Main(string[] args) { Console.Writ ...

  4. Exception,异常处理操作try{}catch(XXXException e){}finally{}

    package seday07.exception;/** * @author xingsir * try-catch 异常处理机制 * 语法: * try{ * 代码片段 * }catch(XXXE ...

  5. Python中为什么不能用可变对象作为默认参数的值

    def func(numbers = [], num=1): numbers.append(num) for number in numbers: print(number) func() >& ...

  6. 松软科技web课堂:SQLServer之SUM() 函数

    SUM() 函数 SUM 函数返回数值列的总数(总额). SQL SUM() 语法 SELECT SUM(column_name) FROM table_name SQL SUM() 实例 我们拥有下 ...

  7. 升鲜宝V2.0_杭州生鲜配送行业,再论B端生鲜配送企业管理软件的开发与实施的难点与行业痛点_15382353715_余东升

    升鲜宝V2.0_杭州生鲜配送行业,再论B端生鲜配送企业管理软件的开发与实施的难点与行业痛点_15382353715_余东升 笔者简介:升鲜宝供应链管理软件平台创始人,14年软件从业经历,10多年深究生 ...

  8. SQLi-LABS Page-1(Basic Challenges) Less5-Less10

    Less5 GET - Double Injection - Single Quotes http://10.10.202.112/sqli/Less-5?id=1 http://10.10.202. ...

  9. linux中OTG识别到一个U盘后产生一个sg节点的全过程

    注:本篇文章暂时不做流程图,如果有需求后续补做. 1. 需要准备的源码文件列表: base部分: kernel\base\core.c kernel\base\bus.c kernel\base\dd ...

  10. SQL 高效运行注意事项(三)

    合理配置tempdb 1.tempdb在SQL Server停掉,重启时会自动的drop,re-create. 根据model数据库会默认建立一个新的 2.tempdb对IO的要求比较高,最好分配到高 ...