I am having trouble with this error message as the line it errors on is not actually using Distinct() at all. I am wondering if it is something to do with the IEqualityComparer I’ve implemented?
It creates an unsupported exception in a view on this line, specifically on .Count():
tr style="display: @( Model.FeaturedOffers.Count() == 0 ? "" : "none" ) " id="none">
Here is the IEqualityComparer class:
public class RewardOfferEqualityComparer : IEqualityComparer<OfferOverviewViewModel>
{
public bool Equals(OfferOverviewViewModel x, OfferOverviewViewModel y)
{
return Equals(x.OfferId, y.OfferId);
}
public int GetHashCode(OfferOverviewViewModel x)
{
return x.OfferId.GetHashCode();
}
}
Found that calling
.ToList().Distinct()instead of.Distinct()solved the problem.Found answer here