I think, I have a very big problem.
Or I must not use Foreign Keys.
I have a table User
I have a Table Roles
I have a table UserRoles (Every User can have some Roles / Every Role can used from some Users)
I have a table UserRoles (Every User can have some Roles / Every Role can used from some Users)
I have a table Permissions
I have a table RolePermissions (Every Role has some Permissions and vice versa)
another table RoleRole for use the roles in a tree-structure
Now, I want get a Userlist:
MyUserList := ObjectManager.Find<TUser>.Where(Linq['Name'] = StringVariable).List;
And I get an exception: EIdNotSetException
Tables:
User: 1 entry, id: TGUID ok (not 0000...)
MyUserList := ObjectManager.Find<TUser>.Where(Linq['Name'] = StringVariable).List;
And I get an exception: EIdNotSetException
Tables:
User: 1 entry, id: TGUID ok (not 0000...)
Roles: 3 Entrys; all ID's <> null
UserRoles: 2 entrys of the User has 2 Roles
Permissions: Many Entrys, all ID's <> null
RolePermissions: Many Entrys, all <> null for 2 of the Roles (1 Role never used)
RoleRole: table empty. No tree-structure
If I execute the Find-Command, I can see in the SQL-Server-Log that there where 4 queries.
select from User
select from User
select from UserRole left join User leftjoin Role
select from RolePermission left join Role leftjoin RolePermissions
select from RoleRole left join Role left join Role
First, ALL associations are lazy. I have a Many-Valued-Association between Role and RolePermissions, but not for the simple FieldVar.
Why Aurelius executing so many queries?
What happend, if I have many users with thousends of permission/roles?
What happend, if I have many users with thousends of permission/roles?
I want only list the Users.
The exception EIdNotSetException comes with TRolePermission. If I debug, I see that Aurelius read a RolePermisson (One Field is set) but in the debugger there are both Keys nil. And than I get the EIdNotSetException.
The data structure is fine. The data inside are fine too. I use this with SQL.
The data structure is fine. The data inside are fine too. I use this with SQL.
Do I have to delete all connections (Foreign-Keys) in the "Mapping"?