0
我正在創建一個方法,它將循環實體對象上的屬性列表來檢查每個對象並在其中粘貼一些虛擬數據。這可能嗎?我嘗試低於但我卡住...(評論細節我不能工作,如何做)......如何獲得EntityObject類型的類型並將其與數據一起填充?
private static void SetAllNonNullableProperties(EntityObject airport, string uniqueMessage)
{
Type t = airport.GetType();
PropertyInfo[] props = t.GetProperties();
foreach (var prop in props)
{
//1) How do I see if this property is nullable?
//2) How do I tell the type so that I can stick a string/bool/datetime in it with dummy data?
}
}
只是好奇,你爲什麼不以實體的構造themsel定義默認值VES? – 2012-07-31 21:17:34