The introduction of design patterns in real business applications Abstract Factory mode for encapsulation of database access Components
Common database access Components built on C #
The common database access component based on C #, fully supports the open and close principle, designed to support the extensible support of any major database, the current component only implemented Oracle, MS SQL, MySQL three libraries.
The component implementation is simple, the structure is clear, the present component only includes 5 class files, is compatible with three kinds of databases, the component implementation adopts the Singleton mode, the Factory mode.
Get component Source code Please enter QQ group 706224870, download in the group file. Incoming group verification information: CODEFC
Below is a brief description of the implementation of the idea:
5 classes of files are as follows: DBFactorySingleton.cs, AbstractDBFactory.cs, OracleClientDBFactory.cs, MSSqlServerDBFactory.cs, MySqlDBFactory.cs
1. dbfactorysingleton file using a single-instance mode management component access to the establishment of the factory
2. abstractdbfactory file uses abstract class to describe the corresponding methods of components and some common application methods compatible with multiple databases
3. oracleclientdbfactory file realizes abstractdbfactory function, specially for processing Oracle database
4, Mssqlserverdbfactory file to implement the Abstractdbfactory function, specifically for processing MSSQLSERVER database
5. mysqldbfactory file realizes abstractdbfactory function, specially for processing MySQL database
The following is the structure diagram of the component:
Dbfactorysingleton File Part Content
Abstractdbfactory File Part Content
Oracleclientdbfactory File Part Content
Mssqlserverdbfactory File Part Content
Mysqldbfactory File Part Content
The introduction of design patterns in real business applications Abstract Factory mode for encapsulation of database access Components