I’m trying to learn EF in visual basic. I’m struggling with finding any easy to understand simple tutorial of how to do inner joins.
This is the SQL that i’m trying to replicate in EF:
SELECT Quote.LockedDateTime, IncommingQuoteStatus.StatusDesc, Users.FirstName
+ ' ' + Users.LastName AS UserName
FROM Quote
INNER JOIN IncommingQuoteStatus ON IncommingQuoteStatus.StatusID = Quote.Status
INNER JOIN Users ON Quote.LockedUserID = Users.UserID WHERE Quote.QuoteID = 1111;
I know there is a very short hand way of doing EF but I need to keep things as simple and readable as possible because I’m rubbish! This is the kind of thing I have been working on:
Using db2 As New quotingSystemDevEntities
Dim User = (From Users In db.Users Where Users.UserID = Quote.LockedUserID _
Select Users).SingleOrDefault
' Now I can do something
End Using
If there is anyone that can lay this out in a clear way so that I can learn from it that would be great!
I think you refer to the
joinkeyword:But in a data context generated from your database
Userwill have aQuotescollection. So you could do something like:(Convenient, but translates to an outer join).