Linq-to-sql join/where?

Posted by Curtis White on Stack Overflow See other posts from Stack Overflow or by Curtis White
Published on 2010-06-03T18:50:37Z Indexed on 2010/06/03 18:54 UTC
Read the original article Hit count: 173

Filed under:

I've the following table structures

Users id

Types id isBool

UsersTypes userid types

I want to select all the UserTypes based on id and isBool.

I tried this query

var q = from usertype in usertypes
        from type in types
        where type.isBool == false
        where userstypes.user == id
        select usertype;

But this did not work as expected. My questions are:

  1. Why?
  2. Is there any difference in using the join on syntax vs where, where vs where cond1 && cond2? My understanding is query optimizer will optimize.
  3. Is there any difference in using where cond1 == var1 && cond2 == var2 with and without the parenthesis? This seems peculiar that it is possible to build this without parenthesis
  4. What type of query do I need in this case? I can see that I could do a subquery or use a group but not 100% sure if it is required. An example might be helpful. I'm thinking a subquery may be required in this case.

© Stack Overflow or respective owner

Related posts about linq-to-sql