DevForce Silverlight Powers SecuraMail.net, the award winning high-security Silverlight email client.
"After working with Ria Services for almost a year, DevForce become the obvious answer."
Most people think email clients are old school and boring. The truth is that email was one of the first killer apps. And even today, everyone needs an email client. But little has changed since Gmail and Hotmail hit the scene. People flocked to those services because they were feature-rich, cost nothing, and easy to use. But today, there are security concerns: What happens when that email goes out across the net through many different networks? It’s not secure and you have no control over it.
The major challenge in building a secure email client is the data access. There is a lot of chatter going on back and forth between the client and server, and a lot of data to move across the wire—and speed is essential. After working with Ria Services for almost a year, I threw in the towel and picked up DevForce.
I really wish now that I had started with DevForce for several reasons:
One of my favorite features in DevForce is how it makes it really easy to do paging. By combining a DevForce component, a standard paging control and a data grid, you have everything you need to enable real time paging. For example, if you click on the header of the grid, the grid doesn’t merely sort the existing data in the grid; it actually triggers a sort order change event which triggers DevForce into calling a new query of the entities in the new sort order. So the first page is the first page of ALL the data, not just a simple resort of the existing data.
Further, once data has been brought down to the client, it is cached there. So if the user goes from Page 1 to page 2 and then back to page 1, the cached data is used instead of making another call to the server. No custom code is required to get this functionality; it’s baked right into DevForce.
The component that orchestrates the paging is called the EntityQueryPagedCollectionView.
To put it to use, you instantiate it like this:
C# | //A simple query which gets all email messages. var query = EmailEntityManager.vEmailMessageEntities; // The constructor takes the query, the page size and the load size. EntityQueryPagedCollectionView EmailMessages = new EntityQueryPagedCollectionView( query, 250, 250 ); //We now add a sort description which will determine the initial sort order. EmailMessages.SortDescriptions.Add(new SortDescription("SentOn", ListSortDirection.Descending)); |
I also want to know when the current email changes, so I add this event handler:
C# | EmailMessages.CurrentChanged += new EventHandler(EmailMessages_CurrentChanged); |
C# | <DataPager Source="{Binding EmailMessages}" /> |
C# | <DataGrid ItemsSource="{Binding vEmailMessages, Mode=TwoWay}" /> |
In practice, I don’t bring down the full entity to populate a grid. Instead, I create view in the database that contains just the columns that I want to display in the grid. I then create an entity based on the view. So I will have one entity called EmailMessageEntity and then another one based on the view called vEmailMessageEntity. The grid is then bound to the “slim” version. When the current email changes, I make a call up to the database and get the one full entity that I need and then display that. By having a slim entity, data access time is greatly sped up and the grid is very responsive to sort changes and paging.
There are many more DevForce features that I use, but this is one of my favorites.