Link to home
Start Free TrialLog in
Avatar of razza_b
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
Avatar of lcohan
lcohan
Flag of Canada image

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/
Avatar of Bill Prew
Bill Prew

Are you looking for "LINQ Method syntax" or "LINQ Query syntax"?

»bp
Avatar of razza_b

ASKER

Method syntax please.
ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of razza_b

ASKER

I applied a little tweaking and does the job, thank you sir!
Great, glad that helped.


»bp