1
Good afternoon
I have the following database structure:
Tables:
-User
-Group
-Permission
And all relations N to N:
Grupousuario
Permissaousuario
Permissaogrupo
I set up a query to return the user, independent 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 is to include in this query that I already have, another LEFT JOIN, for the table of Permissaogrupo.
If it were by query SQL would be simple, but with LINQ I still can’t find the solution. I am waiting.
Make the LEFT JOIN for the tables tb_Grupo and tb_Permissao and then another LEFT JOIN for the table tb_PermissaoGrupo with the two keys of the last two JOIN...
– Marco Souza