Build enterprise application with WPF, WCF, Entity Framework and Prism. Tutorial 04.

The first problems I always encounter when I design a scalable, multi-tier application are:

  • Work on a disconnected environment but be able to work with the data previously downloaded.
  • Keep always the data up to date, notify the users when the data changes.
  • Threading and UI performances, do not provide frozen screen when the user requests the data.
  • Synchronization from the database and the disconnected environment.

Those are common problems of a complex software and can be solved using a SOA service solution and WPF for the UI. Of course WPF and WCF by themselves cannot help us without a strong and well designed solution.

The idea of having a SOA service for the communication will give us the ability to design something like this:


Where we will have 1 or more databases, remotely stored somewhere; a distributed SOA service that will allow our software to operate with the remote data, and maybe to have also some security concerns; the final Client application that will be build using some techniques, in order to use the full power of this kind of solution.

Of course this sketch is fancy and cool but it doesn’t give us anything more than a .PNG file that we can present to the CTO or to the customer! What you have to do in order to transform the sketch in a real solution, it’s complex and hard.

Consideration when working with SOA Services.

The first consideration we have to do, if we decide to leave the DAL on a remote web service, and work with a completely disconnected environment, is the data synchronization and the data concurrency.

Let’s make a very simple self explanatory workflow.


We have the order 10-AED-2020 and is opened remotely by 3 employees in the same time. Everyone makes a change to the row, and then they all try to save the changes. What will happen? … a mess …

Usually, what I do, is to “virtually” lock the record so when someone else try to open the row, the UI notifies that the row is already opened by someone else. Then when the “someone else” save or close the row, we notify the changes to everybody.

The second problem can be called routing messaging approach.
Also for this problem I have drawn a simple workflow. (Sorry guys but I love Visio!) tongue-out


The process is described below:

  1. The Vendor requests for a new order
  2. The software submit the request to the service and wait
  3. The service creates the order
  4. The service gives back to the client the new order created

As you can see we can have two different type of message: a single way message (the request) and a request and response message (create order), that has a delay time.

Of course there are many others considerations but for now this is enough for what we are going to do.

Some interesting articles.

Before writing XML or C# code I wish you will have the time to read those articles that I have found really interesting, especially if you had never step into an n-tier application.

MSDN – Build service oriented app

The Entity Framework In Layered Architectures

Patterns for Flexible WCF services

In the next tutorial we will write the code to exposes our entities through WCF, but of course we will not expose directly them but an “alias”. I will show the differences from using a DTO or something else.

Stay tuned!

Leave a comment

Your email address will not be published. Required fields are marked *