Ticket Q442492
Visible to All Users

DC - How to determine the real System.Type of the business entity generated by XAF based on a registered domain component

created 12 years ago

Hello!

I didn't noticed this before 12.1.8 came out, and decided to wrote a ticket.

In attached sample SiimpleAction is checking type of object and compares it to only existing DomainComponent's type, it should match but it does not. Is this a bug, or I'am miss something?
Thanks.

Comments (3)

    My bad, I figured it out. Problem is solved.

      Done! Anyway, thanks alot for your quick response!

      Dennis Garavsky (DevExpress) 12 years ago

        You are always welcome!

        Answers

        created 12 years ago (modified 12 years ago)

        Hello Andrey,
        It is not a bug, it is a designed feature;-)
        This is a modified version of your sample that shows three ways of doing your task correctly:

        C#
        using DevExpress.ExpressApp.DC; using DevExpress.ExpressApp.Xpo; ... //if (current.GetType() == typeof(DomainComponent1)) //Dennis: This is wrong, because real types are generated at runtime based on registered DCs. //if (typeof(DomainComponent1).IsAssignableFrom(current.GetType())) //Dennis: This is OK. //if (current.GetType() == ((IDCEntityStore)XafTypesInfo.PersistentEntityStore).GetGeneratedEntityType(typeof(DomainComponent1))) //Dennis: This is OK too. if (current.GetType() == XpoTypesInfoHelper.GetXpoTypeInfoSource().GetGeneratedEntityType(typeof(DomainComponent1))) DevExpress.XtraEditors.XtraMessageBox.Show(string.Format("typeof {0}",current.GetType())); ...

        I hope this helps.

          Comments (2)
          SZ SZ
          Sergey Zaitsev (Xafari Team) 12 years ago

            One more method
            if (XafTypesInfo.Instance.FindType(current.GetType()).Type == typeof(DomainComponent1))

            Dennis Garavsky (DevExpress) 12 years ago

              Thanks, Sergey!

              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.