Problem: I would like to generate the exact sql below in the desired output using linq syntax (Entity framework 7)
The purpose of the question is to create the exact sql below! Desired Result
select a.AppUserId, u.Email, a.FirstName, a.MiddleName, a.LastName, a.IsInternal, a.AspNetUserId, a.PictureLink, a.SignatureLink, a.PhoneNumber, a.Extension, a.FaxNumber, a.MobileNumber, a.Skype, r.Name as 'Role', a.SupervisorId, a.BackUpId, a.HasAutoAssignClaims, a.IsActive from AppUser a join AspNetUsers u on a.AspNetUserId = u.Id left join AspNetUserRoles ur on u.Id = ur.UserId left join AspNetRoles r on ur.RoleId = r.Id
I can only get the same sql, but with internal connections. I can't seem to get two left connections. Below is the code below, how I was able to generate internal joins, as well as an attempt to crash when creating left joins.
SELECT [a].[AppUserId], [a].[FirstName], [a].[MiddleName], [a].[LastName], [a].[IsInternal], [a].[AspNetUserId], [a].[PictureLink], [a].[SignatureLink], [a].[PhoneNumber], [a].[Extension], [a].[FaxNumber], [a].[MobileNumber], [a].[Skype], [a].[SupervisorId], [a].[BackUpId], [a].[HasAutoAssignClaims], [a].[IsActive] FROM [AppUser] AS [a] INNER JOIN [AspNetUsers] AS [b] ON [a].[AspNetUserId] = [b].[Id] INNER JOIN [AspNetUserRoles] AS [c] ON [b].[Id] = [c].[UserId] INNER JOIN [AspNetRoles] AS [d] ON [a].[RoleId] = [d].[Id]
The code with the inner join works, but I need left joins ....:
var query = (
The code with the left connection ... which I do not have, does not work
what doesn't work is that on g2.RoleId is equal to d.Id in the group3 g2 line is not available. So how can I make c.RoleId available for my next left connection? Basically, after you group something, you can no longer use it.
var LeftJoin= (
