Question: Distinct is not giving distinct row for table

```
 ObjectParameter statusCode = new ObjectParameter("StatusCode", typeof(int));
 ObjectParameter statusMessage = new ObjectParameter("StatusMessage", typeof(string));
 return Context.p_Countries_List(userName, statusCode, statusMessage)
              .Select(c => new Countries_List_ResultModel()
            {
                currency = c.currency
            }).Distinct().ToList();

```

Answer: 
You have to override `Equals` so `Distinct` knows how to tell one instance from another.

```
public class Countries_List_ResultModel
{
    public override bool Equals(object obj)
    {
        var item = obj as Countries_List_ResultModel;

        if (item == null)
        {
            return false;
        }

        return true; // Add the appropriate logic.
    }

    public override int GetHashCode()
    {
        // Return the hashcode to quickly identify different instances.
        return this.currency.GetHashCode();
    }
}

```

More info [here](https://stackoverflow.com/questions/9601674/creating-a-distinct-list-of-custom-type-in-c-sharp).
I found the answer and this is working.

```
        ObjectParameter statusCode = new ObjectParameter("StatusCode", typeof(int));
        ObjectParameter statusMessage = new ObjectParameter("StatusMessage", typeof(string));
        return Context.p_Currencies_List(userName, statusCode, statusMessage).Distinct().Select(c => new Countries_List_ResultModel()
        {
            currency = c
        }).ToList();

```