to use Distinct as you mentioned above you have to create another class the implements
IEqualityComparer<whatevertypenwas>
and then pass a new instance of that to your query. For example:
class NyClassN
{
public string TypeMis { get; set; }
public int ID { get; set; }
public string Mission { get; set; }
}
<br />
class NyClassNEqComp : IEqualityComparer<NyClassN>
{
public bool Equals(NyClassN x, NyClassN y)
{
return x.Mission.Equals(y.Mission) && x.TypeMis.Equals(y.TypeMis);
}<br />
public int GetHashCode(NyClassN obj)
{
return string.Format("{0}{1}", obj.Mission, obj.TypeMis).GetHashCode();
}
}<br />
class Program
{
static void TestAg(string mTypeMis)
{
var q = (from N in new List<NyClassN>()
where N.TypeMis == mTypeMis
select N).Distinct (new NyClassNEqComp());
}
}
Or implement a public class
DelegateComparer : IEqualityComparer{}
then add an extension:
public static IEnumerable Distinct(this IEnumerable items, Func equals, Func hashCode)
{
return items.Distinct(new DelegateComparer(equals, hashCode));
}
and then you can call
.Distinct((a, b) => a.Mission_ID== b.Mission_ID, c => c.Mission_ID.GetHashCode());