Continuing in our discussion of Silverlight 3 and the update to .NET RIA Services. I have been updating the example from my Mix09 talk “building business applications with Silverlight 3”.
You can watch the original video of the full session
The demo requires (all 100% free and always free):
I was very surprised recently when someone mentioned that RIA Services only worked with Entity Framework. That is of course not true, but then I realized that we have not been demoing it with LinqToSql nearly enough. So I thought I’d update my demo app to use LinqToSql rather than Entity Framework.
There are lots of reasons you might be using LinqToSql.. Some folks have found it lighterweight and easier to moch making testablity more simple. Others standardized on it for a project and others just prefer it. Either way, RIA Services works great with LinqToSql.
Let’s switch over the example application to use LinqToSql. First let’s add a new edmx..
And drag the SuperEmployee table over..
Save and build!
Now we make some very minor changes to the SuperEmployeeDomainService..
2: public class SuperEmployeeDomainService : LinqToSqlDomainService<SuperEmployeeDataContext>
5: public IQueryable<SuperEmployee> GetSuperEmployees()
7: return this.Context.SuperEmployees
No changes to the client at all.. Build hit F5 and the app runs
Notice in line 2, we are using the LinqToSqlDomainService as a base class rather than the EntityFrameworkDomainService.
In line 7, notice that nothing changes here.. the power of Linq!
That is really all we had to do… hit F5 and the main Silverlight App we were building keeps working..
And all the other goodness just keeps working as well… let’s revisit them all just to remind ourselves how cool RIA Services is 😉
The ASP.NET page that is our sitemap
The ASP.NET page that renders downlevel\SEO content
The ADO.NET Data Services (Astoria) REST based view
And of course, the WinForms view