Multiple join query in eSql

Posted by Syma on Stack Overflow See other posts from Stack Overflow or by Syma
Published on 2010-06-18T13:38:16Z Indexed on 2010/06/18 13:43 UTC
Read the original article Hit count: 384

Filed under:

Hi guys, This is my first question in stackoverflow but really not the first time to get solution here. I am struggling with multiple join in entity framework 4. I have three tables (Accounts, Users and AccountUsers) that am finding difficult to query.

What I want is to get all the users for the provided accountId including the account creator. I can get all the account users with no problem but the hard side for me is getting the account creator since it's not added to AccountUsers table. below is a quick preview how the tables are related.

Accounts

  • AccountId
  • UserId (account creator)
  • ...other columns

Users

  • UserId
  • ...other columns

AccountUsers

  • AccountId
  • UserId

I would prefer the query to be esql, but Linq to Entities will do.

I trust you guys on stackoverflow, so I know this won't take long to get the 'Answer' mark.

Thanks for even reading.

© Stack Overflow or respective owner

Related posts about entity-framework