This question already has an answer here:
i have this model :
public class model
{
public int Id { get; set; }
public string Name { get; set; }
public string Family { get; set; }
public int RoleId { get; set; }
public Role Role { get; set; }
}
public class Role
{
public int RoleId { get; set; }
public string RoleName { get; set; }
public string SEC { get; set; }
}
i need search in the model and find propertys of type is Class but it can not find them .
i try by this code :
PropertyInfo[] props = model.GetType().GetProperties();
foreach (var item in props)
{
if (item.PropertyType.IsClass)
{
PropertyInfo[] subClassProp = item.GetType().GetProperties();
foreach (var itemB in subClassProp)
{
selectList.Add(itemB.Name);
}
}
}
How Can i Solve This Problem ?
Aucun commentaire:
Enregistrer un commentaire