这是一段代码
public class Order
{
//Primary Key
public long OrderId { get; set; }
//Many to One Relationship
[ParentObject("PersonId")]
public Person Buyer { get; set; }
//One to Many Relationship
[ChildObject("OrderId")]
public List<OrderDetail> OrderDetails { get; set; }
public decimal TotalAmount
{
get
{
if (OrderDetails == null)
return 0;
return OrderDetails.Sum(o => o.LineItemCost);
}
}
public string Notes { get; set; }
}
我正在尝试检查 Order 对象。现在我想做的是:获取所有属性并尝试找出类类型,例如
public List<OrderDetail> OrderDetails { get; set; }
我想获得另一个类的“OrderDetail”类型。当我尝试使用 PropertyInfo.PropertyType 获取它时,我得到“List1”(通用类型),PropertyInfo.GetType() 给出了一些 System.Reflection.RuntimeType,PropertyInfo.DeclaringType 给出了“Order”(包含属性的类)。如果有人可以提出解决方案,我将不胜感激。提前致谢。