jeudi 22 août 2019

How to get real list of object properties and its values

I have className in string variable and its Id:

string className = "Solution.TestClass"
long id = 1;

I'm using nHibernate to get entity from DB by its type and ID and its works but the returned object is has object type.

Type t = Type.GetType(className);
var result = context.Get(t, id);

Now I need to get values of properties from result object. Is there any way to do this by reflection? All I got is the class name and assembly. When I try to get property which belongs to class "TestClass" I get an error because it doesn't belong to "object" type.





Aucun commentaire:

Enregistrer un commentaire