The application and development of Enterprise Library based on the database of domestic dream

Source: Internet
Author: User
Tags sqlite database import database

In the previous article, "Enterprise Library-based WinForm development framework to support the expansion of the dream database in China," describes how to support the Enterprise Library data Access layer of the mysterious domestic database-the Dream database. This paper continues this topic and introduces the application and development of Enterprise Library in the database of dream production. 1, the Dream Database restore processing

Dameng database management System is a high-performance database management system with complete independent intellectual property rights, referred to as DM. The latest version of the Dameng database management system is version 7.0, referred to as DM7. DM7 provides feature support for SQL92 and core-level support for SQL99, and supports a variety of database development interfaces, including Ole DB, ADO, ODBC, OCI, JDBC, Hibernate, PHP, PDO, DB Express, and. Net Dataprovider and so on.

Dameng database can download the trial on (http://www.dameng.com/), the installation of a lot of management tools, after installation can let it create some instance database, so as to facilitate our understanding of the basic operation of the database.

After the Dameng database is installed, there are some administrative tools and PDF file links in the System Start menu, as shown below. There is time to recommend reading the user manual in a few files, the document is written in a very detailed, covering the database management operations, database programming development, database syntax parts of the content.

In the framework of WinForm development, a backup file (winframwork.dmp) of the Databasedx database is provided in the framework source directory, which contains the tables and data required by the framework, and the database can be restored (imported) before the framework is used. The operation method is in the "DM management Tool" interface, the left of the pattern tree right-click on the "Import" function, and then select the Import database operation, the interface is as follows.

After clicking the "Import" function, on the popup screen, select the corresponding directory and database backup file, and enter the required mode name, the interface operation is as follows.

After you restore (import) The Dream database and refresh the schema tree list, you will see information about the newly imported database in the mode on the left.

2. Expansion and integration of development and application

Based on the Enterprise Library Development Framework, the underlying use of Microsoft's data Access Components Enterprise Library to adapt to the operation of a variety of database types, its hierarchy is as follows, each DAL layer (such as Dalsql, Daloracle, etc.) all provide the implementation of the corresponding database, the interface layer below the hierarchical diagram as shown below.

If more than one database is added, we add one more component extension class for the Enterprise Library and add the corresponding DAL layer to the Business data module.

Enterprise Library to implement other database support, need to add a component extension class, such as EntLibContrib.Data.SQLite is used to support the SQLite database, ENTLIBCONTRIB.DATA.MYSQL is used to support MySQL, the content of this extension class is not many, mainly used to parse enterprise The configuration content of the library extension.

3. Extended Supported configuration parameters

In the development framework of the startup program or the Web. config configuration file inside the WCF service, we see the following configuration information.

In the configuration file, I added 1, 2, 3 steps, step 1 refers to the Dream database connection string, this is based on the Enterprise Library connection parameters content, because the Enterprise Library by default does not support the Dream database, is supported by its extension module EntLibContrib.Data.Dm, so it is necessary to specify the specific extension object and assembly information in step 2 , and finally, in order to know the specific database type in the framework, in section 3 Step adds a Componentdbtype configuration information to determine which database type (because the framework supports multiple databases, requires explicit typing, and facilitates the construction of different syntax for query statements).

Last mention is the 3rd step inside the Dm_schema is the database configuration parameters, because the dream database needs to specify the specific table of the schema prefix. Given this parameter, we can use the "schema" name of this configuration in the table name of the database module, as we can use this in the DALDM data access layer. The property of the schema, the value of which is obtained through the Dm_schema configuration above.

Of course, we're already in the data access layer, The database schema prefix (equivalent to schema.tablename) is added for TableName, and if This.tablename is used in the DALDM layer, it already contains a prefix for the database schema, so it does not need to be displayed when using TableName. The value of the Add mode, which is exactly the correct use as shown below.

That is, if you use the This.tablename parameter, then the current table does not need to increase the schema prefix, otherwise the table name is incremented This.schema this property prefix. 4, how to develop support to the Dream database application

Because this article mainly introduces how to integrate the Dream database and develop the business application based on the Dream database, this paper will focus on how to build the framework code based on this database.

Because the entire Enterprise Library development framework, in the business layer and the UI layer, is not involved in the specific database processing, so these features so that it can provide a good multi-database support, we based on this principle, generally do not break this Convention, Do not use specific database SQL at the UI layer or the BLL layer.

In order to quickly develop the framework code, there are two ways to quickly generate data access layer code, one is based on the other database access layer replication and modification processing, the other is a new data access layer generation. The former is in the case that other data access layers have been completed, can be quickly copied and modified. The latter is the start of the incremental development business, which generates code based on the DATABASE2SHARP support of the Code generation tool. 1) Replication processing based on other database access tiers

Because of different database support, is to create different data access layer, such as the data access layer of the Dream database, generally DALDM, as shown in the dictionary module of the data Access layer code.

Above we see that Dameng The data access layer of the database its namespace is WHC.Dictionary.DALDm such a format, the previous part of the primary namespace, the latter part of the Convention is basically the name DALDM, and this Dicttype data access class base class This is the data access base class that inherits the Dream database BASEDALDM, this The practice is similar to other databases.

We see that this content is basically the same as SQL Server's data access layer, and SQL Server's data Access layer code is shown below.

In contrast we can see that they are basically the same, if we have developed a data type implementation based on another kind of data access layer of code development, we can do this quickly to implement code replication, modification.

(1) in VS, hold down the CTRL key and drag with the mouse to copy a copy and modify the directory to DALDM.

(2) in VS, close all the code windows and open all copies of the generated files.

(3) Replace Dalsql with DALDM, so that each class replaces two times, implementing a uniform substitution of namespaces and base class names.

(4) Adjust the reference relationship of other layers to daldm.

Recompile the code. 2) New data access layer generation

This way of code generation, need to be in the Code generation tool, select Enterprise Library schema generation, generated code to copy them to the corresponding directory, and adjust the relevant reference relationship.

Refer to the Code generation tool DATABASE2SHARP instructions.

The application and development of Enterprise Library based on the database of domestic dream

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.