You’ve decided to create a new business application (meaning some n-tier application) using Silverlight as the frontend. Is Silverlight the best choice? That’s a debate for another post… Anyway, now it comes to deciding on a data access strategy, which one do you choose? Well this is one of those things where there is no clear winner. To make a choice, Shawn Wildermuth has a great post on the “State of Data Access in Silverlight 4.” Looking at his awesome chart comparing plain WCF, WCF Data Services, and WCF RIA Services, you’ll see that some of the things on the “Cons” side for all of the approaches could be a deal breaker. So which one should you choose? Let me take you through a deliberation that I was involved in recently when forced to make this decision. There is no right answer here (as with most interesting topics), but I would be interested in your feelings on the topic. Let’s get started…
Given the three strategies that Shawn had identified, we had pretty much focused on just WCF Data Services and WCF RIA Services. Plain old WCF services are useful for a lot of things, but they aren’t very flexible on their own. Things like client-side shaping, sorting, filtering or paging are rough, plus I don’t see the value in writing boilerplate service code for CRUD operations. I suppose you could use something like a T4 template for that, but for “standard” web services the thing I really don’t like is SOAP. I won’t wax poetic about how REST makes so much more sense than SOAP, but if you are interested, you should check out RESTful .NET: Build and Consume RESTful Web Services with .NET 3.5 by Jon Flanders, it’s a fantastic book. Sure, you could have a standard WCF Service using REST instead of SOAP, but I don’t believe that you can generate a proxy against a WCF REST service (I don’t mind WebClient/HttpWebRequest code). That isn’t a deal breaker, but it is when writing a lot of code against a lot of objects. We decided that standard WCF just wasn’t the easiest option for the lion’s share of the work.
So that leaves us with WCF Data Services or WCF RIA Services. For a previous project we had discounted using WCF RIA Services for the majority of the data access (though, we did use it for user roles and such). Trying to go into a new project with an open mind, we thought we should dig a little deeper into RIA, after all, it “seems” to be the approach that you should use for a business application as you’ll see.Read More »