模型构建器允许您声明实体之间的关系,但我们需要一种在运行时获取所有关系信息的方法。我们需要生成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
}]
};
有没有人知道如何在运行时从上下文中检索关系信息?