zoukankan      html  css  js  c++  java
  • Designing for Logical Naming of Databases

    The Data Access Application Block allows developers to refer to their target databases by using logical names; for example, "Customers" and "Inventory." The logical name is the single reference needed to access all the application block's functionality.数据访问应用块允许开发参考目标数据库通过使用逻辑名;如Customers Inventory 逻辑名是一个单独的引用,需要访问多个应用块的需要。

    Other than method calls, all other facets of database access are controlled externally, in the configuration file for the application. This allows the physical location of a database to be changed (for example, from a development to a test environment), quickly and without recompilation. Logical naming also allows developers to refer to multiple database instances in their code, even if they are of heterogeneous types.

    其它方法的调用,所有的其它的数据库访问的事实被严格的控制,在配制文件中对于每个应用。这个允许物理数据库的位置改变(如,从开发到测试环境),很快且不需要重新编译。逻辑命名也允许开发者引用多个数据库实例在他们的代码中,甚至在异构类型中。

    Design Implications

    Logical naming implies three things about the application block's design:在应用块的设计中逻辑名应用了三件事。

    ·                 The configuration settings for the application block support named instances. 对于应用块支持的命名实例的配制环境。

    ·                 There is API support for logical names. 逻辑命名的API支持。

    ·                 There is a dependency on the Configuration Application Block在配制应用块中有一种依赖性。.

    The next sections describe these implications.下面的章节中描述了三种含意。

    Design of the Configuration Settings配制环境的设计。

    To support named instances, the configuration settings must include database instances, database types, and connection strings that have the following characteristics:支持命名实例,配制环境必须包含数据库实例,数据库类型,表名其特征的连接串。

    ·                 A database instance has a name, such as Sales, a reference to a database type, such as SQL Server, and a connection string with a name, such as Connection String1.

    ·                 A database type represents the different database types that are on the system. These can be SQL Server, Oracle, DB2, or custom databases that you have developed.

    ·                 A connection string contains the information that is used to connect with the database when the database instance name is specified in the DatabaseFactory method call.

    ·                 一个数据库有一个名字,如Sales,数据库的类型,如 SQL Server 一个带有名字的连接串,如。。。

    API Support for Logical Names逻辑命名的API支持

    None of the Data Access Application Block methods accept connection string information. Instead, the CreateDatabase method accepts a string containing a logical name. The factory uses this logical name to locate the appropriate database-specific type and connection information within the configuration file. The following code shows how to give a database a logical name.

    没有数据访问块的方法接受连接串的信息,取代的是一个CreateDatabase方法接受逻辑名的串,这个工厂接受逻辑名定位合适的具体的数据库类型和连接串从配制文件中,下面的代码显示了如何得到一个逻辑名。

    [C#]

    Database db = DatabaseFactory.CreateDatabase("Customers");

    [Visual Basic]

    Dim db As Database = DatabaseFactory.CreateDatabase("Customers")

    Dependency on Configuration Application Block配制应用块的独立性。

    Because connection string information is in a configuration file, the Data Access Application Block must be able to read configuration information. As a result, the DatabaseFactory class requires the Configuration Application Block, using it to locate and read the necessary information from the configuration file.因为在配制文件中的连接信息,数据访问应用块必须能够读取配制信息,结果,DatabaseFactory类需要配制应用块,作用它定位和读取必要的信息从配制文件中。

  • 相关阅读:
    程序人生,编程思想
    CentOS Linux Jenkins安装、部署、更新
    Git常用命令
    U盘安装Mac OS X要点
    Shell执行*.sql
    WebStorm远程调试Node.js
    svn常用命令
    敏捷开发相关编辑思想(SOA、DDD、REST、CQRS)
    VisualVM远程监控Java
    centos搭建git服务
  • 原文地址:https://www.cnblogs.com/snowball/p/160020.html
Copyright © 2011-2022 走看看