With dozens of new products, enhancements and new features that we’re going to release in 2009 (per 2009 roadmap published in Developer Network), there are so many new topics to discuss related to Web and RIA development. It’s especially important to understand how these new products are working in concert and how each puzzle is connected to achieve highly extensible application.
I decided to cover these new products in several series of blog posts, so each product and new feature can be explained in details. In this first post, I’m going to write about Datasource controls for Silverlight 2.
Silverlight 2 is a great platform to build RIA applications. It’s not only limited to fancy media player or photo viewer, it’s also great for developing business applications.
Despite of its rich UI libraries such as support for animations and several built-in controls, it’s still considered difficult to develop real-world LoB applications with Silverlight 2, more specifically on the data retrieval and data binding part.
I bet that 99% of your data-aware Silverlight application would consist of dozens, if not, hundreds lines of codes. With current Silverlight 2 development model, you are required to manually write codes to connect to web service, handle the response, parsing and convert it into business logic. Not to mention the databinding on the UI controls.
In short, developing real-world LoB application in Silveright 2 without a streamlined data process is simply a tiring and tedious process.
How Intersoft’s Datasource controls come to rescue
To address these tough development challenges, we finally invent a new concept that streamline all data processes into component model, which exposes consistent interfaces to allow further extensibility and customizability.
Introducing Intersoft’s Datasource controls for Silveright 2, these datasource controls are designed based on declarative datasource control concept, which is first introduced in Visual Studio 2005 (ASP.NET 2.0).
The reasons why we chosen to develop our data controls strategy based on this model are:
– Clear separation between data/business object layer and UI layer. This concept greatly reduces the overhead in project’s maintenance, especially large-scale projects that are being worked by separate team of designers and developers.
– Easy to use and understand. By simply specifying values into the provided properties, using datasource control is far more easier and convenient. Bloated and complicated ORM providers are certainly off the list here.
The initial version that planned to ship in 2009 R1 milestone will include three datasource controls:
XmlDataSource is a read-only datasource control that enables you to easily bind a UI control given an Xml data file. It’s best to use this control if you have static xml files in your Silverlight project that you wish to display in your UI control.
Using this control is very straightforward, that is by simply providing the xml data file path and the descendants of path to be iterated.
<ISNet_Silverlight_DataSource:XmlDataSource DataFile=”Xml/Products.xml” Descendants=”//Product” />
WcfDataSource control enables you to bind UI controls based on datasource that is hosted on WCF (Windows Communication Foundation) service. WCF has been gaining wide popularity and adoption these days, as well as getting more converts from ASMX-based Web Service.
Intersoft’s WcfDataSource leverages full implementation of features available in WCF, such as concurrency and conflict options, caching, multiple services, and custom data contract.
WcfDataSource allows you to define one or more services in a single control. Each service is identified with ServiceName property, and can perform data selection, insert, update, and delete operation (CRUD). For greater flexibility, each service can also target different service host and different service target.
For instance, take a look at the following definition:
<ISNet_Silverlight_DataSource:WcfDataService ServiceHost=”http://northwind.com/dataservice_public” ServiceName=”CustomersService” ServiceTarget=”CustomersService.svc”>
- Service reference’s auto discovery.
WcfDataSource takes advantage of service references generated by Silverlight, so you don’t have to rewrite your classes and objects definition.
- Data paging and custom load-on-demand mechanism.
WcfDataSource includes sophisticated architecture that defines data paging and custom data loading interface. WcfDataSource can pass the required information (from the databound UI controls) to the given SelectMethod. WcfDataSource can pass either one of the following parameter signature:
- Strongly-typed object for insert, update and delete.
Instead of working with raw data, you can work against your strongly-typed object model directly for the insert, update and delete operation.For instance, your Update function in WCF service can use the following signature:
int UpdateCustomer(object primaryKeys, Customer newObj)
When an update operation occurred in the databound UI control, WcfDataSource will send the required data to the WCF service, which can be automatically deserialized into strongly-typed object when it arrived to the user-defined function/code.
- Event handlers available in WcfDataSourceView and WcfDataSource level.Often times, you need to manipulate the resulted data before it is bound to the UI controls. WcfDataSource provides various events where you can implement your custom business process, such as Selecting, Selected, Updating, Updated, and more.
WcfDataSource also provides designer with which you can easily define your services and its related properties. See the following screenshot for more details.
Well, now it’s the turn for the most interesting datasource control out of the three. If you have read my post about Silverlight five months ago, you should have recalled about the lacking of data binding in Silverlight which I described in the first point. Astoria, now known as ADO.NET Data Service, is the key answer to programmatic data access over the Web, making data automation possible in Silverlight. Astoria is officially released and included in Microsoft Visual Studio 2008 Service Pack 1.
I won’t be covering too much about Astoria here. If you would like to learn more about Astoria, please visit ADO.NET Data Services MSDN Home.
Intersoft’s AstoriaDataSource, as its name implies, is a datasource control that enables you to connect a databound UI controls (eg, Grid) to an Astoria data service.
AstoriaDataSource will serve as the key component and foundation to all Silverlight databound controls strategy that we’re going to release in the future. Here are the reasons why:
- Data automation from UI control layer.
When using AstoriaDataSource as the datasource control, our upcoming Silverlight databound controls will perform data operations automatically, such as data selecting, data paging, data transactions (Insert, Update, Delete) as well as data manipulations (sorting, filtering).
- Significantly less efforts on developer’s side.
Astoria is likely going to be the preferred solution for many .NET developers when it comes to Web data provider, as it requires very minimal efforts on the developer’s end to get it working and running. Compared to WCF which you are required to provide each function to handle each data operation, Astoria requires none.
All you need to do is to specify yourAstoria data service’s url in the AstoriaDataSource control, and it will take care the rest.
AstoriaDataSource has similar architecture and concepts with WcfDataService, such as multiple services, conflict detection, references auto discovery, and more.
With multiple services support, you can bind multiple UI controls to a single instance of AstoriaDataSource control, reducing the overhead to maintain a lot of objects as well as improving page load performance. Furthermore, it will enable more advanced data operations — such as nested view, hierarchical and value list/lookup — to be performed in elegant and consistent fashion.
The following example shows the syntax of AstoriaDataSource control, and notice how easy it is to expose your Astoria data service accessible in Silverlight with such declarative fashion.
<ISNet_Silverlight_DataSource:AstoriaDataSource x:Name=”AstoriaDataSource1″ ServiceHost=”http://localhost:50634″ ServiceTarget=”NorthwindDataService.svc” ReferenceNamespace=”NorthwindServiceReference” ServiceTypeName=”NorthwindEntities”>
<ISNet_Silverlight_DataSource:AstoriaDataService ServiceName=”Customers” DataObjectTypeName=”Customers”/>
<ISNet_Silverlight_DataSource:AstoriaDataService ServiceName=”Products” DataObjectTypeName=”Products”/>
<ISNet_Silverlight_DataSource:AstoriaDataService ServiceName=”Categories” DataObjectTypeName=”Categories”/>
<ISNet_Silverlight_DataSource:AstoriaDataService ServiceName=”Orders” DataObjectTypeName=”Orders”/>
At Intersoft, we enjoy creating new innovation that can help you build applications in less time with less efforts, saving you from having to write lengthy codes. These upcoming data source controls for Silverlight 2, as you’ve got the ideas, are created for that purpose.
I hope I’m not over exaggerated by saying that these new controls will slash your Silverlight development efforts by 90% or more. Just imagine that you don’t have to write even single line of codes for data retrieval and binding, as you can simply drop-in the datasource controls, set the properties. And that’s it!
In the next post, I’ll cover how these datasource controls work in concert with our upcoming databound controls for Silverlight 2. I can’t express how exciting this will be, so stay tuned on our blog site!
All the best,