1、框架模型无ORM,重点在数据库建模设计与UI框架设计上
2、多数据库支持(Enterprise Lib 默认仅支持SqlServer和Oracle,需自己扩展才能支持其他数据库,本文已扩展SQLite为例说明)
项目截图
Client—>DataProxy 通过WebService访问服务端数据服务
Client—>UI 客户端UI
Lib —> ZF.Data.SQLite 扩展Enterprise Lib支持SQLite
DAL 各种数据库的数据访问层(Data Acess Layer)
WebService 针对各个数据库的WebService
重点看下ZF.Data.SQLite的写法及Web.Config 的配置
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>
例子下载