相关疑难解决方法(0)

获取给定EntityType的导航属性

我使用的是VS2010,EF4.0.需要如下功能.

private string[] GetNaviProps(Type entityType)//eg typeof(Employee)
{
    NorthwindEntities en = new NorthwindEntities();
    //here I return all Properties only for example
    return entityType.GetProperties().Select(p=>p.Name).ToArray();
    //should return Orders,Territories...
}
Run Code Online (Sandbox Code Playgroud)

我已经检查了这个,但IObjectContextAdapter在EF6.0和.net4.5中看起来很像.我试着像它一样替换它

var workspace = en.MetadataWorkspace;
Run Code Online (Sandbox Code Playgroud)

所以它可以编译,但是然后在第3行抛出异常.
有帮助吗?

c# linq ado.net entity-framework

9
推荐指数
2
解决办法
6773
查看次数

标签 统计

ado.net ×1

c# ×1

entity-framework ×1

linq ×1