通过 table 名称 entity framework 反射获取列
Get column by table name entity framework reflection
我需要从我只知道名称的 table 中获取列名称和值。
我尝试了很多东西但都没有成功。
我用这个来获取我的 table :
var table = oSession.ctx.GetType()
.GetProperty("country")
.GetValue(oSession.ctx, null);
我无法检索我的专栏信息..
也许我已经尝试过了:
List<string> columnsNames = table.GetType().GetFields().Select(field => field.Name).ToList();
谢谢你的帮助..
您或许可以尝试使用 GetProperties()
table.GetType().GetProperties().Where(p => !(p.GetMethod.IsVirtual || p.GetIndexParameters().Length > 0)).ToList()
使用 ((IQueryable)table).ElementType.GetProperties()
作为起点。您也可以从
中获得一些想法
我需要从我只知道名称的 table 中获取列名称和值。 我尝试了很多东西但都没有成功。
我用这个来获取我的 table :
var table = oSession.ctx.GetType()
.GetProperty("country")
.GetValue(oSession.ctx, null);
我无法检索我的专栏信息.. 也许我已经尝试过了:
List<string> columnsNames = table.GetType().GetFields().Select(field => field.Name).ToList();
谢谢你的帮助..
您或许可以尝试使用 GetProperties() table.GetType().GetProperties().Where(p => !(p.GetMethod.IsVirtual || p.GetIndexParameters().Length > 0)).ToList()
使用 ((IQueryable)table).ElementType.GetProperties()
作为起点。您也可以从