I need to select data from a table. The data has an Email field which is not unique. Now i only want to select the first item with an Email of its kind and ignore the others.
I tried:
var users = _context.Appointments.Where(p => (p.userId == userId))
.Select(p => new MyUserModel
{
Id = p.Id,
Email = p.User.Email
});
return users.ToList();
I wanted to use Distinct()
, but my elements are not unique, they have a different id
.
How could I go about doing that?