none
RIA Services not displaying large data set (LoadOperation)

    Question

  • Hello everyone,

    I have a database running on another computer and have used Silverlight + RIA Services + Entity Framework to display the data. One of my tables only has one record and binds to a DataGrid fine:

            private LoadOperation<station> loadOp;
    
            public MainPage()
            {
                InitializeComponent();
    
    
               loadOp = this._weatherDataContext.Load(this._weatherDataContext.GetStationsQuery());
              
               loadOp.Completed += new EventHandler(loadOp_Completed);
               
            }
    
            void loadOp_Completed(object sender, EventArgs e)
            {
                dgWeatherData.ItemsSource = loadOp.Entities;
    
            }


    However when I try the same code on my large/main table, the Silverlight page loads up and displays all the column names in the DataGrid but all of the data is missing - the LoadOperation does not return anything.

            private LoadOperation<WeatherData> loadOp;
    
            public MainPage()
            {
                InitializeComponent();
    
    
               loadOp = this._weatherDataContext.Load(this._weatherDataContext.GetWeatherDatasQuery());
              
               loadOp.Completed += new EventHandler(loadOp_Completed);
               
            }
    
            void loadOp_Completed(object sender, EventArgs e)
            {
                dgWeatherData.ItemsSource = loadOp.Entities;
    
            }



    This table contains 13,702 records, is it too many for RIA Services to process? 

    Here are the Queries from the Service class:

     // Implements application logic using the WeatherEntities context.
        // TODO: Add your application logic to these methods or in additional methods.
        // TODO: Wire up authentication (Windows/ASP.NET Forms) and uncomment the following to disable anonymous access
        // Also consider adding roles to restrict access as appropriate.
        // [RequiresAuthentication]
        [EnableClientAccess()]
        public class WeatherDataService : LinqToEntitiesDomainService<WeatherEntities>
        {
    
            // TODO:
            // Consider constraining the results of your query method.  If you need additional input you can
            // add parameters to this method or create additional query methods with different names.
            // To support paging you will need to add ordering to the 'stations' query.
            public IQueryable<station> GetStations()
            {
                return this.ObjectContext.stations;
            }
    
            // TODO:
            // Consider constraining the results of your query method.  If you need additional input you can
            // add parameters to this method or create additional query methods with different names.
            // To support paging you will need to add ordering to the 'updates' query.
            public IQueryable<update> GetUpdates()
            {
                return this.ObjectContext.updates;
            }
    
            // TODO:
            // Consider constraining the results of your query method.  If you need additional input you can
            // add parameters to this method or create additional query methods with different names.
            // To support paging you will need to add ordering to the 'WeatherDatas' query.
            public IQueryable<WeatherData> GetWeatherDatas()
            {
                return this.ObjectContext.WeatherDatas;
               
            }



    Many thanks,

    Mike

    Tuesday, June 12, 2012 8:30 AM

Answers

  • RIA Services is best thought of as an n-tier Business Logic Layer. On the server you create the business logic layer where validations and security are enforced. On the client you get a data model very similar to what you have on the server and you get a copy of the validations so that your UI can have instant feedback to the user. If you follow the link in my signature about RIA Services and MVVM you will find the recommended way of setting up your code. It is a bit.ly bundle that starts with a John Papa video and then goes thorugh some modifications to the original from the RIA Services team and myself.

    Tuesday, June 12, 2012 12:22 PM
  • You can also use paging (from the client side, use .Skip and .Take on your query) to load your date in chunks.

    Tuesday, June 12, 2012 4:48 PM

All replies

  • You are probably hitting the MaxObjectsInGraph limit, use this to fix it.

    Tuesday, June 12, 2012 10:43 AM
  • Thanks Colin, I will try that fix.

    I'm new to RIA services, do I simply think of this as a 'middle-man' that manages interactions between Silverlight and the Entity model?

    As opposed to WPF that allows you to directly use Entity Framework

    Thanks

    Tuesday, June 12, 2012 11:01 AM
  • RIA Services is best thought of as an n-tier Business Logic Layer. On the server you create the business logic layer where validations and security are enforced. On the client you get a data model very similar to what you have on the server and you get a copy of the validations so that your UI can have instant feedback to the user. If you follow the link in my signature about RIA Services and MVVM you will find the recommended way of setting up your code. It is a bit.ly bundle that starts with a John Papa video and then goes thorugh some modifications to the original from the RIA Services team and myself.

    Tuesday, June 12, 2012 12:22 PM
  • The fix worked great, thanks a lot!

    If the amount of records reaches > 655360, would I be better off using stored procedures or a different way to query the histortical weather data? (i.e. max temp, wind speed, rainfall ever recorded etc)

    Tuesday, June 12, 2012 4:35 PM
  • You can also use paging (from the client side, use .Skip and .Take on your query) to load your date in chunks.

    Tuesday, June 12, 2012 4:48 PM