mirror of
https://github.com/dotnetcore/FreeSql.git
synced 2026-02-18 14:20:55 +08:00
TDengine增加单元测试
This commit is contained in:
@@ -1,18 +1,15 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using FreeSql.Internal;
|
||||
using FreeSql.Internal;
|
||||
using FreeSql.Internal.CommonProvider;
|
||||
using FreeSql.Internal.Model;
|
||||
using FreeSql.Internal.ObjectPool;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Data.Common;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using TDengine.Data.Client;
|
||||
|
||||
namespace FreeSql.Provider.TDengine.TDengineAdo
|
||||
namespace FreeSql.TDengine
|
||||
{
|
||||
internal class TDengineAdo : AdoProvider
|
||||
{
|
||||
@@ -32,15 +29,19 @@ namespace FreeSql.Provider.TDengine.TDengineAdo
|
||||
var isAdoPool = masterConnectionString?.StartsWith("AdoConnectionPool,") ?? false;
|
||||
if (isAdoPool) masterConnectionString = masterConnectionString.Substring("AdoConnectionPool,".Length);
|
||||
if (!string.IsNullOrEmpty(masterConnectionString))
|
||||
MasterPool = isAdoPool ?
|
||||
new DbConnectionStringPool(base.DataType, CoreStrings.S_MasterDatabase, () => new TDengineConnection(masterConnectionString)) as IObjectPool<DbConnection> :
|
||||
new TDengineConnectionPool(CoreStrings.S_MasterDatabase, masterConnectionString, null, null);
|
||||
MasterPool = isAdoPool
|
||||
? new DbConnectionStringPool(base.DataType, CoreStrings.S_MasterDatabase,
|
||||
() => new TDengineConnection(masterConnectionString)) as IObjectPool<DbConnection>
|
||||
: new TDengineConnectionPool(CoreStrings.S_MasterDatabase, masterConnectionString, null, null);
|
||||
|
||||
slaveConnectionStrings?.ToList().ForEach(slaveConnectionString =>
|
||||
{
|
||||
var slavePool = isAdoPool ?
|
||||
new DbConnectionStringPool(base.DataType, $"{CoreStrings.S_SlaveDatabase}{SlavePools.Count + 1}", () => new TDengineConnection(slaveConnectionString)) as IObjectPool<DbConnection> :
|
||||
new TDengineConnectionPool($"{CoreStrings.S_SlaveDatabase}{SlavePools.Count + 1}", slaveConnectionString, () => Interlocked.Decrement(ref slaveUnavailables), () => Interlocked.Increment(ref slaveUnavailables));
|
||||
var slavePool = isAdoPool
|
||||
? new DbConnectionStringPool(base.DataType, $"{CoreStrings.S_SlaveDatabase}{SlavePools.Count + 1}",
|
||||
() => new TDengineConnection(slaveConnectionString)) as IObjectPool<DbConnection>
|
||||
: new TDengineConnectionPool($"{CoreStrings.S_SlaveDatabase}{SlavePools.Count + 1}",
|
||||
slaveConnectionString, () => Interlocked.Decrement(ref slaveUnavailables),
|
||||
() => Interlocked.Increment(ref slaveUnavailables));
|
||||
SlavePools.Add(slavePool);
|
||||
});
|
||||
}
|
||||
@@ -96,7 +97,8 @@ namespace FreeSql.Provider.TDengine.TDengineAdo
|
||||
return new TDengineCommand();
|
||||
}
|
||||
|
||||
public override DbParameter[] GetDbParamtersByObject(string sql, object obj) => _util.GetDbParamtersByObject(sql, obj);
|
||||
public override DbParameter[] GetDbParamtersByObject(string sql, object obj) =>
|
||||
_util.GetDbParamtersByObject(sql, obj);
|
||||
|
||||
public override void ReturnConnection(IObjectPool<DbConnection> pool, Object<DbConnection> conn, Exception ex)
|
||||
{
|
||||
|
||||
@@ -1,16 +1,13 @@
|
||||
using System;
|
||||
using FreeSql.Internal.ObjectPool;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using FreeSql.Internal.ObjectPool;
|
||||
using TDengine.Data.Client;
|
||||
|
||||
namespace FreeSql.Provider.TDengine.TDengineAdo
|
||||
namespace FreeSql.TDengine
|
||||
{
|
||||
internal class TDengineConnectionPool : ObjectPool<DbConnection>
|
||||
{
|
||||
@@ -18,7 +15,6 @@ namespace FreeSql.Provider.TDengine.TDengineAdo
|
||||
|
||||
internal Action UnavailableHandler;
|
||||
|
||||
|
||||
public TDengineConnectionPool(string name, string connectionString, Action availableHandler,
|
||||
Action unavailableHandler) : base(null)
|
||||
{
|
||||
@@ -111,7 +107,6 @@ namespace FreeSql.Provider.TDengine.TDengineAdo
|
||||
|
||||
public void OnGetTimeout()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void OnGet(Object<DbConnection> obj)
|
||||
@@ -120,13 +115,14 @@ namespace FreeSql.Provider.TDengine.TDengineAdo
|
||||
{
|
||||
if (obj.Value == null)
|
||||
{
|
||||
InternalPool.SetUnavailable(new Exception(CoreStrings.S_ConnectionStringError), obj.LastGetTimeCopy);
|
||||
InternalPool.SetUnavailable(new Exception(CoreStrings.S_ConnectionStringError),
|
||||
obj.LastGetTimeCopy);
|
||||
throw new Exception(CoreStrings.S_ConnectionStringError_Check(this.Name));
|
||||
}
|
||||
|
||||
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && obj.Value.Ping() == false)
|
||||
if (obj.Value.State != ConnectionState.Open ||
|
||||
DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && obj.Value.Ping() == false)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
obj.Value.Open();
|
||||
@@ -149,13 +145,15 @@ namespace FreeSql.Provider.TDengine.TDengineAdo
|
||||
{
|
||||
if (obj.Value == null)
|
||||
{
|
||||
InternalPool.SetUnavailable(new Exception(CoreStrings.S_ConnectionStringError), obj.LastGetTimeCopy);
|
||||
InternalPool.SetUnavailable(new Exception(CoreStrings.S_ConnectionStringError),
|
||||
obj.LastGetTimeCopy);
|
||||
throw new Exception(CoreStrings.S_ConnectionStringError_Check(this.Name));
|
||||
}
|
||||
|
||||
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && (await obj.Value.PingAsync()) == false)
|
||||
if (obj.Value.State != ConnectionState.Open ||
|
||||
DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 &&
|
||||
(await obj.Value.PingAsync()) == false)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
await obj.Value.OpenAsync();
|
||||
|
||||
@@ -1,18 +1,14 @@
|
||||
using FreeSql.Internal;
|
||||
using FreeSql.Internal.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FreeSql.Provider.TDengine
|
||||
namespace FreeSql.TDengine
|
||||
{
|
||||
internal class TDengineCodeFirst : Internal.CommonProvider.CodeFirstProvider
|
||||
{
|
||||
public TDengineCodeFirst(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression) : base(orm, commonUtils, commonExpression)
|
||||
public TDengineCodeFirst(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression) : base(orm,
|
||||
commonUtils, commonExpression)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override DbInfoResult GetDbInfo(Type type)
|
||||
@@ -25,4 +21,4 @@ namespace FreeSql.Provider.TDengine
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using FreeSql.DatabaseModel;
|
||||
|
||||
namespace FreeSql.Provider.TDengine
|
||||
namespace FreeSql.TDengine
|
||||
{
|
||||
public class TDengineDbFirst : IDbFirst
|
||||
{
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FreeSql.Internal;
|
||||
using System;
|
||||
using System.Linq.Expressions;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using FreeSql.Internal;
|
||||
|
||||
namespace FreeSql.Provider.TDengine
|
||||
namespace FreeSql.TDengine
|
||||
{
|
||||
internal class TDengineExpression : CommonExpression
|
||||
{
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using FreeSql.Internal.CommonProvider;
|
||||
using FreeSql.Internal.CommonProvider;
|
||||
using System;
|
||||
using System.Data.Common;
|
||||
|
||||
namespace FreeSql.Provider.TDengine
|
||||
namespace FreeSql.TDengine
|
||||
{
|
||||
internal class TDengineProvider<TMark> : BaseDbProvider, IFreeSql<TMark>
|
||||
{
|
||||
public TDengineProvider(string masterConnectionString, string[] slaveConnectionString,
|
||||
Func<DbConnection> connectionFactory = null)
|
||||
{
|
||||
this.Ado = new TDengineAdo(this.InternalCommonUtils, masterConnectionString, slaveConnectionString,
|
||||
connectionFactory);
|
||||
this.Aop = new AopProvider();
|
||||
}
|
||||
|
||||
public override ISelect<T1> CreateSelectProvider<T1>(object dywhere)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
using System;
|
||||
using FreeSql.Internal;
|
||||
using FreeSql.Internal.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using FreeSql.Internal;
|
||||
using FreeSql.Internal.Model;
|
||||
|
||||
namespace FreeSql.Provider.TDengine
|
||||
namespace FreeSql.TDengine
|
||||
{
|
||||
internal class TDengineUtils : CommonUtils
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user