I am trying to migrate some of my 9.3 code to 10.1 and could ask a series of questions.
This one is about adding a dynamic member to an entity I added to generate.
I need to get an XPClassInfo from that entity and apply the same code as before from there.
Is it the right path to migration or is there a better way?
Thanks
Mohsen
We have closed this ticket because another page addresses its subject:
How to customize a domain component interface (DC) type information at runtime, e.g. define a custom member
Hi Mohsen,
I'm afraid your problem is not quite clear. Could you be more specific, and provide us with your current code for version 9.3?
Thanks,
Michael.
Here is a test application that shows in module.cs the problem I am talking about at line 35.
Actually, you can replace in AddDynamicField method with whatever code that you see could add a member at runtime to an XPO class.
It is just an example of how to do it and that worked great until 9.3.
Mohsen
Hi Mohsen,
Thank you for the project. Unfortunately, the approach you are using to add a dynamic field to a persistent class won't work with interfaces. Currently, you can create a descendant interface with an additional property, and register a type for it.
[DomainComponent, NavigationItem, ImageName("BO_Task")] public interface IMyProject : IProject { [NonPersistent] [Custom("Caption", "RollupAmount")] [ReadOnly(true)] decimal RollupAmount { get; set; } }
XafTypesInfo.Instance.AddEntityToGenerate("MyProject", typeof(IMyProject));
If this solution doesn't meet your requirements, please explain why you need a dynamic property.
Thanks,
Michael.
We need dynamic fields to customize the application business model to the needs of our customers and as you could guess almost every customer has different needs in this area. Nowadays, every software has to provide some kind of extension to its schema in order to fit exactly user's requirements.
To get back to the sample I provided, here is a modification I made to module.cs:
public override void CustomizeTypesInfo(ITypesInfo typesInfo)
{
base.CustomizeTypesInfo(typesInfo);
XPDictionary xpdict = XafTypesInfo.XpoTypeInfoSource.XPDictionary;
if(xpdict.GetClassInfo(typeof(IProject)).FindMember("RollupAmount") == null)
{
xpdict.GetClassInfo(typeof(IProject)).CreateMember("RollupAmount", typeof(decimal), true,false);
}
XafTypesInfo.Instance.RefreshInfo(typeof(IProject));
}
I can see that it is creating the new member but it is not showing in grid later.
I will try to find a solution anyway because it is such a fundamental functionality in our application that will prevent to upgrade tom 10.1 until it is solved.
Mohsen
Hi Mohsen,
Thank you for the clarification. I agree that this feature could be useful. I have registered a suggestion about it. Our developers will research this task, and possibly implement it in a future update. You can track its state via DC - Provide support for dynamic members in domain components.
Thanks,
Michael.
Thanks