For my function
IEnumerable<CallbackListRecord> LoadOpenListToProcess(CallbackSearchParams usp);
This error line when the sequence contains no elements (as it should)
CallbackListRecord nextRecord = CallbackSearch.LoadOpenListToProcess(p).First();
I changed it to the following
CallbackListRecord nextRecord = null; IEnumerable<CallbackListRecord> nextRecords = CallbackSearch.LoadOpenListToProcess(p); if (nextRecords.Any()) { nextRecord = nextRecords.First(); }
Are there better, simpler, or more elegant ways to determine if an IEnumerable sequence has any elements?
source share