I am trying to fetch a list using EF6
.I have a class like this:
public class Province
{
public string province { set; get; }
public string provinceCode { set; get; }
}
Zone class
namespace InnoviceDomainClass
{
using System;
using System.Collections.Generic;
public partial class Zone
{
public string CityCode { get; set; }
public string City { get; set; }
public string Province { get; set; }
public Nullable<int> ProvinceCode { get; set; }
}
}
I fetch my data using this :
List<Zone> ListZone = zoneRepository.GetAll().ToList();
i need to Distinct
my records :
List<Province> ListZoneWithDistinct = ListZone.Select(i => new Province()
{
province = i.Province,
provinceCode = i.ProvinceCode.Value.ToString()
}).Distinct().ToList();
I think my problem is Distinct()
,i should tell this function based on which column should be distinct?
But my records don't change ;why ?and my records are same
my records is like this
provincecode province
10 Iran
10 Iran
15 USA
15 USA
Output that i need:
provincecode province
10 Iran
15 USA