DevExpress XPO NonPersistentAttribute vs ObjectProperties

42 Views Asked by At

All properties of XPObject descendant class which are foreign keys pointing to another XPObject entities are easily available under ObjectProperties property. I have manually added a custom property to my class which type is a XPObject child and marked it as [NonPersistent].

Now I am writing some generic code and would like to iterate through all properties of type being a XPObject child - no matter if they are persistent or not. Is the Members property (property filtered) the only option?

I am not very happy with that approach, I expect much filtering and casting to get what I need.

1

There are 1 best solutions below

0
Kuba D On

I have implemented my requirement using Members property. The aim is to do some formatting actions for GridView columns if property type is a XPObject descendant implementing IMyInterface. The code looks as follows:

classInfo.Members
    .Where(m => m.IsPublic && m.ReferenceType != null && typeof(IMyDictionary).IsAssignableFrom(m.ReferenceType))
    .OfType<XPMemberInfo>()
    .ToList()
    .ForEach( prop =>
    {
        // doing what needs to be done
    };

It seems to work fine. Anyway I'd be really happy to see a more straightforward approach.