Hello,
I'm tring to create a master-detail gridview (RadGridview from Telerik to be sincere),
I use Ideablade to catch the data, around 15columns per row, and they're a cartesian product of master detail,
consider for example
IDMaster, Description, IDDetail,DetailDescription...
public void myMethod()
{
IsBusy = true;
_repository.LoadmyData(18, Data,
results =>
{
var res = new BindableCollection<myComplexType>(results.Cast<myComplexType>());
var res2 = res;
var comparer = new myComplexTypeComparer();
bool a = comparer.Equals(res.First(), res.Last());
var m = res.Distinct(comparer); //(*)
IsBusy = false;
},
e =>
{
IsBusy = false;
MessageBox.Show(e.Message);
});
}
public class myComplexType
Comparer: IEqualityComparer<myComplexType>
{
public bool Equals(myComplexType x, myComplexType y)
{
if (x.IDMaster == y.IDMaster)
return true;
else
return false;
}
public int GetHashCode(myComplexType obj)
{
return obj.GetHashCode();
}
}
(*) If Res has 3000 items the distinct returns me 3000 items again and it seem's the comparer isn't called... I've read that in order to have .Distinct() working I need my complex type (on google's search it talks about BusinessObject that implements IEquatable) to implement IEquatable ... what can I do?
Thanks