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
The query you're after should be pretty close to this:
var query =
from cu in company_user
where cu.company_id == 1
join u in user on cu.user_id equals u.user_id
join i in invoice on u.user_id equals i.user_id
group i.amount by new
{
u.firstname,
u.lastname,
} into gs
select new
{
firstname = gs.Key.firstname,
lastname = gs.Key.lastname,
count = gs.Count(),
sum = gs.Sum(),
};
Enjoy!