I use a loop to go through all the properties of the class to get the type of the property. I am using the following code:
public Dictionary<string, string> GetClassFields(TEntity obj) { Dictionary<string, string> dctClassFields = new Dictionary<string, string>(); foreach (PropertyInfo property in obj.GetType().GetProperties()) { if (property.PropertyType.IsGenericType && property.PropertyType.GetGenericTypeDefinition() == typeof(Nullable<>) && property.PropertyType.GetGenericArguments().Length > 0) dctClassFields.Add(property.Name, property.PropertyType.GetGenericArguments()[0].FullName); else dctClassFields.Add(property.Name, property.PropertyType.FullName); } return dctClassFields; }
mbadeveloper Aug 08 '17 at 8:48 on 2017-08-08 08:48
source share