Reputation: 127
Apologies if this is on here already. Im new to coding with linq and entity framework in vb.
I have 3 tables. Account table, User table with user_id row and a junction table to map the user_id to the account_id.
I want to get a list of accounts that belong to a user_id using linq and entity framework in vb.
dim findid = 1
return context.Accounts.Where(Function(m) m.Users.Any(Function(x) context.Users.Contains(findid)).tolist
Hope you can help, its driving me nuts.
Upvotes: 1
Views: 99
Reputation: 3582
Try this:
dim findid = 1
return context.Accounts
.Where(Function(m) m.Users.Any(Function(x) x.user_id = findid)).ToList()
Upvotes: 1