LINQ to Entities 3.5 doesn't support String.Join so I'm binding my gridview to a property I define outside the Select statement. Obviously it's not letting me sort on RecipientNames because it's just an IEnumerable and that doesn't make sense. How can I use LINQ to Entities to sort on my new column? If possible I'd like to get rid of RecipientNamesList altogether and create something that LINQ will be able to handle for sorting.
IQueryable<NotificationDetail> resultsFlattened = results.Select(n => new NotificationDetail()
{
..
RecipientNames = n.NotificationRecipients.Select(nr => nr.Recipient.RecipientNameFirst + " " + nr.Recipient.RecipientNameLast).Where(s => s.Trim().Length > 0)});
});
IQueryable<NotificationDetail> resultsPaged = ApplySortingPaging(resultsFlattened,SortPageOptions);
return resultsPaged.ToEntityList(results.Count()); //blows up here, obviously
public string RecipientNamesList
{
get
{
return String.Join(", ", RecipientNames.ToArray());
}
}
IComparable
. – Nick Larsen