2
假設我有一堆通過LINQ獲得的屬性的IQueryable,我如何循環這些屬性?循環遍歷IQueryable的屬性
我曾嘗試:
foreach (PropertyInfo propertyInfo in rows.GetType().GetProperties())
{
var value = propertyInfo.GetValue(this, null);
var name = propertyInfo.Name;
}
這似乎並沒有工作,雖然,不返回任何。我需要一種方法來檢索IQueryable中所有屬性的值的名稱。
太棒了!非常感謝 – Dimo
如何獲取屬性的值? var value = propertyInfo.GetValue(this,null);似乎沒有工作.. – Dimo
@Dimo你必須開始枚舉IQueryable,並在每個實例中傳遞。 'foreach(var row in rows){var value = propertyInfo.GetValue(row,null); }' –