I have a linq query that gets some records from a database using Entity Framework Core, like this:
var result = (from users in _context.Users
on ratings in _context.Ratings on ratings.UserId = users.Id
select new
{
FirstName = users.FirstName,
LastName = users.LastName,
Rating = ratings.Rating
}
).ToList();
This give me something like:
John Doe 7
John Doe 4
John Doe 8
John Doe 9
John Doe 7
But I would like it to be in one record, like this:
John Doe 7 4 8 9 7
The result can be an anonymous type that is returned in Json through a web api.
Is this possible using the above query or do I have to do some processing afterwards using a foreach loop?