The introduction of design patterns in real business applications Abstract Factory mode for encapsulation of database access Components

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.