Kuba D
Kuba D

Reputation: 125

DevExpress XPO NonPersistentAttribute vs ObjectProperties

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.

Upvotes: 0

Views: 75

Answers (1)

Kuba D
Kuba D

Reputation: 125

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.

Upvotes: 0

Related Questions