0
我想獲取實體框架中的表數據模型的屬性名稱。 我有這樣的代碼獲取使用字符串的表的屬性名稱
var properties = context.GetType().GetProperties(BindingFlags.DeclaredOnly |
BindingFlags.Public |
BindingFlags.Instance);
所有我想要的是有一個像以具有定義表模型一個字符串變量下面的方法驗證碼:
MyMethod (string category)
{
var properties = "category".GetType().GetProperties(BindingFlags.DeclaredOnly |
BindingFlags.Public |
BindingFlags.Instance);
......
......
}
是它可能?提前Thanx
謝謝你的回答,但是我使用上面的代碼時出現此錯誤GetType'在靜態上下文 –
我已經更新了我的答案,並提供了一個解決方法,另一種方法(Type.GetType方法可能更簡單一些) –
太好了!非常感謝。 –