Search code examples
c#silverlightwcfriadomainservices

Silverlight RIA DomainService with 2 million rows in a table


I'm doing a project that reads from an oracle database. I have used Silverlight RIA, and autogenerated DomainService since I'm not too concerned about structuring as I only worry about displaying the data.

My question is, that when I use the domaindatasource from the XAML, and use fiddler for debugging the WCF service and its calls, the first set of data from the table of useraccounts contains 2 million rows, and the DomainService times out.

Now I have tried increasing the timeout of the service to 20 mins, but still no avail, I get the error:

Load operation failed for query "GETUA_USERACCOUNTS". The http request to has exceeded the alloted timeout

Also out of the total 9 tables that I use, 3 tables have around 2 million rows, what would be the best method to approach this problem?


Solution

  • To continue where TomTom left off, and Red asked, do your data filtering / processing on the server, before returning the results (Psuedocode)

    public IQueriable<UserDTO> GetUserAccountDetails(string UserID)
    {
        DataSet oneBazillionRows = SQLServer.GetAllUserRows();
    
        // LINQ to the rescue
        return from user in oneBillionRows
               where user.ID = UserID;
    }
    

    and your comsumer:

    public void GetUserInfo()
    {
        ServiceContext context = new ServiceContext();
        context.Load<UserDTO>(ServiceContext.GetUserAccountDetailsQuery(), load =>
        {
            // do some work here
            //like signalling the call is complete
            // or storing the data in your View Model
        }, null);
    }
    

    You consumer will then only recieve the one data row. The basic form is like so:

    public IQueriable<ReturnType> WebService(Parameter parameter, ...)
    {
        // Do all your work here, return minimal results
    }
    

    Consider: Invariably, the sever is going to be a lot beefier than your client machine. Let it do all the work of filtering / sorting / preprocessing results, and have it hand over minimal data. You will find your RIA implementations become much more snappy.