Good afternoon
I have the following database structure:
Tables:
-User
-Group
- Permission
And all relations N to N:
-
User Group
-
User Permission
-
PermissionGroup
I made a query to return the user, regardless of Groups and Permissions (LEFT JOIN) with Linq in C #.
Follows:
tbUsuario = (from _u in _authEntities.tb_usuario
join _gu in _authEntities.tb_grupo_usuario on _u.id_tb_usuario equals _gu.id_tb_usuario
into u
from usuario in u.DefaultIfEmpty()
join _pu in _authEntities.tb_permissao_usuario on _u.id_tb_usuario equals _pu.id_tb_usuario
into p
from permissao in p.DefaultIfEmpty()
where _u.login == login && _u.senha == senha
select _u).SingleOrDefault();
What I need to include in this query I already have, plus a LEFT JOIN, for the Group Permission table.
If it were by SQL query it would be simple, but with LINQ I still have not found the solution. I await.