tags:

views:

138

answers:

3

Registered table has stucture

regid
userid

var Registered = form r in dc.registered  where ... // list contains userid as f.k.

I want user list who has registered.

so query like

var user = from u in dc.users where u.userid in // should contains in Register.userid

I want to learn more about linq where I can find best stuffs?

A: 

I'm not sure your question is all that clear... but...

This resource is a great starting point for Linq: http://msdn.microsoft.com/en-us/vcsharp/aa336746.aspx

mezoid
A: 

You can do something like:

var innerQuery = from r in dc.Registered
                 select r;

var outerQuery = from k in dc.Users
                 where (innerQuery).Any(x => x.UserID == k.UserID)
                 select k;

Don't know if it's completely correct regarding the syntax, but this is one way to do subqueries in LINQ. In any case it should point you in the right direction.

About learning LINQ, this is another question that handles the same: What are some good LINQ resources.

Cloud
A: 

I suspect you want:

var users = from u in dc.users 
            join r in Registered on u.userid equals r.userid
            select u;

Note that this will be more efficient than an "Any" solution as it will build up the set of registered user IDs once (as a hashset) at which point the test for each user is quick.

Jon Skeet
I dont know why but still not working. I am separating 'var Registered' because it has also some filtration.
Vikas
"Not working" is pretty vague. Does it compile? If so, what results does it give? Too many? Too few? The wrong kind of result?
Jon Skeet
Ok I solved It. getting help from LINQPad
Vikas