.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+
.NET 5.0+

XafApplication.LinkNewObjectToParentImmediately Property

Specifies whether or not a link between a master and child object is created immediately when the NewObjectViewController.NewObjectAction is executed in a nested List View with a non-aggregated collection.

Namespace: DevExpress.ExpressApp

Assembly: DevExpress.ExpressApp.v21.2.dll

Declaration

[Browsable(false)]
[DefaultValue(true)]
public bool LinkNewObjectToParentImmediately { get; set; }

Property Value

Type Default Description
Boolean

true

true, if the link between a master and child object is created when the child object is committed; false, if the link is created when the parent is committed.

Remarks

The table below details how the New Action behavior is changed in a nested List View with a non-aggregated collection depending on the LinkNewObjectToParentImmediately value.

Value Description
true The new object linked to the master object is created and the master object is committed when the New Action is executed. The reference to the master object is available in the new child object immediately after creation.
false The master object is not committed and the link is not created when the New Action is executed. The reference to the master object is not added to the new child object immediately. The link is created later, when the child object is committed. To persist the link, a user should also save the master object; otherwise, the unlinked child object will be saved.

To change the behavior for an entire application, set the LinkNewObjectToParentImmediately property in the InitializeDefaults method. You can find this method in your application project‘s XafApplication (WinApplication or WebApplication) descendent class.

namespace MySolution.Win {
    public partial class MySolutionWindowsFormsApplication : WinApplication {
        // ...
        private void InitializeDefaults() {  
            // ...
            LinkNewObjectToParentImmediately = true;
        }
        // ...
    }
}

To change the behavior for a specific View, set the NewObjectViewController.LinkNewObjectToParentImmediately property in a Controller that targets the required View. The behavior of aggregated collections is not changed.

By default, LinkNewObjectToParentImmediately is set to true in XafApplication code. However, the default value is overridden to false in code generated by the Solution Wizard. This is done to keep the behavior of applications created in earlier versions unchanged.

In many-to-many collections, the New Action is hidden when LinkNewObjectToParentImmediately is set to true.

Tip

This property is hidden in the Application Designer. You can use it only in code.

The following code snippets (auto-collected from DevExpress Examples) contain references to the LinkNewObjectToParentImmediately property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also