ModelBuilder allows you declare relationships between entities, but we need a way to get all relationship information at runtime. We need to generate JSON to expression our POCO's relationships like so.
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
}]
};
Does anyone know how to retrieve relationship information from a context at runtime?