how to create wrapper for Datablock in Enterprise library

Topics: Building and extending application blocks, Data Access Application Block, Enterprise Library Core, Exception Handling Application Block
Nov 23, 2010 at 10:19 AM



I have the following scenario.

We are creating layered architecture for creating WCF Service.

We have

1)Service Layer

2)Business layer


so from the Business layer we will be calling Dataacess layer but the requirement is we should not add any datablock code like

Database db=DatabaseFactory.CreateDatabase()

in Datalayer

Instead we need to write a wrapper as seperate project for Datablocks.

For example

Businesslayer will give an entity object to datalayer and datalayer will create command object and it should pass it to wrapper project.

how this can be done..any help.

The Datalayer should not refer any of those enterprise library dlls

Nov 24, 2010 at 1:36 AM

I'm not sure but is your question really about how to create a wrapper class?  Doing this only requires you to create public methods which will expose the methods you will use.  For example, if you need to use Database.ExecuteDataSet, the wrapper method would be something like:

public DataSet RetrieveSomeBusinessObject(string commandText)
            Database db = DatabaseFactory.CreateDatabase();
            DbCommand cmd = db.GetStoredProcCommand(commandText);
            return db.ExecuteDataSet(cmd);

I don't really see any EntLib specific concern on your question, you probably need to post it in other forums.


Sarah Urmeneta
Global Technologies & Solutions
Avanade, Inc.