You are viewing help content for pre-release software. This document and the features it describes are subject to change. Switch to the current version.

Clone Object (Copy Data Records)

  • 3 minutes to read

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.

Clone Object Module Winforms Blazor

Important

Currently, we do not provide built-in support for Entity Framework (EF) in this module, because its implementation heavily depends on our XPO ORM, and we do not have a sufficient number of customer requests in this regard. If you use EF for data access in your XAF application and require a similar functionality for your project, feel free to contact us and describe your business requirements so we can provide you with alternative solutions. In general, you can integrate any custom or standard solution for Entity Framework, which you would implement to solve the same requirement in non-XAF applications. We will also continue monitoring user demand in this regard and it is possible that we will review our current decision in the future.

Add the Clone Object Module to an App

The Clone Object module consists of a single assembly: DevExpress.ExpressApp.CloneObject.Xpo.v21.2.dll (the DevExpress.ExpressApp.CloneObject.Xpo NuGet package).

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.

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

Tip

  • In .NET Framework projects, you can invoke the Module Designer and drag the CloneObject 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.
  • You can add modules to your application when you create a new XAF solution using the Solution Wizard. To do this, select modules in the Choose Extra Modules step.

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.

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.

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.

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.

Clone Object Module Customization

To implement custom behavior for the CloneObjectViewController or CloneObjectAction, 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.

Refer to the CloneObjectViewController.CloneObjectAction topic to see an example. You can handle events exposed by the CloneObjectViewController class.

See Also