学习020-03 Clone Object (Copy Data Records)(克隆对象(复制数据记录))

Clone Object (Copy Data Records)(克隆对象(复制数据记录))

The Clone Object module allows users to clone existing objects in a single click. This functionality can be useful when a user wants to create similar data items without the need to fill all the new data item’s fields.
克隆对象模块允许用户一键克隆现有对象。当用户想要创建类似的数据项,而无需填写新数据项的所有字段时,此功能会很有用。

在这里插入图片描述

Important
XAF does not currently include built-in support for Entity Framework (EF) in this module as its implementation relies on the XPO ORM. Until the Clone Object Module supports EF Core, it is possible to manually integrate any custom or standard Entity Framework solution into your XAF application. For more information on how to do this, refer to the following topic: XAF - Entity Framework Core (EF Core) version of the Clone Object Module.

目前,XAF在此模块中并未内置对实体框架(EF)的支持,因为其实现依赖于XPO对象关系映射(ORM)。在克隆对象模块支持EF Core之前,可以手动将任何自定义或标准的实体框架解决方案集成到您的XAF应用程序中。有关如何执行此操作的更多信息,请参阅以下主题:XAF - 克隆对象模块的实体框架核心(EF Core)版本。

Add the Clone Object Module to an App(将克隆对象模块添加到应用程序)

The Clone Object module consists of a single assembly: DevExpress.ExpressApp.CloneObject.Xpo.v24.1.dll (the DevExpress.ExpressApp.CloneObject.Xpo NuGet package).
克隆对象模块由单个程序集组成:DevExpress.ExpressApp.CloneObject.Xpo.v24.1.dll(DevExpress.ExpressApp.CloneObject.Xpo NuGet 包)。

You can add CloneObjectModule to the common application module to use its CloneObject Action in WinForms, ASP.NET Web Forms, and ASP.NET Core Blazor applications. To do this, add it to the XafApplication.Modules or ModuleBase.RequiredModuleTypes list because a reference to the module assembly is insufficient.
你可以将CloneObjectModule添加到通用应用程序模块中,以便在WinForms、ASP.NET Web Forms和ASP.NET Core Blazor应用程序中使用其CloneObject操作。为此,将其添加到XafApplication.Modules或ModuleBase.RequiredModuleTypes列表中,因为仅引用模块程序集是不够的。

C#
using DevExpress.ExpressApp.CloneObject;
// ...
namespace MySolution.Module {
    public sealed partial class MySolutionModule : ModuleBase {
        public MySolutionModule() {
            // ...
            RequiredModuleTypes.Add(typeof(CloneObjectModule));
        }
    }
}

Tip

  • In .NET applications, you can call the AddCloningXpo<TBuilder>(IModuleBuilder<TBuilder>, Action<ObjectCloningOptions>) method in your ASP.NET Core Blazor/WinForms application builder.
    在 .NET 应用程序中,你可以在 ASP.NET Core Blazor/WinForms 应用程序生成器中调用 AddCloningXpo<TBuilder>(IModuleBuilder<TBuilder>, Action<ObjectCloningOptions>) 方法。
  • In .NET Framework projects, you can invoke the Module Designer and drag the Clone Object module from the Toolbox to the RequiredModules panel. To add this module to an application project, invoke the Application Designer, drag the CloneObject module from the Toolbox’s XAF Modules page to the Modules panel on the Designer, and rebuild your solution.
    在 .NET Framework 项目中,你可以调用模块设计器,并将“克隆对象”模块从“工具箱”拖到“所需模块”面板。若要将此模块添加到应用程序项目,请调用应用程序设计器,将“克隆对象”模块从“工具箱”的“XAF 模块”页面拖到设计器上的“模块”面板,然后重新生成解决方案。
  • You can add modules to your application when you use the Solution Wizard to create a new XAF solution. Select modules in the Choose Additional Modules step.
    当你使用解决方案向导创建新的XAF解决方案时,可以向应用程序添加模块。在“选择其他模块”步骤中选择模块。

Activate the Clone Object Module(激活克隆对象模块)

To activate the CloneObject Action (the Clone… button) for a business object type, set its BOModel | <Class> node’s IsCloneable property to true.
要为业务对象类型激活“克隆对象”操作(“克隆…”按钮),请将其 BOModel | <类> 节点的 IsCloneable 属性设置为 true。

The CloneObject Action is disabled if the current object has unsaved changes because the clone process works in a separate Object Space.
如果当前对象有未保存的更改,则“克隆对象”操作将被禁用,因为克隆过程在单独的对象空间中进行。

To prevent an individual field or property from being cloned, decorate it with NonCloneableAttribute.
若要防止单个字段或属性被克隆,请使用NonCloneableAttribute对其进行修饰。

How It Works(它是如何工作的)

The Clone Object module supplies the CloneObjectViewController View Controller. This Controller contains the CloneObject Single Choice Action that targets the selected object for cloning.
克隆对象模块提供了克隆对象视图控制器(CloneObjectViewController)。该控制器包含“克隆对象单项选择操作”,其目标是对选定对象进行克隆。

The Clone Object module extends the Application Model’s BOModel | <Class> nodes with the IModelClassCloneable.IsCloneable property. Set it to true to enable the action for objects of the selected type.
克隆对象模块使用IModelClassCloneable.IsCloneable属性扩展应用程序模型的BOModel | <类>节点。将其设置为true可对所选类型的对象启用该操作。

Clone Object Module Customization(克隆对象模块定制)

To implement custom behavior for the CloneObjectViewController or CloneObject Action, create a custom View Controller and access the Controller and its Action in the Controller.Activated event handler.
要为“克隆对象视图控制器”或“克隆对象操作”实现自定义行为,请创建一个自定义视图控制器,并在控制器的“激活”事件处理程序中访问该控制器及其操作。

Handle the CloneObjectViewController.CustomCloneObject event to clone objects with custom logic.
处理CloneObjectViewController.CustomCloneObject事件,以自定义逻辑克隆对象。

Refer to the CloneObjectViewController.CloneObjectAction topic to see an example. You can handle events exposed by the CloneObjectViewController class.
请参考“克隆对象视图控制器.克隆对象操作”主题以查看示例。你可以处理由克隆对象视图控制器类公开的事件。

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

汤姆•猫

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值