Access domain object content at run time using field names

Thread is closed for posting
2 posts, 0 answers
  1. Dj Prpa
    Dj Prpa avatar
    20 posts
    Member since:
    Aug 2012

    Posted 26 Jan 2012 Link to this post

    In a database I have a table called "Organization" with a field called "OrganizationName". At run time I can access organization's name value by using domain object's property (something like: myOrganization.OrganizationName = "New Name").

    I would like to access domain object properties in the similar way one can access data reader object's properties (something like: myOrganization["OrganizationName"] = "New Name"). 

    Is there a way to get/set value from domain objects using field names?
     A C# code example would be very helpful.

  2. PetarP
    PetarP avatar
    754 posts

    Posted 31 Jan 2012 Link to this post

    Hello Zoran,

     This is not possible out of the box. It is possible to implement a generic way of accessing properties like this via reflection but that will be a huge performance penalty to your project  and is therefore not recommended. If you are still willing to use such an approach despite the performance penalties please do let me know and I will prepare a small sample for you on how this can be achieved.

    the Telerik team

    SP1 for Q3’11 of Telerik OpenAccess ORM is available for download

Back to Top