Couldn´t make it work. Would you mind indicating me how to use with real life data like Northwind, Products, etc. I don´t know what to write in every step of the way. I have tried different combinations but still no luck
It seems that it requires something else that you already have taht I don´t as to work fine
I just copied and pasted the code in my OnInserting FormView event but it gives a lot of error messages
Please
----------------------
Decker Dong - MSFT
Hello topolov,
I guess that you want to return a collection of a specific kind of Entity. So you can first define a function with two parameters:
1) T entity——entity model class.
2) object collection——for containing vlaues.
public void AutoGetValues<T>(T entity,object[]values) where T:TEntity { var results = entity.GetProperties(); values = new object[results.Length]; int i=0; foreach (PropertyInfo p in results) { values[i++] = p.GetValue(entity,null); } }
3) And then call this method as: object[] values = null; AutoGetValues<ModelClass>(ModelClassInstance, values);
Topolov
Member
680 Points
411 Posts
Re: Reflection (About)
Oct 04, 2011 04:10 PM|LINK
Couldn´t make it work. Would you mind indicating me how to use with real life data like Northwind, Products, etc. I don´t know what to write in every step of the way. I have tried different combinations but still no luck
It seems that it requires something else that you already have taht I don´t as to work fine
I just copied and pasted the code in my OnInserting FormView event but it gives a lot of error messages
Please
----------------------