Dofactory.com
Dofactory.com
 Back to list
Views:   4.6K
Replies:  0
Archived

DAO desing pattern ?

I am still using 4.0 design pattern of DAO.
Now i am trying to create a scenario where as i could call different Data Access object based on my choice and not on data provider.
Like as per Pattern in Action (below), once i set ADO.NET.SqlExpress as provider then it will only access data access object of SqlExpress folder for entire project.
Where as i am trying to do that for some object i could get into Oracle as well as for some into SqlExpress and for few i could get into EntityFramework.

How to make that flexiable so that i can handle all and not depend on only ONE dataprovider?
Like ICustomerDao could be in SqlExpress and IOrderDao Could be in Oracle.

Is it possible? How to design?



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(); 
            }
        }
    }

 
Abhishek Ranjan, May 30, 2014
Stay Inspired!
Join other developers and designers who have already signed up for our mailing list.
Terms     Privacy     Cookies       Do Not Sell       Licensing      
Made with    in Austin, Texas.  - vsn 44.0.0
© Data & Object Factory, LLC.