views:

229

answers:

1

I have a Silverlight 4 app which pulls entities down from a database using WCF RIA services. These data objects are fairly simple, just a few fields but one of those fields contains binary data of an arbitrarily size. The application needs access to this data basically asap after a user has logged in, to display in a list, enable selection etc.

My problem is because of the size of this data, the load times are not acceptable and can approach the default timeout of the RIA service.

I'd like to somehow partially load the objects into my local data context so that I have the IDs, names etc but not the binary data. I could then at a later point (ie when it's actually needed) populate the binary fields of those objects I need to display.

Any suggestions on how to accomplish this would be welcome.

Another approach which has occurred to me whilst writing this question (how often does that happen?!) is that I could move the binary data into a seperate database table joined to the original record 1:1 which would allow me to make use of RIA's lazy loading on that binary data.

again.. comments welcome! Thanks.

+1  A: 

Don't change your database. Change your delivery method.

Create a seperate WCF RIA Service for your quick list of items and use a POCO (plain old clr object) to send down a summary of the data you need. Then, when you're ready for the big guy, you can download one at a time triggered from data from your POCO.

Brad Abrams and Nikhil Kothari have talked about using POCO for a while. Look at their MIX speeches for more information.

Create a new service for your quick list items:

public class QuickListService : LinqToEntitiesDomainService<MyEntities> 
{
    private IQueryable<QuickList> GetQuickList() 
    {
        return from t in ObjectContext.Table
              select new QuickList 
               {
                      ID = t.ID,
                     Title = t.Title
              };
    }
}

Your POCO is simply an object on the server, like this:

public class QuickList
{
    public string Title;
    public long ID;
}

Good luck!

p.s. Nikhil's BookClub app does this a lot. If you need to see a real application doing this, download his app: http://www.nikhilk.net/Content/Presentations/MIX10/BookClub.zip

Jeremiah