Current filter:
                                You should refresh the page.
                                Support Center
                                  • Hallo!

                                    I've read other posts about this theme but i didn't get the answer for Runtime Class creation.
                                    That's all clear with runtime members - using XPClassInfo.CreateMember.
                                    But how to create "runtime-class"?
                                    I have a model of document classification. There are lot's of documents and lot's of document classes, that can be created and modified by user in runtime. User can add properties to his user-classes in runtime. Then user associates his document with specified User-Class and able to modify document properties in scope of specified class.
                                    So the document property values of specified class must be stored in runtime-class table, that also can be modified or created in run-time.

                                    So can you give me a guide of using RunTime classes. Should I inherit XPClassInfo? Or XPDataObjectClassInfo? What's the optimal way to implement it?



                                Hello Philipp,

                                Thank you for the question. You can create a persistent class at runtime using the following code:

                                using DevExpress.Xpo; using DevExpress.Xpo.Metadata; .... ReflectionDictionary dict = new ReflectionDictionary(); XpoDefault.Dictionary = dict; XPClassInfo ci = new XPDataObjectClassInfo(dict, <ClassName>); ci.CreateMember(...); ... dict.AddClassInfo(ci);

                                However, I should say that this is not the best way to introduce the necessary functionality because you will be able to add a new members to your classes, but you will not be able to remove these members. Unfortunately, there is no correct way to implement this functionality at the database level. As a solution to your task, I suggest that you simply create one base class named "Document" which will have one-to-many relation to a collection of its properties. Thus you will introduce more flexible model, in which you will be able to perform any modifications.

                                Please feel free to contact us if you need any further assistance. We will be happy to help you.




                                It's practicaly impossible to implement your suggestion about one-to-many relation between Document and its property values.
                                The fact is that there are tens of thousands of documents and there are lots of classess and properties. Each document has it's own property-values set - and application must perform queries by property values.

                                I'm going to store the model of runtime user-classes in the same database as XPO-static classes like DocumentClassInfo and DocumentPropertyInfo.
                                Then runtime user-persistent classes will be initialized from this model. And if user will remove some property from DocumentClassInfo - it wouldn't be physically removed from runtime-class table immediately. Physicall removing of deleted properties will be performed in action "Compress database" without help of XPO.
                                So, do you see some troubles, i'll have in implementation of this concept?



                                Hello Philipp,

                                Thank you for the feedback. Yes, with the described approach, I think it is possible to introduce the necessary functionality. However, in this instance you will need to control the database consistency programmatically yourself. Note that the database structure and the business objects model should be always synchronized.


                                If you need additional product information, write to us at or call us at +1 (818) 844-3383

                                FOLLOW US

                                DevExpress engineers feature-complete Presentation Controls, IDE Productivity Tools, Business Application Frameworks, and Reporting Systems for Visual Studio, along with high-performance HTML JS Mobile Frameworks for developers targeting iOS, Android and Windows Phone. Whether using WPF, ASP.NET, WinForms, HTML5 or Windows 10, DevExpress tools help you build and deliver your best in the shortest time possible.

                                Copyright © 1998-2017 Developer Express Inc.
                                All trademarks or registered trademarks are property of their respective owners