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).
There are two overloads of `Distinct` method:

```
Distinct<TSource>(this IEnumerable<TSource> source);
Distinct<TSource>(this IEnumerable<TSource> source, IEqualityComparer<TSource> comparer);

```

Apparently, you are using the first one which use a default equality comparer to compare values. Default equality comparer for reference types compares them by reference that's why all your `new Countries_List_ResultModel` are different for comparer.
You can create your own custom comparer that checks the equality of `currency` and use overload that takes `IEqualityComparer<TSource> comparer` as a parameter.

```
     return Context.p_Countries_List(userName, statusCode, statusMessage)
              .Select(c => new Countries_List_ResultModel()
            {
                currency = c.currency
            }).Distinct(new MyCustomComparer()).ToList();

    public class MyCustomComparer : IEqualityComparer<Countries_List_ResultModel>
    {
        public bool Equals(Countries_List_ResultModel x, Countries_List_ResultModel y)
        {
            if (x == y) return true;
            if (x == null || y == null) return false;
            return x.currency == y.currency;
        }

        public int GetHashCode(Countries_List_ResultModel obj)
        {
            if (obj == null) return 0;
            return obj.currency.GetHashCode();
        }
    }

```