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'

Basem AlshabaniPosted Jul 21, 2021, 12:06 PM
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
Sachin SinghPosted Jul 21, 2021, 9:04 AM