Search code examples
wcf-ria-services

Populate a generic list from a ria service


I am using wcf ria services in a silverlight application. I am looking at creating a dashboard for my users using some on the telerik graphing tools. I want 3 different graphs but all 3 graphs will be bound to the same data just displayed in a different ways.

I am not really sure the best approach to take. In my application loaded event do I create a generic list and then call my ria service to populate the list, I then could create some methods that bind the graphs to the data allowing me to modify the data display for each of the graphs or should I be doing it differently?

I am trying to populate the generic list like

  void BusinessReporting_Loaded(object sender, RoutedEventArgs e)
   {

       StoreID = Convert.ToInt32(App.Current.Resources["LC"].ToString());

       LoadOperation loadOp = this._ctx.Load(_ctx.GetTransactionEntriesQuery(StoreID));
       var data = loadOp.Entities.ToList();
   }

However no entities are been returned, why is that? I know there are entries in the database.

Any help would be great.


Solution

  • Add 'loadOp.Completed' event handler and load your .Entities in the event handler. Something like this ( sorry I'm typing from my iPhone and can't seem to figure out the formatting options)

        loadOp.Completed += loadOp_Completed;
    }
    void loadOp_Completed(object sender, EventArgs e)
    {
        var op = ( LoadOperation<YourGenericType>>)sender;
        var data = op.Entities.ToList();
    }