Enterprise Library Data Access Application Block In C# .NET

Firstly, I will talk about Enterprise Library

What is Enterprise Library and how it work


Enterprise Library is a framework and it is an integration pack for all Microsoft products (C#, Azure, Sharepoint and more).

It provides all application recommended operations like Validations, Exception Handling, Logging, Data Transfer objects, etc.

I recommend it, If your application deals with any bulk data Insert, Select and Update. Good at performance wise also.

The following computer screens will guide you.

Step 1: Create empty website

empty website

Step 2: Add SQL Server database template to your application.

SQL Server database

Step 3: Add one Web Form or any sample page to your website.

Webform

Here I recommended you, a class that use expose DTO.

Step 4: Add one class to your website to develop Enterprise DAL and DTO (Data Transfer Objects).

class 

Next find connection string to your Database.mdf with help of the following screen,

connection string

The above screenshot sqlDataSource will help you to get connection string to your project database.mdf and later you can remove from your page.

connection

Find connection string and add it to your web.config file.

web.config

Next add DB stuff to your Testconnection Database Table and Procedures.

Testconnection

Table Design has been completed and next step is for Stored Procs.

Table Design

All necessary stuff has been made and now lets come into application and add packages.
// Required : Install-Package EnterpriseLibrary.Data

Install-Package

Required namespaces
  1. using Microsoft.Practices.EnterpriseLibrary.Data;  
  2. using Microsoft.Practices.EnterpriseLibrary.Common;  
  3. using Microsoft.Practices.EnterpriseLibrary;  
  4. using System;  
  5. using System.Collections.Generic;  
  6. using System.Linq;  
  7. using System.Web;  
  8. using System.Data.Sql;  
  9. using System.Data.SqlClient;  
  10. using Microsoft.Practices.EnterpriseLibrary.Data.Sql;  
  11. using System.Threading.Tasks;  
NameSpace

Above screenshot about Constructor logic, namespaces and below one is Insert operations using Enterprise Library.

Enterprise Library

Update Operations

Update Operations

Select Operations and Data Transfer objects to CollectData class

Select Operations

Your Home work :

Home

Call your functions with help of EnterpriseDAL.cs Object.

Code

 


Similar Articles