Orchard.Roles UserId explanation

Topics: General, Writing modules
Aug 5, 2011 at 10:12 AM

i was trying to find out how the OrchardRoles in combination with OrchardUsers works but one think i dont fully understand is the following:

Why is the UserId column of part UserRolesPartRecord not an relation to User table like Role is a relation to RoleRecord but just a flat string and maintained manually?

Aug 5, 2011 at 7:24 PM

Well, it's not a string, it's an int. The reason why the record is not directly referring to a user record is probably that while the role record is defined in the same module as the user roles part record, the user record is in a different module (because we wanted to decouple roles from users as much as possible to allow for other, not necessarily role-based permission schemas to be possible). Records are not typically interface-based, so you'd have to use the concrete type here, which would make it impossible to swap out the implementation later without affecting that module as well. At least that's how I understand it by looking at the code (didn't write it).