New Posts New Posts RSS Feed: Master-Detail grid self referenced
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Master-Detail grid self referenced

 Post Reply Post Reply
Author
pponzano View Drop Down
Senior Member
Senior Member
Avatar

Joined: 28-Apr-2011
Location: Italy
Posts: 165
Post Options Post Options   Quote pponzano Quote  Post ReplyReply Direct Link To This Post Topic: Master-Detail grid self referenced
    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
Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 783
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post Posted: 21-Dec-2011 at 2:30pm
Hi Paolo,
 
I'm investigating this issue and will follow up shortly.
 
Silvio.
Back to Top
pponzano View Drop Down
Senior Member
Senior Member
Avatar

Joined: 28-Apr-2011
Location: Italy
Posts: 165
Post Options Post Options   Quote pponzano Quote  Post ReplyReply Direct Link To This Post Posted: 23-Dec-2011 at 2:08am
any news Silvio?
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down