Introducing Versatile DataSources

I have been working on enhancements to ASP.NET Dynamic Data since Feb 2008. There have been plenty of gaps between its technology and what the web form developer wants in their finished site. This is in part because Dynamic Data is more narrowly focused on aspects of data entry web forms than I am as a web control developer.

Over the summer, I identified one of those gaps as a lack of DataSource controls to handle several common cases. A DataSource control is a conduit between the actual data and a DataBound control like GridView or FormView. It delivers data from a query and returns data to be saved.

Microsoft has released numerous DataSource controls, like SqlDataSource, LinqDataSource, and EntityDataSource. Yet all have shortcomings. Some don’t handle Dynamic Data. Most demand the web form developer write business logic. Most are specific to a technology (LinqDataSource for LINQ to SQL, EntityDataSource for Entity Framework, etc.) None handle data from POCO classes that is not CRUD (“create, read, update, delete”) oriented.

Microsoft is attempting to remedy this with two new technologies.

  • DomainDataSource – In RIAServices. Places the business logic in the Domain objects. Supports multiple technologies.
  • EnableDynamicData() – A method introduced in Dynamic Data 4.0 to allow using a POCO class.

I have endeavored to do better, and the result is Versatile DataSources. It’s free and available on CodePlex, complete with extensive documentation, examples, and source code. Before talking about its features, let me ask the community for your feedback. I want to know how important this is to you. Please take a moment to review these features.

Versatile DataSources contains two DataSource controls. EntityDAODataSource improves upon the ideas behind the DomainDataSource. POCODataSource lets you work with POCO classes. Both support Dynamic Data and establish a strong separation of concerns between UI and business logic.

These DataSources encourage building business logic classes and establish a strong separation of concerns between user interface development and business logic. With Dynamic Data added, you get an outstanding webcontrols generator that follows the attributes you have established on your business logic classes.

EntityDAODataSource Features

  • For use with Data Access Objects ("DAO") that handle the CRUD ("create, read, update, delete") actions. Starter DAO classes are supplied for ADO.NET, LINQ to SQL, and ADO.NET Entity Framework. They already predefine the following methods: Update, Insert, Delete, SelectAll, SelectOne (by primary key), and Select (query by the filtering properties on the EntityDAODataSource). Your existing DAO classes can be used as well.
  • Defines strong separation of concerns between user interface and business logic, letting the business logic dictate everything possible. The web control developer only identifies the Entity class, Select method, and the Select method parameters. (Even the Select method and its parameters are optional as in many cases EntityDAODataSource can figure them out.)
  • Supports Dynamic Data. Introduces ADO.NET support to Dynamic Data.
  • Provides a mechanism for paging, sorting, filtering, and caching, which is delegated to the Select methods on the DAO classes. The supplied DAO classes already implement all of these capabilities.
  • Select methods are simpler to setup. They are always passed the SelectArgs object which passes in paging, sorting, filtering, and caching information. Select methods only need to create their query, consuming the sorting and filtering data. Then pass both the query and the SelectArgs object to the ExecuteSelectCommand for execution where paging and caching are applied.
  • Supports the DynamicFilter and QueryableFilterRepeater controls without using the QueryExtender control.
  • Supports Dynamic Data’s Url Routing to determine the table, action (read, edit, insert), and record. You don’t have to setup any Parameter objects in SelectParameters or WhereParameters properties.
  • Supports Associations (relationships) defined by Dynamic Data and used by Url Routing.
  • Provides design mode support, including a Configure command and editors for its SelectParameters, WhereParameters, and FilterExpressions properties.

POCODataSource Features

  • For any data entry form that takes an action based on the data input.
  • For use with the POCO class intended to run an action. Eliminates the middle step of transferring data from an intermediate form to the final object by handling two way databinding directly with the POCO instance.
  • Populates the properties of objects automatically. You can just invoke their “action method”.
  • Supports Dynamic Data. Apply the attributes of System.ComponentModel.DataAnnotations to your POCO class and let Dynamic Data construct a matching user interface complete with validation. Allows separation of concerns design where the business logic dictates how to build the user interface.
  • Very simple setup. Either assign the POCO class type to the POCOTypeName property or use the CreatePOCOInstance event to return an instance of the object.
  • Provides design mode support

3 Comments

Comments have been disabled for this content.