Farseer.net Lightweight Open Source Framework intermediate article: Database switching

Source: Internet
Author: User

Navigation

Catalog: Farseer.net Lightweight Open source Framework Catalog

Previous: Farseer.net lightweight open Source Framework Intermediate article: Dynamic database access

Filed under: Farseer.net Lightweight Open source Framework intermediate: SQL Execution Report

As described above, how to dynamically change the access of a database through code in the course of a project is more inclined to have the same entity class with multiple identical table structures.

This article describes how to quickly switch between different databases. For example, when you use SQL Server, which day database boss whim, let you switch to Oracle, what to do?

This kind of database switching in ORM can obviously highlight the advantages. Of course, it is also a bit far-fetched, the circumstances of this change is not a lot of opportunities. Just a few in the process of running a project, it is very common to need a variable database because the original database cannot meet the current demand.

If you use the Farseer framework, first thank you for your support of farseer.net. And you're lucky, because you don't have to change the code (compile) to do the task at all, you can switch to another database.

At the beginning of the farseer.net design, it was to let developers forget the concept of the database, that is, to forget the database, that is, no matter what kind of database you use, you do not need to care about the difference between the different database operations.

Now let's take a look at how to switch the database, in the project: ~/app_data/db.config is the database type configured. The use of Dbconfigs was also specifically described in the last two articles. Of course, you can also use the configuration of multiple databases in your project to support simultaneous access to different databases.

Say so much or put the code on it:

1 <?XML version= "1.0"?>2 <DbconfigXmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"xmlns:xsd= "Http://www.w3.org/2001/XMLSchema">3   <dblist>4     <DbInfo>5       <Server>.</Server>6       <UserID>Sa</UserID>7       <PassWord>123456</PassWord>8       <DataType>Sql server</DataType>9       <Dataver>2005</Dataver>Ten       <Catalog>Farseer</Catalog> One       <poolminsize>16</poolminsize> A       <poolmaxsize>100</poolmaxsize> -       <ConnectTimeout>30</ConnectTimeout> -       <CommandTimeout>60</CommandTimeout> the     </DbInfo> -   </dblist> - </Dbconfig>

DataType: Is the configuration database type, the currently supported database type, see in the custom configuration file .

Dataver: Configuration database version, described here, because of different versions, the resulting SQL is different. This is supported by the new features brought by the high version.

Here we talk about this, in fact, nothing special, the special opening to explain is worried that we will be confused.

Navigation

Catalog: Farseer.net Lightweight Open source Framework Catalog

Previous: Farseer.net lightweight open Source Framework Intermediate article: Dynamic database access

Filed under: Farseer.net Lightweight Open source Framework intermediate: SQL Execution Report

Advertising time

QQ Group:116228666 (farseer.net Open source frame exchange) Please specify: Blog Park

Farseer.net is an ORM framework + Common tool + extension collection.

Farseer: Prophets and seers usually offer tricks and strategies in certain situations. Also hope that the framework can provide you with maximum convenience.

ORM: The English name is:object relational(relationship) Mapping(map)

Farseer.net's goal is: Quick start, rapid development, simple and convenient.

1 New 1 " Zhang San " }. Insert ()

Farseer.net Lightweight Open Source Framework intermediate article: Database switching

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.