Design pattern to handle multiple databases via data access layer

c#-5.0data-access-layerdesign-patterns

I have been studying design pattern of "Gang of four design pattern".

I need to design data layer to handle multiple database as well as extend the function if required. The database could one is SQL, one XMl or some external system database.

What would be good design pattern to follow?

Edit:
Based on suggestion, i tried to implement DAO and Factory pattern in Data layer. To an extent i could get to the point.
But As per GOF desgin pattern, The data provider name decided which database object i can call.
Like below. Where as i am trying to make the layer dynamic so that multiple database can handled. If i follow below pattern then i can only access one database in one application.

If somebody has looked into Gang of Four Design pattern then Please guide me.

public class DaoFactories
{
    public static IDaoFactory GetFactory(string dataProvider)
    {
        // Return the requested DaoFactory
        switch (dataProvider)
        {
            case "ADO.NET.Access": return new AdoNet.Access.AccessDaoFactory();
            case "ADO.NET.Oracle": return new AdoNet.Oracle.OracleDaoFactory();

            case "ADO.NET.SqlExpress":
            case "ADO.NET.SqlServer": return new AdoNet.SqlServer.SqlServerDaoFactory();

            case "LinqToSql.SqlExpress": 
            case "LinqToSql.SqlServer": return new LinqToSql.Implementation.LinqDaoFactory();

            case "EntityFramework.SqlExpress": 
            case "EntityFramework.SqlServer": return new EntityFramework.Implementation.EntityDaoFactory();

            // Default: SqlExpress
            default: return new AdoNet.SqlServer.SqlServerDaoFactory(); 
        }
    }
}

Best Answer

You should look into the Repository Pattern and Data Access Object Pattern

Repository Pattern: In many applications, the business logic accesses data from data stores such as databases, SharePoint lists, or Web services. Directly accessing the data can result in the following: Duplicated code A higher potential for programming errors Weak typing of the business data Difficulty in centralizing data-related policies such as caching An inability to easily test the business logic in isolation from external dependencies

Data Access Object: In computer software, a data access object (DAO) is an object that provides an abstract interface to some type of database or other persistence mechanism. By mapping application calls to the persistence layer, DAO provide some specific data operations without exposing details of the database.

Related Topic