获取外键关系信息

时间:2013-09-25 21:01:42

标签: entity-framework

模型构建器允许您声明实体之间的关系,但我们需要一种在运行时获取所有关系信息的方法。我们需要生成JSON来表达我们的POCO关系。

relationships = {
            oneToOne: [{
                type: Person,
                hasKey: "id",
                hasOne: "ldapAccount",
                ofType: LdapAccount,
                withKey: "id",
                withForeignKey: "id",
                withOne: "person"
            }],
            oneToMany: [{
                type: Company,
                hasKey: "id",
                hasMany: "agencyRoles",
                ofType: AgencyRole,
                withKey: "id",
                withForeignKey: "companyId",
                withOne: "company"
            }],
            manyToMany: [{
                type: PermissionGroup,
                hasKey: "id",
                hasForeignKey: "permissionId",
                hasMany: "permissions",
                ofType: Permission,
                withKey: "id",
                withForeignKey: "permissionGroupId",
                withMany: "permissionGroups",
                usingMappingType: PermissionGroupToPermission
            }]
        };

有没有人知道如何在运行时从上下文中检索关系信息?

0 个答案:

没有答案