Browse DevX
Sign up for e-mail newsletters from DevX


Data Access with Microsoft Application Blocks

Microsoft has created a set of libraries known as Application Blocks which help developers reduce the amount of code they must write—while using current best practices. One of the components, Data Access Application Block for .NET, addresses Microsoft SQL Server data access by wrapping up data access into a helper class.




Building the Right Environment to Support AI, Machine Learning and Deep Learning

icrosoft recently launched the Microsoft Patterns and Practices section of their Web site, offering several complete architectural and design application blocks, complete with source code, that you can use in your .NET applications.

When Microsoft introduced .NET, they introduced a new data access architecture called ADO.NET. This new data access architecture is the next evolution from COM-based ADO. ADO.NET provides a lot of new features for accessing data such as datasets, which are essentially an in-memory database, and data adapters that allow different data providers to interact with a DataSet. This model allows datasets to be completely data provider-independent giving you the option of changing the data provider used to fill a DataSet and update data from a DataSet. You can even use multiple data providers with a single DataSet—fancy that! Of course you will find some classes such as a Connection class, Parameter class, and Command class that perform the same basic function as their ADO predecessor. With ADO.NET's new features and enhancements, of course, comes extra complexity when you write your data access code; you never had to deal with a data adapter in the past. Wouldn't you like someone to encapsulate all that complexity into a series of classes and methods to handle 95% of your data access logic needs? You're in luck.

Microsoft has introduced the Patterns & Practices Web site, which contains Microsoft's suggested practices and design patterns guidelines for designing, developing, deploying, and managing the life cycle of software solutions. The Patterns & Practices Web site contains the following four types of methods for sharing these guidelines: (design) Patterns, Reference Architectures, Reference Building Blocks and IT Services, and Lifecycle Practices. Together these guidelines provide far better guidance for developing strong solutions compared to simple white papers or books alone.

The Reference Building Blocks and IT Services guidelines provide designs and components for building reusable sub-systems in your software solutions. The components of this guideline are referred to as Application Blocks. Table 1 lists the eleven Application Block components that were available at the time this article was written.

Table 1: Current Application Block components available at the time this article was written.

Application Block


Aggregation Application Block

This Application Block contains a component that sends requests to a series of dispatchers to return data from various service providers in a single data entity such as a dataset or XML document.

Asynchronous Invocation Application Block

This Application Block manages asynchronous communication between an application and service providers.

Authorization and Profile Application Block

This Application Block gives you the ability to manage role-based authorization and profile information in your applications.

Caching Application Block

This Application Block provides an infrastructure to cache data from service providers such as a Web service or database.

Configuration Management Application Block

This Application Block provides a simple and consistent interface for reading and writing application configuration data.

Data Access Application Block

This Application Block contains a component that has functionality to simplify the most common methods for accessing Microsoft SQL Server database servers via the .NET SqlClient class.

Exception Management Application Block

This Application Block provides a framework for logging exception information and publishing to the event log, or you can create your own custom publisher.

Logging Application Block

This Application Block uses the Enterprise Instrumentation Framework (EIF) to assist in the development of instrumented applications.

Smart Client Offline Application Block

This Application Block provides an infrastructure to develop applications with offline capabilities.

Updater Application Block

This Application Block helps you recognize, validate, and download updated application files from a central location.

User Interface Process Application Block

This Application Block provides a series of components that assist the developer in creating UI process components.

One of the Reference Building Blocks that the Microsoft Practices & Patterns team has introduced is a data access helper framework called the Data Access Application Block for .NET. This data access helper framework provides a series of static methods for simplifying CRUD (Create, Read, Update, and Delete) operations. It contains two main classes: the SqlHelper class, and the SqlHelperParameterCache class. The SqlHelper class provides for simplified data access to a SQL server database and the SqlHelperParameterCache class caches SqlParameters for a given command as well as connection so that you can reuse them at any given time. Together these classes encapsulate the code you will need to perform most of your routine data access logic.

Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date