[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 375
  • Last Modified:

How do I access Castle Activerecord class property by index?

Given an activerecord class as follows:

[Serializable]
    [ActiveRecord(Table = "`MailMember`",Lazy=true)]
    public class MailMember : BaseObject<MailMember>
    {

        Campaigns campaign;
        [BelongsTo("CampaignID")]
        public virtual Campaigns Campaign
        {
            get { return campaign; }
            set { campaign = value; }
        }
        string firstName;
        [Property]
        public virtual string FirstName
        {
            get { return firstName; }
            set { firstName = value; }
        }
        string lastName;
        [Property]
        public virtual string LastName
        {
            get { return lastName; }
            set { lastName = value; }
        }

If I create an instance of MailMember:

Mailmember mm = new MailMember();

How can I acess the properties (column names) without knowing the names?

I can access the value by:
string membername = mm.FirstName;

but I want to iterate through all fields in MailMember and create a temporary table using the column names from the mm class, then add a few extra columns:
so I need to be able to get at the property names like mm[1].name (would be 'FirstName')

so I'm thinking something like

DataColumn dc = new DataColumn(mm[1].name.tostring());


or maybe there's another way of using the mailmember instance to create a new Datatable directly, and just add the extra columns to that?

cheers
0
mimpact
Asked:
mimpact
1 Solution
 
mimpactAuthor Commented:
I thought that might be the answer - thanks for the confirmation
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now