This is a migrated thread and some comments may be shown as answers.

Access domain object content at run time using field names

1 Answer 31 Views
Development (API, general questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Dj Prpa
Top achievements
Rank 1
Dj Prpa asked on 26 Jan 2012, 05:47 PM
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.

Thanks,

1 Answer, 1 is accepted

Sort by
0
PetarP
Telerik team
answered on 31 Jan 2012, 05:41 PM
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.

Greetings,
Petar
the Telerik team

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

Tags
Development (API, general questions)
Asked by
Dj Prpa
Top achievements
Rank 1
Answers by
PetarP
Telerik team
Share this question
or