Ticket Q558045
Visible to All Users
Duplicate

How to use LongIDs (a la 13.1.5) in 13.2?

created 11 years ago

https://www.devexpress.com/Support/Center/Question/Details/S19870
So I am late to the party. I have been happily using longids with 13.1.4 with my own BaseObject identified along with the one from BaseImpl.
What do I do now?
What do you mean by static constructor of platform agnostic module?
If I were to cycle through all of my code and assign longids to each class equivalent to assembly fullname, would I get to the same place?
What do I do with my current set of models besides search and replace?

Comments (3)
Dennis Garavsky (DevExpress) 11 years ago

    Hello,
    Starting with version 13.1.6, use the SetPrefixId method as described in the Core - Introduce an ability to have two or more classes with one and the same name, but declared within different assemblies ticket. There I also gave a better example of using a static constructor (you may also want to refer to MSDN to learn more about static constructors and also check out the Application Solution Components help article to learn more about the XAF solution structure).
    If you already used long identifiers in your model customizations, then revert back to short identifiers using the Find and Replace dialog of Visual Studio. If there are collisions, use the prefixed name you passed to the SetPrefixId method. Let me know in case of any further questions.

      Dennis, Your description missed some key things which Steve had pointed out. I think you should write (or at least ghost write) one of your blogs about this topic. Would be very helpful.
      I honestly did not know about static constructor. Probably should have gotten a CS degree before starting a company.
      I really think DX did the right thing by switching to Long IDs. Sometimes we clients need saving from ourselves more than anyone else.

        I did end up using reflection to assign fullname prefix IDs to all xpo classes in my module which was three lines of code. And for the rest I will do search and replace on the model files.

        Answers

        created 11 years ago (modified 11 years ago)

        Take a look at http://www.devexpress.com/Support/Center/Question/Details/Q536483
        On that thread I just summarized what I learned in dealing with this same issue. To simplify out use of it here, I added the folllowing utility method to our code:

        C#
        /// <summary> /// ModelHelp contains methods to help you work with the XAF model. /// </summary> public class ModelHelper { /// <summary> /// Simplifies and standardizes the use of the DevExpress method SetIdPrefix. SetIdPrefix is needed when 2 classes have the same name /// and the XAF model builder tries to generate the same identifier for both. /// </summary> /// <remarks> /// We have standardaized on using the fully qualified name of the class as the prefix. The prefix passed to /// ModelNodesGeneratorSettings.SetIdPrefix is what will come before the _DetailView and _ListView strings in the identifier. /// </remarks> /// <typeparam name="T">One of the classes with a conflicting name.</typeparam> public static void ResolveModelIdConflict<T>() where T : class { ModelNodesGeneratorSettings.SetIdPrefix(typeof(T), typeof(T).FullName); } } }

        One of our calls looks like this:

        C#
        ModelHelper.ResolveModelIdConflict<Your.Class.Name.Here>();

        You could go a step further and use reflection to locate all your business objects and call this for each one.

          Comments (1)

            Thanks Steve, you are a life saver. The key was to declare the setidprefix in the offending assembly, and to declare it in the non static ctor before initialize component.

            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.