Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Convert SQL Query To Linq
Message
From
22/06/2010 07:16:31
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
ASP.NET
Category:
LINQ
Miscellaneous
Thread ID:
01470083
Message ID:
01470150
Views:
31
>>>I could use some help converting this to linq:
>>>
>>>
>>>SELECT u.*
>>>	FROM aspnet_Users u
>>>	JOIN aspnet_UsersInRoles ur ON ur.UserId = u.UserId
>>>	WHERE ur.RoleId = @RoleId
>>>
>>>
>>>
>>>I have this so far:
>>>
>>>
>>>var user = from u in dc.aspnet_Users
>>>            where u.
>>>            select u;
>>>
>>
>>How about something like this...
>>
>>
>>var query = from u in dc.aspnet_users where u.aspnet_UsersInRoles.RoleId = RoleId select u;
>>
>>User usr = query.FirstOrDefault();
>>
>>
>>
>>Kurt
>
>That was close. This works:
>
>
>var users = from u in dc.aspnet_Users
>            from ur in u.aspnet_UsersInRoles
>            where ur.RoleId == RoleID 
>            select u;
>
>
>Thanks

You need to apply Distinct() to this one I think. Using Any() is better IMHO.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform