I am trying to apply distinct on a linq query where I am selecting it to an IquerableModel
Ex- var query= _unitOfwork.A.getall()
join b in _unitOfWork.B.GetAll() on a.CId equals b.Id into ct1
from ct in b.DefaultIfEmpty()
// Similary have left join with 4-5 tables
select new DynamicClaimModel
{
//propert binding
}.Distinct()
But this is throwing an exception. I DO NOT WANT TO CONVERT IT TO LIST because of heavy data.
'The 'Distinct' operation cannot be applied to the collection ResultType of the specified argument.
Parameter name: argument'


Sachin SinghRank #66 · 26.2K reputationPosted Jul 21, 2021, 5:04 AM EDT
Basem AlshabaniRank #3,323 · 432 reputationPosted Jul 21, 2021, 8:06 AM EDT
Distinct use within linq is not useful
If you have 2 collection objects with the same property values,each of them will be considered a distinct object,so both of them will be retrieved
So use (group by first) approach as in answer given