Is it possible, using an example from Customize Business Object's Metadata to create:
- custom member-collection is DC1
- custom member-reference_to_DC1 in DC2
- association between them
Small example will be highly appreciated.
Is it possible, using an example from Customize Business Object's Metadata to create:
Small example will be highly appreciated.
Hello Stanislaw,
To define a non-associated reference property for a domain component at runtime, you can use the following code within the XafApplication.SettingUp event handler:
C#void application_SettingUp(object sender, SetupEventArgs e) {
TypesInfo typesInfo = (TypesInfo)((XafApplication)sender).TypesInfo;
Type parentInterfaceType = typeof(IParent);
Type childInterfaceType = typeof(IChild);
Type realParentType = ((IDCEntityStore)typesInfo.FindEntityStore(typeof(IDCEntityStore))).GetGeneratedEntityType(parentInterfaceType);
var parentMember = typesInfo.FindTypeInfo(childInterfaceType).CreateMember("Parent", realParentType);
I have found out that currently you canNOT define an associated IList<T> collection for a domain component, which is expected for DC associations to work. Our team will take this scenario into account, although I cannot promise any implementation time frame for this very rare scenario. I also want to emphasize that defining reference or collection properties whose type or element type is another domain component will work in simple cases only when no shared parts are involved due to the runtime DC entities generation specifics.
Thanks for for update, Stanislaw. As I wrote above, our team will take your request into account for the future.
Would you please also take a moment and describe a specific use-case scenario where you needed this functionality? With that, we'll be in a better position to prioritize your request and also probably describe alternative options.
We have an external metadata storage maintained via 3rd party independent application and contains domain component specifications. At the application start we need to apply this specifications run-time. The domain component specifications does not allow the shared parts at all, so we can safely create DCs and associations run-time.
Thanks for your clarification, Stanislaw. I guessed so, but just wanted to re-confirm your 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.
Hello Stanislaw,
As far as I understand, you need an example for a one-to-many association created at runtime, correct?
We currently have such an example for regular persistent classes (see E250) and have not researched this task for DC, except for simple scalar properties (see an example at S34769).
I need some additional time to research whether it is easily possible for DC. You can also try to use the aforementioned approach yourself and see if this works. What worries me a bit here is that internally, during DC entity generation, we use GetList<T> methods instead of GetCollection<T> for associations, and I am not sure if there are no specifics.
Hello, Dennis,
I use this sample code:
var parentMember = typeInfo.CreateMember(HierarchyLogic.PersistentParentName, parentType);
parentMember.AddAttribute(new AssociationAttribute("A"), parentType)
var childrenMember = typeInfo.CreateMember(HierarchyLogic.PersistentChildrenName, typeof(XPCollection<>).MakeGenericType(childrenType));
childrenMember.AddAttribute(new AssociationAttribute("A"), childrenType)
((XafMemberInfo)parentMember).Refresh();
((XafMemberInfo)childrenMember).Refresh();
It creates both members, but without association