How do I access Castle Activerecord class property by index?

Posted on 2011-04-27
Last Modified: 2012-05-11
Given an activerecord class as follows:

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

        Campaigns campaign;
        public virtual Campaigns Campaign
            get { return campaign; }
            set { campaign = value; }
        string firstName;
        public virtual string FirstName
            get { return firstName; }
            set { firstName = value; }
        string lastName;
        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?

Question by:mimpact
    LVL 11

    Accepted Solution


    Author Closing Comment

    I thought that might be the answer - thanks for the confirmation

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
    If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
    In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    758 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now