Ticket T191131
Visible to All Users

DevExpress.Persistent.BaseImpl - Avoid problems caused by the fact that a new BaseObject record has an empty key value until it is saved

created 10 years ago (modified 10 years ago)

Problem: https://dxsearch.devexpress.com/default.aspx?d=15&p=T4%7cP2%7c54&q=OidInitializationMode&page=3 (currently there are about 40 requests on the subject)

All problems fall into the two main categories:
 - Inline editing on the Web in the grid, tree list and scheduler (example: B197990). Certain scheduler scenarios are not supported for the OidInitializationMode = OnSaving at all (Q513729);
 - Manipulations with aggregated collections depending on new master object or any custom logic on the Oid property  (example: Q325791, T191111);

They occur mostly in ASP.NET because data bound control records are identified by their identifiers. Since all your objects have the same Guid.Empty value until they are saved, it is impossible to correctly perform certain operations (e.g., selection, editing, deletion) within the control.
See the linked duplicates for more details.

Proposed/Current solution:
Set BaseObject.OidInitializationMode = OidInitializationMode.AfterConstruction in Project Templates for new XPO solutions to avoid breaking changes for existing users like in New Objects have an Oid.
This should fix all the problems listed in duplicates for NEW users and will NOT affect existing customers.

Comments (2)
Anatol (DevExpress) 10 years ago

      For what its worth, you reference ticket B198984, which was mine. However, I no longer use that approach now that I can use IsNewObject(@This) in my criteria. So I actually set OidInitializtionMode to AfterConstruction these days.

      Answers approved by DevExpress Support

      created 10 years ago (modified 7 years ago)

      We have implemented the functionality described in this ticket. It will be included in our next update(s).

      Please check back and leave a comment to this response to let us know whether or not this solution addresses your concerns.

      Additional information:

      In XAF Solutions created via the Solution Wizard, the BaseObject.OidInitializationMode static property is now set to AfterConstruction using the following code line added to the Module.cs file:

      C#
      BaseObject.OidInitializationMode = OidInitializationMode.AfterConstruction;

      We do not modify the default value in the BaseObject class implementation to avoid the behavior change in existing applications.

        Comments (1)
        DevExpress Support Team 10 years ago

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.