- 增加 Where In 表达式解析;

- 增加 FreeSqlBuilder.UseConnectionFactory 自定义数据库连接对象的创建方法;
This commit is contained in:
28810
2019-12-17 01:39:53 +08:00
parent 51494c31a2
commit e1e3e4a3b2
57 changed files with 1018 additions and 492 deletions

View File

@ -13,9 +13,14 @@ namespace FreeSql.Odbc.Default
class OdbcAdo : FreeSql.Internal.CommonProvider.AdoProvider
{
public OdbcAdo() : base(DataType.Odbc) { }
public OdbcAdo(CommonUtils util, string masterConnectionString, string[] slaveConnectionStrings) : base(DataType.Odbc)
public OdbcAdo(CommonUtils util, string masterConnectionString, string[] slaveConnectionStrings, Func<DbConnection> connectionFactory) : base(DataType.Odbc)
{
base._util = util;
if (connectionFactory != null)
{
MasterPool = new FreeSql.Internal.CommonProvider.DbConnectionPool(DataType.Odbc, connectionFactory);
return;
}
if (!string.IsNullOrEmpty(masterConnectionString))
MasterPool = new OdbcConnectionPool("主库", masterConnectionString, null, null);
if (slaveConnectionStrings != null)
@ -60,9 +65,11 @@ namespace FreeSql.Odbc.Default
return new OdbcCommand();
}
protected override void ReturnConnection(ObjectPool<DbConnection> pool, Object<DbConnection> conn, Exception ex)
protected override void ReturnConnection(IObjectPool<DbConnection> pool, Object<DbConnection> conn, Exception ex)
{
(pool as OdbcConnectionPool).Return(conn, ex);
var rawPool = pool as OdbcConnectionPool;
if (rawPool != null) rawPool.Return(conn, ex);
else pool.Return(conn);
}
protected override DbParameter[] GetDbParamtersByObject(string sql, object obj) => _util.GetDbParamtersByObject(sql, obj);

View File

@ -5,6 +5,7 @@ using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Linq;
using System.Threading;
@ -37,12 +38,12 @@ namespace FreeSql.Odbc.Default
/// <param name="masterConnectionString"></param>
/// <param name="slaveConnectionString"></param>
/// <param name="adapter">适配器</param>
public OdbcProvider(string masterConnectionString, string[] slaveConnectionString)
public OdbcProvider(string masterConnectionString, string[] slaveConnectionString, Func<DbConnection> connectionFactory = null)
{
this.InternalCommonUtils = new OdbcUtils(this);
this.InternalCommonExpression = new OdbcExpression(this.InternalCommonUtils);
this.Ado = new OdbcAdo(this.InternalCommonUtils, masterConnectionString, slaveConnectionString);
this.Ado = new OdbcAdo(this.InternalCommonUtils, masterConnectionString, slaveConnectionString, connectionFactory);
this.Aop = new AopProvider();
this.CodeFirst = new OdbcCodeFirst(this, this.InternalCommonUtils, this.InternalCommonExpression);