razza_b
asked on
How to convert SQL to LINQ
Anyone know how to convert this SQL query in a context LINQ query?
SELECT [R].[Name]
FROM [dbo].[AspNetUsers] AS [U]
INNER JOIN [dbo].[AspNetUserClaims] AS [UC] ON [U].[Id] = [UC].[UserId]
INNER JOIN [dbo].[AspNetRoles] AS [R] ON [UC].[ClaimValue] = [R].[Name]
WHERE [U].[Id] = @UserId
SELECT [R].[Name]
FROM [dbo].[AspNetUsers] AS [U]
INNER JOIN [dbo].[AspNetUserClaims] AS [UC] ON [U].[Id] = [UC].[UserId]
INNER JOIN [dbo].[AspNetRoles] AS [R] ON [UC].[ClaimValue] = [R].[Name]
WHERE [U].[Id] = @UserId
You could use "Linqer" from here https://www.sqltolinq.com to help with that and there are also tools under also LinkTools https://www.thinqlinq.com/default/LINQ-Tools.aspx to help you with learning Linq along with Bill Horst blog https://devblogs.microsoft.com/vbteam/converting-sql-to-linq-part-1-the-basics-bill-horst/
Are you looking for "LINQ Method syntax" or "LINQ Query syntax"?
»bp
»bp
ASKER
Method syntax please.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I applied a little tweaking and does the job, thank you sir!
Great, glad that helped.
»bp
»bp