• 基于微软EnterpriseLib的框架(一)


    1、框架模型无ORM,重点在数据库建模设计与UI框架设计上

    2、多数据库支持(Enterprise Lib 默认仅支持SqlServer和Oracle,需自己扩展才能支持其他数据库,本文已扩展SQLite为例说明)


    项目截图

    Project

    Client—>DataProxy     通过WebService访问服务端数据服务

    Client—>UI    客户端UI

    Lib —> ZF.Data.SQLite 扩展Enterprise Lib支持SQLite

    DAL 各种数据库的数据访问层(Data Acess Layer)

    WebService 针对各个数据库的WebService

     

    重点看下ZF.Data.SQLite的写法及Web.Config 的配置

    2015-05-27_212216

    SQLiteDatabase.cs

    using Microsoft.Practices.EnterpriseLibrary.Data;
    using Microsoft.Practices.EnterpriseLibrary.Data.Configuration;
    using System;
    using System.Data.Common;
    using System.Data.SQLite;
    
    namespace ZF.Data.SQLite
    {
        [DatabaseAssembler(typeof(SQLiteDatabaseAssembler))]
        public class SQLiteDatabase : Database
        {
            private string connectionString;
            public SQLiteDatabase(string connectionString)
                : base(connectionString, SQLiteFactory.Instance)
            {
                this.connectionString = connectionString;
            }
            protected override void DeriveParameters(DbCommand discoveryCommand)
            {
                throw new Exception("The method or operation is not implemented.");
            }
        }
    }

    SQLiteDatabaseAssembler.cs

    using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;
    using Microsoft.Practices.EnterpriseLibrary.Data;
    using Microsoft.Practices.EnterpriseLibrary.Data.Configuration;
    using System;
    using System.Configuration;
    namespace ZF.Data.SQLite
    {
        public class SQLiteDatabaseAssembler : IDatabaseAssembler
        {
            public Database Assemble(string name, ConnectionStringSettings connectionStringSettings, IConfigurationSource configurationSource)
            {
                return new SQLiteDatabase(connectionStringSettings.ConnectionString);
            }
        }
    }

    web.config

    <?xml version="1.0"?>
    <configuration>
        <configSections>
            <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data"/>
        </configSections>
        <appSettings/>
        <dataConfiguration defaultDatabase="sqlite">
            <providerMappings>
                <add databaseType="ZF.Data.SQLite.SQLiteDatabase, ZF.Data.SQLite" name="System.Data.SQLite"/>
            </providerMappings>
        </dataConfiguration>
        <connectionStrings>
            <add name="sqlServer" providerName="System.Data.SqlClient" connectionString="Database=test_sql;Server=.;User ID=sa;Password=123456;"/>
            <add name="oracle" providerName="System.Data.OracleClient" connectionString="Data Source=test_orc;User ID=zf;Password=Zf123456"/>
            <add name="sqlite" providerName="System.Data.SQLite" connectionString="Data Source=C:	est_JM.db;Version=3;Password=123456"/>
        </connectionStrings>
        <system.web>
            <compilation debug="true"/>
            <authentication mode="Windows"/>
        </system.web>
    </configuration>

     

    例子下载

  • 相关阅读:
    php 生成带图片的二维码
    ajax 请求 添加正在加载中 遮罩层
    uedit上传图片时文件选择框延迟弹出的解决方法
    gulp基本用法
    JS引擎的执行机制
    前端知识体系
    css基础
    gulp使用入门
    AngularJS最佳实践
    Restful API 待更新。。。
  • 原文地址:https://www.cnblogs.com/Aphasia/p/4534443.html
Copyright © 2020-2023  润新知