Load Data from Service

Topics: Prism v4 - Silverlight 4
Apr 19, 2011 at 4:41 PM

Hi,

I am getting problem to get the data in the correct time when i try use my dataservice.Currenlty i have thre method from my service:

- GetListOfEntity1(). Call to the service and set a object liek "selectedDefaultOjbect"   //binding to a dropdown

 

 private void ServiceGetEntity1List(ObservableCollection<Entity1> results)
        {
            Entity1List= results;
            SelectedDefaultEntity1 = Entity1List.FirstOrDefault();           
        }

 

- GetListofEntity2()   //binding to a dropdown

 

 private void ServiceGetEntity2List(ObservableCollection<Entity2> results)
        {
            Entity2List= results;
            SelectedDefaultEntity2 = Entity2List.FirstOrDefault();           
        }

 

- LoadDAta() this method is called using the property SelectedDefaultEntity1 and  SelectedDefaultEntity2. then first call the first two method and after call the third one.

 

  private void LoadData()
        {
            if(SelectedDefaultEntity1!= null && SelectedDefaultEntity2!= null)
            {
                              _dataService.GetProductionData(ServiceGetEntiy3Result, SelectedDefaultEntity1.Id,SelectedDefaultEntity2.Id);
            }
        }

 

 

- Also I have some important properties

 

       public Entity2 SelectedDefaultEntity2
        {
            get { return _selectedDefaultEntity2; }
            set
            {
                _selectedDefaultEntity2= value;
                this.RaisePropertyChanged("SelectedDefaultEntity2");
               LoadData();
            }

        }



       public Entity1 SelectedDefaultEntity1
        {
            get { return _selectedDefaultEntity1; }
            set
            {
                _selectedDefaultEntity1= value;
                this.RaisePropertyChanged("SelectedDefaultEntity1");
                LoadData();
            }

        }

Now the problems are:

- LoadData method is called twice because i don't know which property will be set first: SelectedDefaultEntity1 or SelectedDefaultEntity2 :(

- Also i am putting LodData in both properties because in the user interface any change in the control throw the call the data again. (if the user change the dropdown1 then the system need load again the data, the same for the second dropdown).

 

Any help is very appreciated!

Rolando

 

 

Developer
Apr 19, 2011 at 6:17 PM

Hi Rolando,

As this is not related with Prism's guidance, you might find better support in the Silverlight Forums.

Thanks,

Guido Leandro Maliandi
http://blogs.southworks.net/gmaliandi