Introduction

 

In the WCF RIA Services PDC release, Live IntelliSense was first introduced to enable no-build experience for RIA Services development.  More information about this feature can be found in: Live IntelliSense in WCF RIA Services for VS2010.

 

In the WCF RIA Services 1.0 RTW release, the feature has been extended to support data binding scenarios.  If you make changes to models or services at server side and switch to client side without building the solution, you will find not only IntelliSense but also the data sources shown in the Data Source Window can automatically get updated at client side now.  Below is an example to show you how this happens.

 

Example

 

First I create a new Silverlight Business Application.  When I open MainPage.xaml in the client project, the Data Source Window shows up with UserRegistrationContext and RegistrationData (if it doesn’t, click Menu -> Data -> Show Data Sources):

clip_image001 

In this application, I’d like to collect user’s gender in registration so that I can display an appropriate profile on the home page for him/her.  Hence, I switch to the server project and append a new property to the end of the RegistrationData class in Models\RegistrationData.cs (C#):

/// <summary>

/// Gets and sets the gender.

/// </summary>

[Required(ErrorMessage="Gender is required.")]

[Display(Order = 7, Name = "Gender")]

public string Gender { get; set; }

Or in Models\RegistrationData.vb (VB):

''' <summary>

''' Gets and sets the gender.

''' </summary>

<Required(ErrorMessage:="Gender is required.")> _

<Display(Order:=7, Name:="Gender")> _

Public Property Gender() As String

To get the new property propagated to the client generated code and shown in the Data Source Window, I would have to build the entire solution when using the PDC release. But it’s no longer necessary with the RTW release.  Instead, I switch back to the client project directly.  The newly added property Gender shows up after the Data Source Window refreshed:

clip_image002 

It looks good so far.  Then I hope to display Gender after Email but before Question when dragging & dropping RegistrationData to XAML.  So I go back to Models\RegistrationData.cs and change the order to 3 in the property’s DisplayAttribute.  The new order is in the middle between the orders of Email and Question:

/// <summary>

/// Gets and sets the gender.

/// </summary>

[Required(ErrorMessage="Gender is required.")]

[Display(Order = 3, Name = "Gender")]

public string Gender { get; set; }

Or in Models\RegistrationData.vb (VB):

''' <summary>

''' Gets and sets the gender.

''' </summary>

<Required(ErrorMessage:="Gender is required.")> _

<Display(Order:=3, Name:="Gender")> _

Public Property Gender() As String

Again, I switch focus back to the client project without building solution.  This time the Data Source Window gets refreshed and moves the Gender property up:

clip_image003 

Besides updating the registration page with the new property, I plan to create a new client page as well to show the basic registration information for administrator only.  Meanwhile I add a new query method in Services\UserRegistrationService.cs at server side to support the query on the Gender field:  

public IEnumerable<RegistrationData> GetUsersByGender(string gender)

{

}

Or in Services\UserRegistrationService.vb (VB):

          Public Function GetUsersByGender(ByVal gender As String) As IEnumerable(Of RegistrationData) 

End Function

I left the method body blank because I wanted to implement it later on.  Normally the solution can’t be built at the moment as the compiler would tell you that not all code paths return a value. However, I just want to know how the client generated code looks like now, so again I switch focus to client and check the Data Source Window:

clip_image004 

The new query method GetUsersByGenderQuery comes out with the Data Source Window refreshing.  Next, I select the new query method as default, disable Question, Answer in the Data Source Window and drag drop RegistrationData to the new page:

clip_image006

 

Conclusion 

 

You may have noticed that I had never built the solution in the entire example!  Yes, this feature can help you get rid of most of the intermediate builds which are only for propagating server changes to client.   Moreover, VS is clever enough to know whether the code changes at server side would change the client generated code or not so that it can decide whether the Data Source Window should get refreshed or not when the focus is switched to client from server.  This makes the development experience across the server/client projects even smoother.  Now launch your VS2010 with WCF RIA Services and give it a shot!

Enjoy!