Print Page | Close Window

Master-Detail grid self referenced

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=3172
Printed Date: 26-Apr-2024 at 12:09am


Topic: Master-Detail grid self referenced
Posted By: pponzano
Subject: Master-Detail grid self referenced
Date Posted: 20-Dec-2011 at 2:38am
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 myComplexTypeComparer: 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



Replies:
Posted By: sbelini
Date Posted: 21-Dec-2011 at 2:30pm
Hi Paolo,
 
I'm investigating this issue and will follow up shortly.
 
Silvio.


Posted By: pponzano
Date Posted: 23-Dec-2011 at 2:08am
any news Silvio?



Print Page | Close Window