How can I write the following code more elegantly using LINQ query syntax?
var mergedNotes = new List<Note>();
var noteGroupsByUserID = notes.GroupBy( x => x.UserID );
foreach (var group in noteGroupsByUserID)
{
var sortedNotesByOneUser = group.OrderBy( x => x.CreatedOn ).ToList();
var mergedNotesForAUserID = GetMergedNotesFor( sortedNotesByOneUser );
mergedNotes.AddRange( mergedNotesForAUserID );
}
return mergedNotes;