I have a library that is doing a bunch of reflection work relying on the PropertyInfo of the classes it receives (to get and set values).
Now I want to be able to work with dynamic objects, but I can't find how to get the PropertyInfo of a dynamic's properties. I've checked the alternatives, but for those I'd need to change everywhere I use PropertyInfo to get/set values.
public void Mapping(dynamic entity)
{
// - Always null
PropertyInfo p = entity.GetType().GetProperty("MyID");
// - Always null
PropertyInfo[] ps = entity.GetType().GetProperties();
}
Is it possible to get or create a PropertyInfo somehow just to be able to use it's GetValue()
and SetValue()
on a dynamic object?
Aucun commentaire:
Enregistrer un commentaire