I have a simple linq lambda statement
Interactions = new BindableCollection<InteractionDTO>(ctx.Interactions.Where(x => x.ActivityDate > DateTime.Today)
.Select(x => new InteractionDTO
{
Id = x.Id,
ActivityDate = x.ActivityDate,
subject = x.Subject,
ClientNames = x.Attendees.Count == 1 ? x.Attendees.FirstOrDefault().Person.CorrespondenceName :
x.Attendees.FirstOrDefault().Person.CorrespondenceName : "Multiple attendees"
}));
This will give me the first Client Name, I'm trying to have it appear First 2 attendees followed by dots. I tried this
ClientNames = x.Attendees.Count == 1 ?
x.Attendees.FirstOrDefault().Person.CorrespondenceName :
x.Attendees.FirstOrDefault().Person.CorrespondenceName +
x.Attendees.Skip(1).FirstOrDefault().Person.CorrespondenceName + " ..."
But I get this error:
The method 'Skip' is only supported for sorted input in LINQ to Entities. The method 'OrderBy' must be called before the method 'Skip'.
I'm not sure what your Attendees class looks like, but assuming it has an ID field: