Musings on WCF RIA Services #2: The Backlog

The original User's Voice site for WCF RIA Services seems to be gone, luckily the Internet Archive Wayback machine has a copy. I thought it might be interesting to go through the list of the issues from the first page that have not been completed yet and see what I would do in my own fork of WCF RIA Services if it were open sourced.

 Support data change notifications from the server

I have a proof of concept design for a change notification system that uses SignalR. The DomainService needs a tweak to make it easier to get the primary keys of each entity on the server.

RIA Services support for Windows Phone 7 [Windows Phone 8, WPF, WinRT)

Windows Phone 8, WinRT, Mono (Droid and IOS), and WPF support are all a top priority and, I think, doable. However, I would not be porting the DomainDataSource as it is too specific to Silverlight.

Fluent-API based metadata (to replace buddy classes)

This is already an active project being spearheaded by Merijn.

EntityQuery<T>.Select() to project entities from the RIA Clients without creating DTOs at the server

This is very unlikely as it goes against the basic design and purpose of WCF RIA Services.

Support more of OData

In general, I think replacing the current WCF based DomainService with a WebAPI based "DomainController" would be a good direction to go in. However, WCF RIA Services is not WCF Data Services and attempts to make either one of them more like the other is misguided.

Ability to Include Navigation Properties Based on Many-to-Many relationships

The M2M4RIA project on CodePlex would be rolled into WCF RIA Services itself. I am not sure exactly what that would look like but I know Merijn is ready to handle it.

 A visual plugin for VS to manage domain services

This is very unlikely, I would be moving away from visual editors and towards direct code editing. If somebody else wants to tackly this then I would happily add it to my version.

Offline support in RIA Services

An open source WCF RIA Services would have a much improved version of RiaServicesContrib.EntityTools which does support complex types and composition. Those new hooks should allow the easy creation of rich offline capabilities.

MVVM support in project Template

 Targeted NuGet packages will probably be preferred over project templates going forward.

RIA Services support for AJAX (HTML clients)

I think HTML5 support will be important, figuring out what that means is the difficult part.

Propagate authorization/role metadata from server to client so that it can be used for building authorization-specific UI; e.g. admin sees additional named update methods that a user does not.

Honestly, I have no idea what that even means.

Paging support without requiring LINQ backend (e.g. sprocs)

This is a maybe. To some degree I feel that user defined table valued functions would accomplish the same goal without needing any changes made. I do have a few ideas here which I may try out, however it may wait until there is a user who is willing to be the guinea pig.

Transaction support from client

Same as paging support, I have some ideas here on how to package multiple SaveChanges calls from multiple DomainContexts into a single communication with the server but  no real proof of concept.

RIA Service support for ORMs besides EF

This request was about adding support for more ORMs to the DomainService wizard. Honestly, thinking long term, I am not sure if the DomainService wizard is going to keep working for EF.



WCF RIA Services EF 4.1 Scaffolding Support, WCF RIA Services Contrib, and NuGet

Two big announcements today. First, the old RiaServicesContrib.dll file has been replaced with RiaServicesContrib.EntityTools.dll and is now available as a NuGet package. The package name is RiaServicesContrib.EntityTools. Hope that is easy to remember.

The other news is that RIA Services Contrib has a new scaffolding system for EF 4.1.

Soon after WCF RIA Services support for EF 4.1 was released, Rudi Larno released a scaffolding system for building the DomainServices based on the EF model. Unfortunatly, Rudi doesn't have time to maintain what he built so I am taking it over for him. Today I added the scaffolding code to the RIA Services Contrib project on Codeplex and published it on NuGet.

The scaffold is not exactly the same as what Rudi was using. When you create a DomainService using the scaffold you may need to add a new using statement with the namespace where your POCO entities are. Also, I modified what is generated to match the snippet code supplied by Microsoft.

To install the scaffolder

1) In the Package Manager Console select the package that will contain the DomainService
2) Type Install-Package RIAServicesContrib.EntityFramework.Scaffolding and push enter

To use the scaffolding system, in the PackageManagerConsole type in the following command line:

Scaffold RiaContribEfDomainService <TEntity> <TDbContext> <TDomainService>

So, if you are adding the Customer entity from the OrderEntities DbContext and you are creating the OrderDomainService you would type

Scaffold RiaContribEfDomainService Customer OrderEntities OrderDomainService




WCF RIA Services support for EF 4.1 and Snippets

WCF RIA Services now has support for EF 4.1. Varun Puranik and Jeff Handley have details on their blogs about how to use it.

One of the really interesting things Varun provides is a snippet to help setup the DbDomainService since the Wizard will not be available until SP2 is released. After using the snippet I am not sure what we all did without it.

To help make it even better, I have made my own modifications and, since Varun released the original under MS-PL, I am adding the snippets to RIA Services Contrib. For now they are available at the bottom of this post.

I actually have six different snippets for both VB and CS covering both DbDomainService and LinqToEntitiesDomainService.

The six snippets are:

  • dbcrud : Code snippet for DbDomainService CRUD Methods
  • dbcrudt : Code snippet for DbDomainService CRUD Methods With Timestamp
  • dbnu : Code snippet for a DbDomainService Named Update Method
  • ltecrud : Code snippet for LinqToEntitiesDomainService CRUD Methods
  • ltecrudt : Code snippet for LinqToEntitiesDomainService CRUD Methods With Timestamp
  • ltenu : Code snippet for a LinqToEntitiesDomainService Named Update Method

RiaServicesContribSnippets.zip (3.78 kb) 



MEFing up RIA Services Part 2: Kyle's Turn

Last week Kyle McClellan from the WCF RIA Services team at Microsoft posted his own version of the Book Club sample. Not wanting Kyle to be left out, I decided to MEF up his code as well.

Here is the result:

MEFedUpRIAServicesMVVM_V2.zip (3.27 mb)

I think Kyle is doing some really interesting things with this code, but I think I prefer how John's original code used ObservableCollections (which were really EntityLists) instead of how Kyle is casting everything to IEnumerable or ICollection. What I will be creating next is my version of the Book Club which will be a mix of John's code, Kyle's code, and some completely different concepts that I am working on.


Updated ApplyState/ExtractState Library

Export more blog entries this week. I will be putting up my guide to the major new features after todays keynote.

In the meantime, here is an updated ApplyState/ExtractState refactored to use the EntitySet instead of the EntityList. I will put up a VS2010 version as well tonight.

RIAServicesContrib2008.zip (235.60 kb)


ApplyState and ExtractState with RIA Services Contrib

UPDATE: There is a new version of the ApplyState and ExtractState at http://www.riaservicesblog.net/Blog/post/Updated-ApplyStateExtractState-Library.aspx

Tomorrow Soon  Some day I am going to updating RIA Services Contrib with some new features. The existing T4 templates, as fun as they are, are going to left alone for now. I am going to look at them again after the PDC version of RIA Services is released. In the meantime, I am going to release some new utility classes that I have been putting together. The release is attached to this blog post and Codeplex will be updated tomorrow. 

This new contrib release adds ApplyState and ExtractState methods to Enity objects, an Import method to EntityList<T>, and an Export method to all IEnumerable<T> where T : Entity collections. To use the new code simply reference the RIAServicesContrib.dll and import the RiaServicesContrib.Extensions namespace.

Here are some usage examples:

Entity cloning

Person newPerson = newPerson();
newPerson.ApplyState(Nothing, existingPerson.ExtractState(ExtractType.ModifiedState);
newPerson.PersonId = Guid.NewGuid();

Partial Save (i.e. save only a single change instead of the whole DomainContext)

PersonDomainContext tempContext = new PersonDomainContext();
Person savePerson = newPerson();
savePerson.ApplyState(originalPerson.ExtractState(ExtractType.OriginalState, ExtractType.ModifiedState);

Export EntityList and save to Isolated Storage

using IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication()
    using IsolatedStorageFileStream isfs = new IsolatedStorageFileStream(fileName, FileMode.OpenOrCreate, isf)
        DataContractSerializer serializer = new DataContractSerializer(typeof(List<EntityStateSet>));
        serializer.WriteObject(isfs, context.Persons.Export());

Import information from Isolated Storage into EntityList

using IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication()
    using IsolatedStorageFileStream isfs = new IsolatedStorageFileStream(fileName, FileMode.Open, isf)
        DataContractSerializer serializer = new DataContractSerializer(typeof(List<EntityStateSet>));

Some things which might not be obvious is that the Export functionality can also be done against a LINQ query, allowing partial exports of entities. When I update CodePlex I am going to include better documentation of the API.

RiaServicesContrib.zip (12.97 kb)

Month List