Yesterday I went to Microsoft's Pablo Castro's presentation about the next version of ADO.Net. This presentation covered LINQ (Language Integrated Query) and some new features like the Entity Data Model.

Many of you are probably familliar with LINQ, but every time I see it, I want to start using it right away. Unfortunately my company is a slow adopter, and we aren't even on 2005 yet :(

The Entity Data Model is seperate from LINQ, but works hand in hand with it to provide some very imperssive features.

Using some GUI designers (or presumably by manually editing some XML files), you can map from your logical table schema, to a real business schema.

Pablo's example used the AdventureWorks database, and remapped the Contacts, Person, and SalesPerson entities into one SalesPerson business entity. The tables are split up in the logical layer for normalization reasons, but from a business perspective, there is no reason to interact with it at that level.

You create the mapping between your tables and the entities, and then you can query the entity as if it were the table. Esentially making a view. However, the views are updateable, which is a nice touch. Also, The features allow you to abstract away data conventions. For example, in the same AdventureWorks database, There are Sales. However, there is a convention in the data that if the Tax is 0, then that was a StoreSale. When yuo select out the collection of Sales, you get some sales, and some StoreSales, automatically cast for you, based on the conventions you define in the mapping.

All of this is queried through Entity SQL, a new version of the SQL language that supports the additional features that the EDM platform provides.

A new “MAP” provider has been created that you run your connections and commands against, and this provider translates from Entity SQL to the native SQL your database requires. A nice side effect of this is true database agnostic access. Even if you just did a one to one table to entity mapping, you would still get the database abstarction, which is a great feature. All of this new functionality is exposed through a new IExtendedDataRecord interface, which is esentially a datareader, with the additional schema information that EDM provides.

The other big win for this is DataSet queries. You can treat your DataSet just like another data source for the mapping. The big benefit for this is that the same tools you use for true DB access you use for DataSet access, no new semantics or incompatible tools!

Of course, all of this works with LINQ as well, so you can get LINQ collection iteration etc, on your business entities, rather than your raw tables.

Also, your business entities are exposed as objects, which can be extended to add functionality. So you get all the benefits of an object layer on your data, for very little effort.

This is very exciting. Pablo says the bits for Entity Data Model should be available later this year, and I am really looking forward to it.