I have two tables.
Table 1.Users (Username, Name)
2. Table of pictures (identifier, username, IsPrimary)
Each user can have from zero to many images.
I am trying to write a query that will return to all users (with or without pictures) and one image identifier (images with IsPrimary = true).
I wrote this Linq query:
var v = from u in Users
join p in Photos on u.Username equals p.Username
select new
{
u.Username,
p.ID
};
This works, but returns duplicate user strings. (if the user has more than one photo).
I want to get one row for each user. Is it possible?
source
share