Field mapped on related field

Posts   
 
    
tprohas
User
Posts: 257
Joined: 23-Mar-2004
# Posted on: 16-Feb-2006 01:20:47   

I'm in need of a way to loop through the fields of an object including the fields that are fields from a related entity. I also need this loop to include custom fields that I have created. Is this possible? The reason I'm doing this is to dynamically generate a spread sheet of data about an entity and need all the fields/properties.

What if my entity is a subtype of another entity? Would I then be able to loop through all the fields of the two entities?

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 16-Feb-2006 05:54:23   

I think you should use reflection. and use the Type.GetProperties Method

It should look like this:

Type MyType =Type.GetType("MyClass"); 
PropertyInfo[] propInfoArray = MyType.GetProperties();
tprohas
User
Posts: 257
Joined: 23-Mar-2004
# Posted on: 22-Feb-2006 01:54:31   

Thanks for the suggestion. I used this and it worked great.