I\'m fighting with linq trying to learn the syntax and I can\'t figure out how to do the following simple query
SELECT DISTINCT
user.firstname,
user.last
Since op mentioned learning syntax, here's a fluent version:
company_user
.Where(x => x.company_id == 1)
.Join(
user,
x => x.user_id,
x => x.user_id,
(o,i) => new {
FirstName = i.firstName,
LastName = i.lastName,
InvoiceCount = invoice.Count(y => y.user_id == o.user_id),
InvoiceSum = invoice.Where(y => y.user_id == o.user_id).Sum(y => y.amount)
}
).GroupBy(x => new { x.FirstName, x.LastName })
.Distinct()