I have an Access database with duplicate fields in the HappenedOn column that I wish to order by in my LINQ queries. When it is sorted descending (as shown in the screenshot below), there are two duplicate dates. When sorted ascending, there are also two duplicate dates.
When I run either OrderBy or OrderByDescending,
var currentMeeting = _context.MeetingT
.OrderBy(m => m.HappenedOn)
.Select(m => m.MeetingId).FirstOrDefault();
var currentMeeting = _context.MeetingT
.OrderByDescending(m => m.HappenedOn)
.Select(m => m.MeetingId).FirstOrDefault();
I get an exception that is unexpected for the method FirstOrDefault, "Sequence contains more than one element". This does not happen when I order by a field that has no duplicates, like the MeetingId column. I may be mistaken, but I believe that an arbitrary record should be returned if there are two records that have the same value in the sort field.