I need to create a Distinct
class for a LINQ query. Let's say the Department DTO class looks like this:
public class Department
{
public int ID {get; set;} //primary key
public string Name {get; set;}
public string Address {get; set;}
}
and I need to query by distinct department names (not IDs).
Will my GetHashCode
look like
public int GetHashCode(Department record)
{
return record.NAME.GetHashCode();
}
or will it look like
public int GetHashCode(Department record)
{
return record.ID.GetHashCode();
}