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: 
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();
        }
    }

```
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();

```