Geeks With Blogs
Peter Tweed Exploring and explaining the mysteries of .NET

I was asked to present on RIA Services with for the FUNdamentals session of the East Bay .NET User Group last week.  Even though I only had 30 minutes to present on the topic, I decided to show the full development of a CRUD application.  With RIA Services this is a straight forward thing to do and still allowed time to explain the concepts in use.

The solution found here is the code that was built during the demonstration at the user group.  It shows the use of Entity Framework to connect to a SQL Server database and generate a model for the Person table, combined with a Domain Service Class to handle the generation of the RIA Services CRUD operations to wrap the entity model for our project.

Once the meta data class for the Person class has been generated I added a StringLength attribute to specify a minimum and maximum length of the InterestingInfo property with a custom error message, we also added a shared partial class for the Person class adding a calculated read only property (FullName) - showing the use of the Person.shared.cs naming convention to define that the code should be shared on the Silverlight client as well as the web server.

The Silverlight application template used was the Silverlight Business Application.  The ~/Views/Home.xaml page had a datagrid added to it with two buttons - add and delete.  When the page is initialized the Person object graph of the Domain Service Context is loaded and bound to the items source of the datagrid. 

When the grid row exit edit event is fired the changes made in the datagrid are committed to the Domain Service Context and the changes are submitted so they are committed to the database.

When the add button is clicked a new Person object is added to the Person object graph of the Domain Service Context.  When the delete button is clicked the selected Person object in the datagrid is deleted from the Domain Service Context and the changes are submitted.

The above solution shows a simple CRUD application built with RIA Services to perform the heavy lifting and code generation for accessing shared functionality across a two tier environment.


Posted on Sunday, September 13, 2009 8:29 PM Silverlight | Back to top

Comments on this post: RIA Services with Silverlight for East Bay .NET User Group FUNdamentals

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © PeterTweed | Powered by: