I have Author class and to get distinct records I have implemented IEquatable:
public class Authors: IEquatable<Authors>
{
public long ID { get; set; }
public string Name { get; set; }
public bool IsSelected { get; set; }
public long DT_RowId { get; set; }
public string ParentName { get; set; }
public bool Equals(Authors other)
{
if (Name == other.Name && ID == other.ID)
{
return true;
}
return false;
}
}
But when I try to get the distinct records, it returns all the records without filtering.
IEnumerable<Authors> distinctData = authorsFromService.Select(c => new Authors
{
DT_RowId = c.DT_RowId,
Name = c.Name,
ID = c.ID,
ParentName = c.ParentName ?? "",
IsSelected = c.IsSelected
}).Distinct();