Enterprise Library 3.0 DAAB Improvements To Date
by David Hayden
I can't help but get excited about the new features in Enterprise Library 3.0 as well as the new software factories put out by the Microsoft Patterns and Practices Team. This week I locked myself in my office and spent all my free time on the Web Client Software Factory and the new Composite Web Application Block and Page Flow Application Block. These are great tools to have in your toolbox and are overflowing with practices that can help improve your development.
Over the past few months I have been monitoring and playing with the new changes in Enterprise Library 3.0. The Data Access Application Block has a few cool changes and there may be more before EntLib 3.0 is released. Here are a list of DAAB improvements worth mentioning ( as of January 2007 CTP ).
Batch Update Functionality
The Database.UpdateDataSet Method now includes an overload that allows you to specify a batch update size:
Database.UpdateDataSet(DataSet dataSet, string tableName, DbCommand insertCommand, DbCommand updateCommand, DbCommand deleteCommand, UpdateBehavior updateBehavior, int? updateBatchSize);
TransactionScope Support
We now have support for System.Transactions and TransactionScope. The DAAB looks to see if a transaction is happening and caches open connections for re-use with other commands so a Distributed Transaction won't occur if using the same connection. Hence the following is now possible in Enterprise Library 3.0 without causing a Distributed Transaction:
using (TransactionScope scope = new TransactionScope(...)) { database.ExecuteNonQuery(...); database.ExecuteNonQuery(...); // .... scope.Complete(); }
SQL Server 2005 Compact Edition Support
A new class has been added to the DAAB specifically for SQL Server 2005 Compact Edition, called SqlCeDatabase. There is a CreateFile Method that uses the CreateDatabase method found in the SqlCeEngine Class as well as a TableExists Method that uses the INFORMATION_SCHEMA Classes to query for the existence of a table. In addition, it comes with a new connection pooling class to offer connection pooling services for SQL Server 2005 Compact Edition. Great Stuff:
bool tableExists = database.TableExists("Subscribers");
Conclusion
You can download the January 2007 CTP here to try out the changes for yourself.
Additional Resources
- Data Access Application Block Gets Batch Update Functionality in Enterprise Library 3.0
- TransactionScope and Enterprise Library 3.0 Data Access Application Block – System.Transactions
- Data Access Application Block Supports SQL Server Compact Edition with SqlCeDatabase Class – Enterprise Library 3.0 Tutorials
- Using Enterprise Library DAAB and Microsoft Access 2007 via ODBC and OLEDB – Connection Strings and ADO.NET
- Typed DataSets and Data Access Application Block ( DAAB ) – Enterprise Library Tutorials
by David Hayden