var id = 1;
var query =
from user in database.Users
join invoice in database.Invoices on user.Id equals invoice.UserId
where user.Id == id
select new { User = user, Invoice = invoice };
Here’s the same query, using Lambda Expression LINQ extension methods:
var id = 1;
var query = database.Users // your starting point - table in the "from" statement
.Join(database.Invoices, // the source table of the inner join
user => user.Id, // Select the primary key (the first part of the "on" clause in an sql "join" statement)
invoice => invoice.UserId, // Select the foreign key (the second part of the "on" clause)
(user, invoice) => new { User = user, Invoice = invoice }) // selection
.Where(userAndInvoice => userAndInvoice.User.Id == id); // where statement