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):

  1. VS2008 SP1 (Which includes Sql Express 2008)
  2. Silverlight 3 RTM
  3. .NET RIA Services July '09 Preview

Also, download the full demo files and check out the running application.

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.

image

Let’s switch over the example application to use LinqToSql.  First let’s add a new edmx..

image

And drag the SuperEmployee table over..

image

Save and build!

Now we make some very minor changes to the SuperEmployeeDomainService..

 

   1: [EnableClientAccess()]
   2: public class SuperEmployeeDomainService : LinqToSqlDomainService<SuperEmployeeDataContext>
   3: {
   4:  
   5:         public IQueryable<SuperEmployee> GetSuperEmployees()
   6:         {
   7:             return this.Context.SuperEmployees
   8:                        .Where(emp=>emp.Issues>100)
   9:                        .OrderBy(emp=>emp.EmployeeID);
  10:         }

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..

image

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

image

The ASP.NET page that renders downlevel\SEO content

image

The ADO.NET Data Services (Astoria) REST based view

image

And of course, the WinForms view

image