Ticket S37664
Visible to All Users

How do I change database mappings for domain components (DC) and their members?

created 14 years ago

Proposed Solution:
The PersistentDc should have a MapTo parameter that should be taken into account when generating persistent classes for domain components.
Or at least the XPO's PersistentAttribute should be taken into account.

Answers approved by DevExpress Support

created 11 years ago (modified 11 years ago)

We do not recommend using DC for legacy databases. Thus, we do not provide any means for generating domain components code and logics from existing databases and also have no immediate plans to support this scenario. Please try XPO or Entity Framework data models instead.
We will note this fact in the DC documentation.

    Comments (1)
    SM SM
    Santiago Moscoso 11 years ago

      Legacy databases is not the only reason you could need this, there could be a convention on how to name table columns that are different of the convetions used to name properties.

      created 12 years ago (modified 10 years ago)

      Currently, it is possible to solve this task using the DevExpress.Xpo.PersistentAttribute added at runtime. Here is some example code that needs to be added into your ModuleBase descendant (typically located in the Module.xx file):

      C#
      ... private const string GeneratedEntityName = "Test"; public override void Setup(XafApplication application) { base.Setup(application); application.TypesInfo.RegisterEntity(GeneratedEntityName, typeof(ITest)); application.TypesInfo.RegisterSharedPart(typeof(ITest)); application.SettingUp += application_SettingUp; } private void application_SettingUp(object sender, SetupEventArgs e) { XPDictionary xpDictionary = XpoTypesInfoHelper.GetXpoTypeInfoSource().XPDictionary; foreach(XPClassInfo classInfo in xpDictionary.Classes) { string entityFullName = string.Format("DevExpress.ExpressApp.DC.GeneratedClasses.{0}", GeneratedEntityName); if(classInfo.FullName == entityFullName) { classInfo.AddAttribute(new PersistentAttribute("CustomEntityTable")); } string sharedPartFullName = string.Format("DevExpress.ExpressApp.DC.GeneratedClasses.{0}_Data", typeof(ITest).Name); if(classInfo.FullName == sharedPartFullName) { classInfo.AddAttribute(new PersistentAttribute("CustomSharedPartTable")); } } ...
      C#

      I must note, however, that DC is not supposed to be used for legacy databases where these mappings are usually required. DC does not provide any means for generating domain component code and logic from existing databases either. If you require using DC with an existing database, consider using pure XPO or Entity Framework data models instead.
      If you have other use-case scenarios where changing the default database table and column mappings is required, please elaborate more on this in comments.

        Show previous comments (2)
        Dennis Garavsky (DevExpress) 12 years ago

          Thanks for the feedback, Christopher! This solution can certainly be improved, and we will consider this according to our customers' requests.

            is this still valid on version 14?

            Dennis Garavsky (DevExpress) 10 years ago

              @Abel: You can use a solution I described above. BTW, would you please elaborate a bit more on your use-case scenario?

              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.