How To Convert This To Linq
-
I'm fairly new with Linq. Could use some help.... I need to convert this to Linq:
SELECT r1.*
FROM aspnet_Roles r1
WHERE r1.RoleId IN
(SELECT r2.RoleId
FROM mmlaspnet_RolesToGlobalRoles r2)
ORDER BY RoleNamehelp!
Everything makes sense in someone's mind
-
I'm fairly new with Linq. Could use some help.... I need to convert this to Linq:
SELECT r1.*
FROM aspnet_Roles r1
WHERE r1.RoleId IN
(SELECT r2.RoleId
FROM mmlaspnet_RolesToGlobalRoles r2)
ORDER BY RoleNamehelp!
Everything makes sense in someone's mind
Assuming you have a DataContext hooked up to the db which we will call dbc, it should go something like this. dim r2=from i in dbc.mmlaspnet_RolesToGlobalRoles dim r1 = from i in dbc.aspnet_roles where i.RoleId.contains(r2) Not totally sure on the syntax of that one but that should get you started.
"It`s always better to have a big long wick"
-
I'm fairly new with Linq. Could use some help.... I need to convert this to Linq:
SELECT r1.*
FROM aspnet_Roles r1
WHERE r1.RoleId IN
(SELECT r2.RoleId
FROM mmlaspnet_RolesToGlobalRoles r2)
ORDER BY RoleNamehelp!
Everything makes sense in someone's mind
Let say that the instantiated data context is db, then you query in Linq would be as follows :
var r2 = from rtgr in db.mmlaspnet_RolesToGlobalRoles
select rtgr.RoleId;
var r1 = from r in db.aspnet_Roles
where r2.Contains(r.RoleId)
orderby r.RoleName
select r;fereach( var roles in r1 )
{
Console.WriteLine("RoleID = {0} ....", role.RoleId, ...);
}