MySql驱动支持NewLife.MySql;整理代码
This commit is contained in:
parent
6db17b1108
commit
51f4178df7
|
@ -54,7 +54,7 @@ public class EntityCache<TEntity> : CacheBase<TEntity>, IEntityCache where TEnti
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 缓存核心
|
#region 缓存核心
|
||||||
private TEntity[] _Entities = new TEntity[0];
|
private TEntity[] _Entities = [];
|
||||||
/// <summary>实体集合。无数据返回空集合而不是null</summary>
|
/// <summary>实体集合。无数据返回空集合而不是null</summary>
|
||||||
public IList<TEntity> Entities
|
public IList<TEntity> Entities
|
||||||
{
|
{
|
||||||
|
|
|
@ -380,7 +380,7 @@ public class ClassBuilder
|
||||||
|
|
||||||
if (!type.IsNullOrEmpty())
|
if (!type.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
if (!type.Contains(".") && conv.GetMethod("To" + type, new Type[] { typeof(Object) }) != null)
|
if (!type.Contains(".") && conv.GetMethod("To" + type, [typeof(Object)]) != null)
|
||||||
{
|
{
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
|
|
|
@ -482,7 +482,7 @@ public class EntityBuilder : ClassBuilder
|
||||||
public void Merge(String fileName)
|
public void Merge(String fileName)
|
||||||
{
|
{
|
||||||
// 新旧代码分组
|
// 新旧代码分组
|
||||||
var newLines = ToString().Split(new[] { Environment.NewLine }, StringSplitOptions.None);
|
var newLines = ToString().Split([Environment.NewLine], StringSplitOptions.None);
|
||||||
var oldLines = File.ReadAllLines(fileName).ToList();
|
var oldLines = File.ReadAllLines(fileName).ToList();
|
||||||
|
|
||||||
var changed = 0;
|
var changed = 0;
|
||||||
|
|
|
@ -54,7 +54,7 @@ static class Helper
|
||||||
|
|
||||||
public static DataRow[] ToArray(this DataRowCollection collection)
|
public static DataRow[] ToArray(this DataRowCollection collection)
|
||||||
{
|
{
|
||||||
if (collection == null) return new DataRow[0];
|
if (collection == null) return [];
|
||||||
|
|
||||||
var list = new List<DataRow>();
|
var list = new List<DataRow>();
|
||||||
foreach (var item in collection)
|
foreach (var item in collection)
|
||||||
|
|
|
@ -11,16 +11,16 @@ namespace XCode.Common;
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal class KeyedLocker<TEntity>
|
internal class KeyedLocker<TEntity>
|
||||||
{
|
{
|
||||||
private static object[] Lockers;
|
private static Object[] Lockers;
|
||||||
static KeyedLocker()
|
static KeyedLocker()
|
||||||
{
|
{
|
||||||
int Length = 8;
|
var Length = 8;
|
||||||
var temp = new object[Length];
|
var temp = new Object[Length];
|
||||||
for (int i = 0; i < Length; i++) temp[i] = new object();
|
for (var i = 0; i < Length; i++) temp[i] = new Object();
|
||||||
Lockers = temp;
|
Lockers = temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static object SharedLock(string key)
|
public static Object SharedLock(String key)
|
||||||
{
|
{
|
||||||
if (key is null) throw new ArgumentNullException(nameof(key));
|
if (key is null) throw new ArgumentNullException(nameof(key));
|
||||||
var code = key.GetHashCode();
|
var code = key.GetHashCode();
|
||||||
|
|
|
@ -13,7 +13,7 @@ public partial class ValidHelper
|
||||||
if (value is T[] arr) return arr;
|
if (value is T[] arr) return arr;
|
||||||
if (value is null || Convert.IsDBNull(value)) return default;
|
if (value is null || Convert.IsDBNull(value)) return default;
|
||||||
if (value is IEnumerable<T> list) return list.ToArray();
|
if (value is IEnumerable<T> list) return list.ToArray();
|
||||||
if (value is T v) return new T[] { v };
|
if (value is T v) return [v];
|
||||||
if (value is IEnumerable)
|
if (value is IEnumerable)
|
||||||
{
|
{
|
||||||
var ret = new List<T>();
|
var ret = new List<T>();
|
||||||
|
|
|
@ -101,7 +101,7 @@ abstract class DbBase : DisposeBase, IDatabase
|
||||||
set => _providerFactory = value;
|
set => _providerFactory = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Dictionary<Type, DbProviderFactory> _factories = new();
|
private static readonly Dictionary<Type, DbProviderFactory> _factories = [];
|
||||||
private Boolean _inited;
|
private Boolean _inited;
|
||||||
protected DbProviderFactory? GetFactory(Boolean create)
|
protected DbProviderFactory? GetFactory(Boolean create)
|
||||||
{
|
{
|
||||||
|
@ -870,7 +870,7 @@ abstract class DbBase : DisposeBase, IDatabase
|
||||||
return value.ToString();
|
return value.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static readonly Char[] _likeKeys = new[] { '\'', '%', '_' };
|
private static readonly Char[] _likeKeys = ['\'', '%', '_'];
|
||||||
/// <summary>格式化模糊搜索的字符串。处理转义字符</summary>
|
/// <summary>格式化模糊搜索的字符串。处理转义字符</summary>
|
||||||
/// <param name="column">字段</param>
|
/// <param name="column">字段</param>
|
||||||
/// <param name="format">格式化字符串</param>
|
/// <param name="format">格式化字符串</param>
|
||||||
|
@ -1020,9 +1020,9 @@ abstract class DbBase : DisposeBase, IDatabase
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public virtual IDataParameter[] CreateParameters(Object? model)
|
public virtual IDataParameter[] CreateParameters(Object? model)
|
||||||
{
|
{
|
||||||
if (model == null) return new IDataParameter[0];
|
if (model == null) return [];
|
||||||
if (model is IDataParameter[] dps) return dps;
|
if (model is IDataParameter[] dps) return dps;
|
||||||
if (model is IDataParameter dp) return new[] { dp };
|
if (model is IDataParameter dp) return [dp];
|
||||||
if (model is IDictionary<String, Object> dic) return CreateParameters(dic);
|
if (model is IDictionary<String, Object> dic) return CreateParameters(dic);
|
||||||
|
|
||||||
var list = new List<IDataParameter>();
|
var list = new List<IDataParameter>();
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Data.Common;
|
using System.Data.Common;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using NewLife;
|
|
||||||
using NewLife.Collections;
|
using NewLife.Collections;
|
||||||
using NewLife.Data;
|
using NewLife.Data;
|
||||||
using NewLife.Log;
|
using NewLife.Log;
|
||||||
|
@ -11,16 +10,12 @@ namespace XCode.DataAccessLayer;
|
||||||
internal class Hana : RemoteDb
|
internal class Hana : RemoteDb
|
||||||
{
|
{
|
||||||
#region 属性
|
#region 属性
|
||||||
|
|
||||||
/// <summary>返回数据库类型。</summary>
|
/// <summary>返回数据库类型。</summary>
|
||||||
public override DatabaseType Type => DatabaseType.Hana;
|
public override DatabaseType Type => DatabaseType.Hana;
|
||||||
|
|
||||||
/// <summary>创建工厂</summary>
|
/// <summary>创建工厂</summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
protected override DbProviderFactory CreateFactory()
|
protected override DbProviderFactory? CreateFactory() => GetProviderFactory("Sap.Data.Hana", "Sap.Data.Hana.Core.dll", "Sap.Data.Hana.HanaFactory");
|
||||||
{
|
|
||||||
return GetProviderFactory("Sap.Data.Hana", "Sap.Data.Hana.Core.dll", "Sap.Data.Hana.HanaFactory")!;
|
|
||||||
}
|
|
||||||
|
|
||||||
private const String Server_Key = "Server";
|
private const String Server_Key = "Server";
|
||||||
|
|
||||||
|
@ -105,7 +100,7 @@ internal class Hana : RemoteDb
|
||||||
return base.FormatValue(field, value);
|
return base.FormatValue(field, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static readonly Char[] _likeKeys = new[] { '\\', '\'', '\"', '%', '_' };
|
private static readonly Char[] _likeKeys = ['\\', '\'', '\"', '%', '_'];
|
||||||
|
|
||||||
/// <summary>格式化模糊搜索的字符串。处理转义字符</summary>
|
/// <summary>格式化模糊搜索的字符串。处理转义字符</summary>
|
||||||
/// <param name="column">字段</param>
|
/// <param name="column">字段</param>
|
||||||
|
@ -382,7 +377,7 @@ internal class HanaMetaData : RemoteDbMetaData
|
||||||
var dt = ss.Query(sql, null);
|
var dt = ss.Query(sql, null);
|
||||||
if (dt.Rows.Count == 0) return null;
|
if (dt.Rows.Count == 0) return null;
|
||||||
|
|
||||||
var hs = new HashSet<String>(names ?? new String[0], StringComparer.OrdinalIgnoreCase);
|
var hs = new HashSet<String>(names ?? [], StringComparer.OrdinalIgnoreCase);
|
||||||
|
|
||||||
// 所有表
|
// 所有表
|
||||||
foreach (var dr in dt)
|
foreach (var dr in dt)
|
||||||
|
@ -552,7 +547,7 @@ internal class HanaMetaData : RemoteDbMetaData
|
||||||
|
|
||||||
protected override Boolean DatabaseExist(String databaseName)
|
protected override Boolean DatabaseExist(String databaseName)
|
||||||
{
|
{
|
||||||
var dt = GetSchema(_.Databases, new String[] { databaseName });
|
var dt = GetSchema(_.Databases, [databaseName]);
|
||||||
return dt != null && dt.Rows != null && dt.Rows.Count > 0;
|
return dt != null && dt.Rows != null && dt.Rows.Count > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Data.Common;
|
using System.Data.Common;
|
||||||
using NewLife;
|
|
||||||
using NewLife.Collections;
|
using NewLife.Collections;
|
||||||
using NewLife.Data;
|
using NewLife.Data;
|
||||||
using NewLife.Log;
|
using NewLife.Log;
|
||||||
|
@ -14,10 +13,12 @@ internal class HighGo : RemoteDb
|
||||||
#region 属性
|
#region 属性
|
||||||
/// <summary>返回数据库类型。外部DAL数据库类请使用Other</summary>
|
/// <summary>返回数据库类型。外部DAL数据库类请使用Other</summary>
|
||||||
public override DatabaseType Type => DatabaseType.HighGo;
|
public override DatabaseType Type => DatabaseType.HighGo;
|
||||||
|
|
||||||
/// <summary>模式</summary>
|
/// <summary>模式</summary>
|
||||||
public string? TableSchema { get; set; }
|
public String? TableSchema { get; set; }
|
||||||
|
|
||||||
/// <summary>系统数据库名</summary>
|
/// <summary>系统数据库名</summary>
|
||||||
public override String SystemDatabaseName => string.Empty;
|
public override String SystemDatabaseName => String.Empty;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 数据库特性
|
#region 数据库特性
|
||||||
|
@ -44,9 +45,9 @@ internal class HighGo : RemoteDb
|
||||||
{
|
{
|
||||||
if (batchSize <= 0) return base.BuildDeleteSql(tableName, where, 0);
|
if (batchSize <= 0) return base.BuildDeleteSql(tableName, where, 0);
|
||||||
var sb = Pool.StringBuilder.Get();
|
var sb = Pool.StringBuilder.Get();
|
||||||
var xWhere = string.Empty;
|
var xWhere = String.Empty;
|
||||||
var xTable = this.FormatName(tableName);
|
var xTable = this.FormatName(tableName);
|
||||||
if (!string.IsNullOrWhiteSpace(where)) xWhere = " Where " + where;
|
if (!String.IsNullOrWhiteSpace(where)) xWhere = " Where " + where;
|
||||||
var sql = $"WITH to_delete AS (SELECT \"ctid\" FROM {xTable} {xWhere} LIMIT {batchSize}) ";
|
var sql = $"WITH to_delete AS (SELECT \"ctid\" FROM {xTable} {xWhere} LIMIT {batchSize}) ";
|
||||||
sql += $"DELETE FROM {xTable} where \"ctid\" in (SELECT \"ctid\" from to_delete)";
|
sql += $"DELETE FROM {xTable} where \"ctid\" in (SELECT \"ctid\" from to_delete)";
|
||||||
return sql;
|
return sql;
|
||||||
|
@ -70,9 +71,11 @@ internal class HighGo : RemoteDb
|
||||||
}
|
}
|
||||||
/// <summary>创建元数据对象</summary>
|
/// <summary>创建元数据对象</summary>
|
||||||
protected override IMetaData OnCreateMetaData() => new HighGoMetaData();
|
protected override IMetaData OnCreateMetaData() => new HighGoMetaData();
|
||||||
|
|
||||||
/// <summary>创建数据库会话</summary>
|
/// <summary>创建数据库会话</summary>
|
||||||
protected override IDbSession OnCreateSession() => new HighGoSession(this);
|
protected override IDbSession OnCreateSession() => new HighGoSession(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>瀚高(HighGo)数据库</summary>
|
/// <summary>瀚高(HighGo)数据库</summary>
|
||||||
internal class HighGoSession : RemoteDbSession
|
internal class HighGoSession : RemoteDbSession
|
||||||
{
|
{
|
||||||
|
@ -84,19 +87,19 @@ internal class HighGoSession : RemoteDbSession
|
||||||
public override Int64 QueryCountFast(String tableName)
|
public override Int64 QueryCountFast(String tableName)
|
||||||
{
|
{
|
||||||
var db = Database as HighGo;
|
var db = Database as HighGo;
|
||||||
var sql = $"SELECT \"n_live_tup\" FROM \"pg_stat_user_tables\" WHERE \"schemaname\"='{db.TableSchema}' AND \"relname\" = '{tableName.Replace("\"", string.Empty)}'";
|
var sql = $"SELECT \"n_live_tup\" FROM \"pg_stat_user_tables\" WHERE \"schemaname\"='{db.TableSchema}' AND \"relname\" = '{tableName.Replace("\"", String.Empty)}'";
|
||||||
return ExecuteScalar<Int64>(sql);
|
return ExecuteScalar<Int64>(sql);
|
||||||
}
|
}
|
||||||
public override Task<Int64> QueryCountFastAsync(String tableName)
|
public override Task<Int64> QueryCountFastAsync(String tableName)
|
||||||
{
|
{
|
||||||
var db = Database as HighGo;
|
var db = Database as HighGo;
|
||||||
var sql = $"SELECT \"n_live_tup\" FROM \"pg_stat_user_tables\" WHERE \"schemaname\"='{db.TableSchema}' AND \"relname\" = '{tableName.Replace("\"", string.Empty)}'";
|
var sql = $"SELECT \"n_live_tup\" FROM \"pg_stat_user_tables\" WHERE \"schemaname\"='{db.TableSchema}' AND \"relname\" = '{tableName.Replace("\"", String.Empty)}'";
|
||||||
return ExecuteScalarAsync<Int64>(sql);
|
return ExecuteScalarAsync<Int64>(sql);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 批量操作
|
#region 批量操作
|
||||||
string GetBatchSql(String action, IDataTable table, IDataColumn[] columns, ICollection<String>? updateColumns, ICollection<String>? addColumns, IEnumerable<IModel> list)
|
String GetBatchSql(String action, IDataTable table, IDataColumn[] columns, ICollection<String>? updateColumns, ICollection<String>? addColumns, IEnumerable<IModel> list)
|
||||||
{
|
{
|
||||||
var sb = Pool.StringBuilder.Get();
|
var sb = Pool.StringBuilder.Get();
|
||||||
var db = Database as DbBase;
|
var db = Database as DbBase;
|
||||||
|
@ -178,21 +181,22 @@ internal class HighGoSession : RemoteDbSession
|
||||||
|
|
||||||
public override Int64 InsertAndGetIdentity(String sql, CommandType type = CommandType.Text, params IDataParameter[]? ps)
|
public override Int64 InsertAndGetIdentity(String sql, CommandType type = CommandType.Text, params IDataParameter[]? ps)
|
||||||
{
|
{
|
||||||
sql = sql + $" RETURNING *";
|
sql += $" RETURNING *";
|
||||||
return base.InsertAndGetIdentity(sql, type, ps);
|
return base.InsertAndGetIdentity(sql, type, ps);
|
||||||
}
|
}
|
||||||
public override Task<Int64> InsertAndGetIdentityAsync(String sql, CommandType type = CommandType.Text, params IDataParameter[]? ps)
|
public override Task<Int64> InsertAndGetIdentityAsync(String sql, CommandType type = CommandType.Text, params IDataParameter[]? ps)
|
||||||
{
|
{
|
||||||
sql = sql + $" RETURNING *";
|
sql += $" RETURNING *";
|
||||||
return base.InsertAndGetIdentityAsync(sql, type, ps);
|
return base.InsertAndGetIdentityAsync(sql, type, ps);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>瀚高(HighGo)元数据</summary>
|
/// <summary>瀚高(HighGo)元数据</summary>
|
||||||
internal class HighGoMetaData : RemoteDbMetaData
|
internal class HighGoMetaData : RemoteDbMetaData
|
||||||
{
|
{
|
||||||
#region 属性
|
#region 属性
|
||||||
HighGo _HighGo => Database as HighGo;
|
HighGo _HighGo => Database as HighGo;
|
||||||
string GetTablesSql
|
String GetTablesSql
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
@ -205,7 +209,8 @@ internal class HighGoMetaData : RemoteDbMetaData
|
||||||
where relkind in('p', 'r') and relname not like 'hg_%' and relname not like 'sql_%' and schemaname='{_HighGo.TableSchema}' order by relname";
|
where relkind in('p', 'r') and relname not like 'hg_%' and relname not like 'sql_%' and schemaname='{_HighGo.TableSchema}' order by relname";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
string GetColumnsSql
|
|
||||||
|
String GetColumnsSql
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
@ -238,7 +243,8 @@ internal class HighGoMetaData : RemoteDbMetaData
|
||||||
order by table_catalog, table_schema, ordinal_position";
|
order by table_catalog, table_schema, ordinal_position";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
string GetIndexsSql
|
|
||||||
|
String GetIndexsSql
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
@ -310,7 +316,7 @@ internal class HighGoMetaData : RemoteDbMetaData
|
||||||
var dt = ss.Query(GetTablesSql, null);
|
var dt = ss.Query(GetTablesSql, null);
|
||||||
if (dt.Rows == null || dt.Rows.Count == 0) return list;
|
if (dt.Rows == null || dt.Rows.Count == 0) return list;
|
||||||
//字段
|
//字段
|
||||||
sql = string.Format(GetColumnsSql, names != null && names.Length > 0 ? " and tablename in ('" + names.Join("','") + "')" : string.Empty);
|
sql = String.Format(GetColumnsSql, names != null && names.Length > 0 ? " and tablename in ('" + names.Join("','") + "')" : String.Empty);
|
||||||
var columns = ss.Query(sql, null);
|
var columns = ss.Query(sql, null);
|
||||||
var hs = new HashSet<String>(names ?? [], StringComparer.OrdinalIgnoreCase);
|
var hs = new HashSet<String>(names ?? [], StringComparer.OrdinalIgnoreCase);
|
||||||
//索引
|
//索引
|
||||||
|
@ -331,7 +337,7 @@ internal class HighGoMetaData : RemoteDbMetaData
|
||||||
if (columns.Rows != null && columns.Rows.Count > 0)
|
if (columns.Rows != null && columns.Rows.Count > 0)
|
||||||
{
|
{
|
||||||
var cols = columns.Where(o => $"{o["TableName"]}" == table.TableName);
|
var cols = columns.Where(o => $"{o["TableName"]}" == table.TableName);
|
||||||
if (cols is null || 0 >= cols.Count()) { continue; }
|
if (cols is null || !cols.Any()) { continue; }
|
||||||
foreach (var dc in cols)
|
foreach (var dc in cols)
|
||||||
{
|
{
|
||||||
var field = table.CreateColumn();
|
var field = table.CreateColumn();
|
||||||
|
@ -358,7 +364,7 @@ internal class HighGoMetaData : RemoteDbMetaData
|
||||||
if (indexes.Rows != null && indexes.Rows.Count > 0)
|
if (indexes.Rows != null && indexes.Rows.Count > 0)
|
||||||
{
|
{
|
||||||
var ins = indexes.Where(o => $"{o["tablename"]}" == table.TableName);
|
var ins = indexes.Where(o => $"{o["tablename"]}" == table.TableName);
|
||||||
if (ins is null || 0 >= ins.Count()) { continue; }
|
if (ins is null || !ins.Any()) { continue; }
|
||||||
foreach (var dr2 in ins)
|
foreach (var dr2 in ins)
|
||||||
{
|
{
|
||||||
var dname = $"{dr2["indexname"]}";
|
var dname = $"{dr2["indexname"]}";
|
||||||
|
@ -367,7 +373,7 @@ internal class HighGoMetaData : RemoteDbMetaData
|
||||||
di.Unique = indexdef.Contains("UNIQUE");
|
di.Unique = indexdef.Contains("UNIQUE");
|
||||||
var startIndex = indexdef.IndexOf("(") + 1;
|
var startIndex = indexdef.IndexOf("(") + 1;
|
||||||
var endIndex = indexdef.LastIndexOf(")");
|
var endIndex = indexdef.LastIndexOf(")");
|
||||||
var cname = indexdef?.Substring(startIndex, endIndex - startIndex).Replace("\"", string.Empty).Split(",").Select(o => o.Trim()).ToArray();
|
var cname = indexdef?.Substring(startIndex, endIndex - startIndex).Replace("\"", String.Empty).Split(",").Select(o => o.Trim()).ToArray();
|
||||||
if (cname is null || 0 >= cname.Length) continue;
|
if (cname is null || 0 >= cname.Length) continue;
|
||||||
|
|
||||||
var cs = new List<String>();
|
var cs = new List<String>();
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Data.Common;
|
using System.Data.Common;
|
||||||
using NewLife;
|
|
||||||
using NewLife.Collections;
|
using NewLife.Collections;
|
||||||
using NewLife.Data;
|
using NewLife.Data;
|
||||||
using NewLife.Log;
|
using NewLife.Log;
|
||||||
|
@ -14,12 +13,16 @@ internal class KingBase : RemoteDb
|
||||||
#region 属性
|
#region 属性
|
||||||
/// <summary>返回数据库类型。外部DAL数据库类请使用Other</summary>
|
/// <summary>返回数据库类型。外部DAL数据库类请使用Other</summary>
|
||||||
public override DatabaseType Type => DatabaseType.KingBase;
|
public override DatabaseType Type => DatabaseType.KingBase;
|
||||||
|
|
||||||
/// <summary>数据库版本</summary>
|
/// <summary>数据库版本</summary>
|
||||||
public Version Version { get; set; }
|
public Version Version { get; set; }
|
||||||
|
|
||||||
/// <summary>模式</summary>
|
/// <summary>模式</summary>
|
||||||
public string? TableSchema { get; set; }
|
public String? TableSchema { get; set; }
|
||||||
|
|
||||||
/// <summary>目前只支持兼容 Oracle、PostgreSQL、MySql</summary>
|
/// <summary>目前只支持兼容 Oracle、PostgreSQL、MySql</summary>
|
||||||
public DatabaseType DataBaseMode { get; set; } = DatabaseType.None;
|
public DatabaseType DataBaseMode { get; set; } = DatabaseType.None;
|
||||||
|
|
||||||
/// <summary>系统数据库名</summary>
|
/// <summary>系统数据库名</summary>
|
||||||
public override String SystemDatabaseName => "security";
|
public override String SystemDatabaseName => "security";
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -38,12 +41,13 @@ internal class KingBase : RemoteDb
|
||||||
public override String? BuildDeleteSql(String tableName, String where, Int32 batchSize)
|
public override String? BuildDeleteSql(String tableName, String where, Int32 batchSize)
|
||||||
{
|
{
|
||||||
if (batchSize <= 0) return base.BuildDeleteSql(tableName, where, 0);
|
if (batchSize <= 0) return base.BuildDeleteSql(tableName, where, 0);
|
||||||
var sb = Pool.StringBuilder.Get();
|
|
||||||
var xWhere = string.Empty;
|
var xWhere = String.Empty;
|
||||||
var xTable = this.FormatName(tableName);
|
var xTable = FormatName(tableName);
|
||||||
if (!string.IsNullOrWhiteSpace(where)) xWhere = " Where " + where;
|
if (!String.IsNullOrWhiteSpace(where)) xWhere = " Where " + where;
|
||||||
var sql = $"WITH to_delete AS (SELECT \"ctid\" FROM {xTable} {xWhere} LIMIT {batchSize}) ";
|
var sql = $"WITH to_delete AS (SELECT \"ctid\" FROM {xTable} {xWhere} LIMIT {batchSize}) ";
|
||||||
sql += $"DELETE FROM {xTable} where \"ctid\" in (SELECT \"ctid\" from to_delete)";
|
sql += $"DELETE FROM {xTable} where \"ctid\" in (SELECT \"ctid\" from to_delete)";
|
||||||
|
|
||||||
return sql;
|
return sql;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,6 +57,7 @@ internal class KingBase : RemoteDb
|
||||||
return base.FormatLike(column, format);
|
return base.FormatLike(column, format);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
protected override void OnSetConnectionString(ConnectionStringBuilder builder) => base.OnSetConnectionString(builder);
|
protected override void OnSetConnectionString(ConnectionStringBuilder builder) => base.OnSetConnectionString(builder);
|
||||||
|
|
||||||
protected override DbProviderFactory? CreateFactory()
|
protected override DbProviderFactory? CreateFactory()
|
||||||
|
@ -82,6 +87,7 @@ internal class KingBase : RemoteDb
|
||||||
public override String PageSplit(String sql, Int64 startRowIndex, Int64 maximumRows, String keyColumn) => PostgreSQL.PageSplitByOffsetLimit(sql, startRowIndex, maximumRows);
|
public override String PageSplit(String sql, Int64 startRowIndex, Int64 maximumRows, String keyColumn) => PostgreSQL.PageSplitByOffsetLimit(sql, startRowIndex, maximumRows);
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>人大金仓(KingBase)数据库</summary>
|
/// <summary>人大金仓(KingBase)数据库</summary>
|
||||||
internal class KingBaseSession : RemoteDbSession
|
internal class KingBaseSession : RemoteDbSession
|
||||||
{
|
{
|
||||||
|
@ -93,30 +99,31 @@ internal class KingBaseSession : RemoteDbSession
|
||||||
public override Int64 QueryCountFast(String tableName)
|
public override Int64 QueryCountFast(String tableName)
|
||||||
{
|
{
|
||||||
var db = Database as KingBase;
|
var db = Database as KingBase;
|
||||||
var sql = $"SELECT \"n_live_tup\" FROM \"sys_stat_user_tables\" WHERE \"schemaname\"='{db.TableSchema}' AND \"relname\" = '{tableName.Replace("\"", string.Empty)}'";
|
var sql = $"SELECT \"n_live_tup\" FROM \"sys_stat_user_tables\" WHERE \"schemaname\"='{db.TableSchema}' AND \"relname\" = '{tableName.Replace("\"", String.Empty)}'";
|
||||||
return ExecuteScalar<Int64>(sql);
|
return ExecuteScalar<Int64>(sql);
|
||||||
}
|
}
|
||||||
public override Task<Int64> QueryCountFastAsync(String tableName)
|
public override Task<Int64> QueryCountFastAsync(String tableName)
|
||||||
{
|
{
|
||||||
var db = Database as KingBase;
|
var db = Database as KingBase;
|
||||||
var sql = $"SELECT \"n_live_tup\" FROM \"sys_stat_user_tables\" WHERE \"schemaname\"='{db.TableSchema}' AND \"relname\" = '{tableName.Replace("\"", string.Empty)}'";
|
var sql = $"SELECT \"n_live_tup\" FROM \"sys_stat_user_tables\" WHERE \"schemaname\"='{db.TableSchema}' AND \"relname\" = '{tableName.Replace("\"", String.Empty)}'";
|
||||||
return ExecuteScalarAsync<Int64>(sql);
|
return ExecuteScalarAsync<Int64>(sql);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public override Int64 InsertAndGetIdentity(String sql, CommandType type = CommandType.Text, params IDataParameter[]? ps)
|
public override Int64 InsertAndGetIdentity(String sql, CommandType type = CommandType.Text, params IDataParameter[]? ps)
|
||||||
{
|
{
|
||||||
sql = sql + $" RETURNING *";
|
sql += $" RETURNING *";
|
||||||
return base.InsertAndGetIdentity(sql, type, ps);
|
return base.InsertAndGetIdentity(sql, type, ps);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Task<Int64> InsertAndGetIdentityAsync(String sql, CommandType type = CommandType.Text, params IDataParameter[]? ps)
|
public override Task<Int64> InsertAndGetIdentityAsync(String sql, CommandType type = CommandType.Text, params IDataParameter[]? ps)
|
||||||
{
|
{
|
||||||
sql = sql + $" RETURNING *";
|
sql += $" RETURNING *";
|
||||||
return base.InsertAndGetIdentityAsync(sql, type, ps);
|
return base.InsertAndGetIdentityAsync(sql, type, ps);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region 批量操作
|
#region 批量操作
|
||||||
string GetBatchSql(String action, IDataTable table, IDataColumn[] columns, ICollection<String>? updateColumns, ICollection<String>? addColumns, IEnumerable<IModel> list)
|
String GetBatchSql(String action, IDataTable table, IDataColumn[] columns, ICollection<String>? updateColumns, ICollection<String>? addColumns, IEnumerable<IModel> list)
|
||||||
{
|
{
|
||||||
var sb = Pool.StringBuilder.Get();
|
var sb = Pool.StringBuilder.Get();
|
||||||
var db = Database as DbBase;
|
var db = Database as DbBase;
|
||||||
|
@ -156,12 +163,13 @@ internal class KingBaseSession : RemoteDbSession
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>人大金仓(KingBase)元数据</summary>
|
/// <summary>人大金仓(KingBase)元数据</summary>
|
||||||
internal class KingBaseMetaData : RemoteDbMetaData
|
internal class KingBaseMetaData : RemoteDbMetaData
|
||||||
{
|
{
|
||||||
#region 属性
|
#region 属性
|
||||||
KingBase _KingBase => Database as KingBase;
|
KingBase _KingBase => Database as KingBase;
|
||||||
string GetTablesSql
|
String GetTablesSql
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
@ -174,7 +182,7 @@ internal class KingBaseMetaData : RemoteDbMetaData
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
string GetColumnsSql
|
String GetColumnsSql
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
@ -211,7 +219,7 @@ internal class KingBaseMetaData : RemoteDbMetaData
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
string GetIndexsSql
|
String GetIndexsSql
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
@ -328,7 +336,7 @@ internal class KingBaseMetaData : RemoteDbMetaData
|
||||||
var dt = ss.Query(GetTablesSql, null);
|
var dt = ss.Query(GetTablesSql, null);
|
||||||
if (dt.Rows == null || dt.Rows.Count == 0) return list;
|
if (dt.Rows == null || dt.Rows.Count == 0) return list;
|
||||||
//字段
|
//字段
|
||||||
sql = string.Format(GetColumnsSql, names != null && names.Length > 0 ? " and tablename in ('" + names.Join("','") + "')" : string.Empty);
|
sql = String.Format(GetColumnsSql, names != null && names.Length > 0 ? " and tablename in ('" + names.Join("','") + "')" : String.Empty);
|
||||||
var columns = ss.Query(sql, null);
|
var columns = ss.Query(sql, null);
|
||||||
//索引
|
//索引
|
||||||
sql = GetIndexsSql;
|
sql = GetIndexsSql;
|
||||||
|
@ -356,7 +364,7 @@ internal class KingBaseMetaData : RemoteDbMetaData
|
||||||
if (columns.Rows != null && columns.Rows.Count > 0)
|
if (columns.Rows != null && columns.Rows.Count > 0)
|
||||||
{
|
{
|
||||||
var cols = columns.Where(o => $"{o["TableName"]}" == table.TableName);
|
var cols = columns.Where(o => $"{o["TableName"]}" == table.TableName);
|
||||||
if (cols is null || 0 >= cols.Count()) { continue; }
|
if (cols is null || !cols.Any()) { continue; }
|
||||||
foreach (var dc in cols)
|
foreach (var dc in cols)
|
||||||
{
|
{
|
||||||
var field = table.CreateColumn();
|
var field = table.CreateColumn();
|
||||||
|
@ -383,7 +391,7 @@ internal class KingBaseMetaData : RemoteDbMetaData
|
||||||
if (indexes.Rows != null && indexes.Rows.Count > 0)
|
if (indexes.Rows != null && indexes.Rows.Count > 0)
|
||||||
{
|
{
|
||||||
var ins = indexes.Where(o => $"{o["tablename"]}" == table.TableName);
|
var ins = indexes.Where(o => $"{o["tablename"]}" == table.TableName);
|
||||||
if (ins is null || 0 >= ins.Count()) { continue; }
|
if (ins is null || !ins.Any()) { continue; }
|
||||||
foreach (var dr2 in ins)
|
foreach (var dr2 in ins)
|
||||||
{
|
{
|
||||||
var dname = $"{dr2["indexname"]}";
|
var dname = $"{dr2["indexname"]}";
|
||||||
|
@ -392,7 +400,7 @@ internal class KingBaseMetaData : RemoteDbMetaData
|
||||||
di.Unique = indexdef.Contains("UNIQUE");
|
di.Unique = indexdef.Contains("UNIQUE");
|
||||||
var startIndex = indexdef.IndexOf("(") + 1;
|
var startIndex = indexdef.IndexOf("(") + 1;
|
||||||
var endIndex = indexdef.LastIndexOf(")");
|
var endIndex = indexdef.LastIndexOf(")");
|
||||||
var cname = indexdef?.Substring(startIndex, endIndex - startIndex).Replace("\"", string.Empty).Split(",").Select(o => o.Trim()).ToArray();
|
var cname = indexdef?.Substring(startIndex, endIndex - startIndex).Replace("\"", String.Empty).Split(",").Select(o => o.Trim()).ToArray();
|
||||||
if (cname is null || 0 >= cname.Length) continue;
|
if (cname is null || 0 >= cname.Length) continue;
|
||||||
|
|
||||||
var cs = new List<String>();
|
var cs = new List<String>();
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Data.Common;
|
using System.Data.Common;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using NewLife;
|
|
||||||
using NewLife.Collections;
|
using NewLife.Collections;
|
||||||
using NewLife.Data;
|
using NewLife.Data;
|
||||||
using NewLife.Log;
|
using NewLife.Log;
|
||||||
|
@ -17,12 +16,12 @@ internal class MySql : RemoteDb
|
||||||
|
|
||||||
/// <summary>创建工厂</summary>
|
/// <summary>创建工厂</summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
protected override DbProviderFactory CreateFactory()
|
protected override DbProviderFactory? CreateFactory()
|
||||||
{
|
{
|
||||||
//_Factory = GetProviderFactory("NewLife.MySql.dll", "NewLife.MySql.MySqlClientFactory") ??
|
//_Factory = GetProviderFactory("NewLife.MySql.dll", "NewLife.MySql.MySqlClientFactory") ??
|
||||||
// GetProviderFactory("MySql.Data.dll", "MySql.Data.MySqlClient.MySqlClientFactory");
|
// GetProviderFactory("MySql.Data.dll", "MySql.Data.MySqlClient.MySqlClientFactory");
|
||||||
// MewLife.MySql 在开发过程中,数据驱动下载站点没有它的包,暂时不支持下载
|
// MewLife.MySql 在开发过程中,数据驱动下载站点没有它的包,暂时不支持下载
|
||||||
return GetProviderFactory("NewLife.MySql", null, "NewLife.MySql.MySqlClientFactory", true, true) ??
|
return GetProviderFactory("NewLife.MySql", "NewLife.MySql.dll", "NewLife.MySql.MySqlClientFactory", true, true) ??
|
||||||
GetProviderFactory(null, "MySql.Data.dll", "MySql.Data.MySqlClient.MySqlClientFactory");
|
GetProviderFactory(null, "MySql.Data.dll", "MySql.Data.MySqlClient.MySqlClientFactory");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -283,13 +282,13 @@ internal class MySqlSession : RemoteDbSession
|
||||||
/// <param name="type">命令类型,默认SQL文本</param>
|
/// <param name="type">命令类型,默认SQL文本</param>
|
||||||
/// <param name="ps">命令参数</param>
|
/// <param name="ps">命令参数</param>
|
||||||
/// <returns>新增行的自动编号</returns>
|
/// <returns>新增行的自动编号</returns>
|
||||||
public override Int64 InsertAndGetIdentity(String sql, CommandType type = CommandType.Text, params IDataParameter[] ps)
|
public override Int64 InsertAndGetIdentity(String sql, CommandType type = CommandType.Text, params IDataParameter[]? ps)
|
||||||
{
|
{
|
||||||
sql += ";Select LAST_INSERT_ID()";
|
sql += ";Select LAST_INSERT_ID()";
|
||||||
return base.InsertAndGetIdentity(sql, type, ps);
|
return base.InsertAndGetIdentity(sql, type, ps);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Task<Int64> InsertAndGetIdentityAsync(String sql, CommandType type = CommandType.Text, params IDataParameter[] ps)
|
public override Task<Int64> InsertAndGetIdentityAsync(String sql, CommandType type = CommandType.Text, params IDataParameter[]? ps)
|
||||||
{
|
{
|
||||||
sql += ";Select LAST_INSERT_ID()";
|
sql += ";Select LAST_INSERT_ID()";
|
||||||
return base.InsertAndGetIdentityAsync(sql, type, ps);
|
return base.InsertAndGetIdentityAsync(sql, type, ps);
|
||||||
|
|
|
@ -21,7 +21,7 @@ internal class Oracle : RemoteDb
|
||||||
|
|
||||||
/// <summary>创建工厂</summary>
|
/// <summary>创建工厂</summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
protected override DbProviderFactory CreateFactory() => GetProviderFactory(null, "Oracle.ManagedDataAccess.dll", "Oracle.ManagedDataAccess.Client.OracleClientFactory");
|
protected override DbProviderFactory? CreateFactory() => GetProviderFactory(null, "Oracle.ManagedDataAccess.dll", "Oracle.ManagedDataAccess.Client.OracleClientFactory");
|
||||||
|
|
||||||
protected override void OnSetConnectionString(ConnectionStringBuilder builder)
|
protected override void OnSetConnectionString(ConnectionStringBuilder builder)
|
||||||
{
|
{
|
||||||
|
@ -754,7 +754,7 @@ internal class OracleMeta : RemoteDbMetaData
|
||||||
var owner = Owner;
|
var owner = Owner;
|
||||||
//if (owner.IsNullOrEmpty()) owner = UserID;
|
//if (owner.IsNullOrEmpty()) owner = UserID;
|
||||||
|
|
||||||
dt = GetSchema(_.Tables, new String[] { owner, tableName });
|
dt = GetSchema(_.Tables, [owner, tableName]);
|
||||||
if (!dt.Columns.Contains("TABLE_TYPE"))
|
if (!dt.Columns.Contains("TABLE_TYPE"))
|
||||||
{
|
{
|
||||||
dt.Columns.Add("TABLE_TYPE", typeof(String));
|
dt.Columns.Add("TABLE_TYPE", typeof(String));
|
||||||
|
@ -763,7 +763,7 @@ internal class OracleMeta : RemoteDbMetaData
|
||||||
dr["TABLE_TYPE"] = "Table";
|
dr["TABLE_TYPE"] = "Table";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var dtView = GetSchema(_.Views, new String[] { owner, tableName });
|
var dtView = GetSchema(_.Views, [owner, tableName]);
|
||||||
if (dtView != null && dtView.Rows.Count != 0)
|
if (dtView != null && dtView.Rows.Count != 0)
|
||||||
{
|
{
|
||||||
foreach (var dr in dtView.Rows?.ToArray())
|
foreach (var dr in dtView.Rows?.ToArray())
|
||||||
|
@ -796,7 +796,7 @@ internal class OracleMeta : RemoteDbMetaData
|
||||||
data["IndexColumns"] = Get("all_ind_columns", owner, tableName, mulTable, "Table_Owner");
|
data["IndexColumns"] = Get("all_ind_columns", owner, tableName, mulTable, "Table_Owner");
|
||||||
|
|
||||||
// 主键
|
// 主键
|
||||||
if (MetaDataCollections.Contains(_.PrimaryKeys)) data["PrimaryKeys"] = GetSchema(_.PrimaryKeys, new String[] { owner, tableName, null });
|
if (MetaDataCollections.Contains(_.PrimaryKeys)) data["PrimaryKeys"] = GetSchema(_.PrimaryKeys, [owner, tableName, null]);
|
||||||
|
|
||||||
// 序列
|
// 序列
|
||||||
data["Sequences"] = Get("all_sequences", owner, null, null, "Sequence_Owner");
|
data["Sequences"] = Get("all_sequences", owner, null, null, "Sequence_Owner");
|
||||||
|
@ -820,7 +820,7 @@ internal class OracleMeta : RemoteDbMetaData
|
||||||
{
|
{
|
||||||
var list = new List<String>();
|
var list = new List<String>();
|
||||||
|
|
||||||
var dt = GetSchema(_.Tables, new String[] { Owner, null });
|
var dt = GetSchema(_.Tables, [Owner, null]);
|
||||||
if (dt?.Rows == null || dt.Rows.Count <= 0) return list;
|
if (dt?.Rows == null || dt.Rows.Count <= 0) return list;
|
||||||
|
|
||||||
foreach (DataRow dr in dt.Rows)
|
foreach (DataRow dr in dt.Rows)
|
||||||
|
|
|
@ -3,7 +3,6 @@ using System.Data;
|
||||||
using System.Data.Common;
|
using System.Data.Common;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using NewLife;
|
|
||||||
using NewLife.Collections;
|
using NewLife.Collections;
|
||||||
using NewLife.Data;
|
using NewLife.Data;
|
||||||
using NewLife.Log;
|
using NewLife.Log;
|
||||||
|
@ -20,7 +19,7 @@ internal class PostgreSQL : RemoteDb
|
||||||
|
|
||||||
/// <summary>创建工厂</summary>
|
/// <summary>创建工厂</summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
protected override DbProviderFactory CreateFactory() => GetProviderFactory(null, "Npgsql.dll", "Npgsql.NpgsqlFactory");
|
protected override DbProviderFactory? CreateFactory() => GetProviderFactory(null, "Npgsql.dll", "Npgsql.NpgsqlFactory");
|
||||||
|
|
||||||
private const String Server_Key = "Server";
|
private const String Server_Key = "Server";
|
||||||
|
|
||||||
|
@ -333,13 +332,13 @@ internal class PostgreSQLSession : RemoteDbSession
|
||||||
/// <returns>新增行的自动编号</returns>
|
/// <returns>新增行的自动编号</returns>
|
||||||
public override Int64 InsertAndGetIdentity(String sql, CommandType type = CommandType.Text, params IDataParameter[] ps)
|
public override Int64 InsertAndGetIdentity(String sql, CommandType type = CommandType.Text, params IDataParameter[] ps)
|
||||||
{
|
{
|
||||||
sql = sql + $" RETURNING *";
|
sql += $" RETURNING *";
|
||||||
return base.InsertAndGetIdentity(sql, type, ps);
|
return base.InsertAndGetIdentity(sql, type, ps);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Task<Int64> InsertAndGetIdentityAsync(String sql, CommandType type = CommandType.Text, params IDataParameter[] ps)
|
public override Task<Int64> InsertAndGetIdentityAsync(String sql, CommandType type = CommandType.Text, params IDataParameter[] ps)
|
||||||
{
|
{
|
||||||
sql = sql + $" RETURNING *";
|
sql += $" RETURNING *";
|
||||||
return base.InsertAndGetIdentityAsync(sql, type, ps);
|
return base.InsertAndGetIdentityAsync(sql, type, ps);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -634,14 +633,14 @@ internal class PostgreSQLMetaData : RemoteDbMetaData
|
||||||
|
|
||||||
var session = Database.CreateSession();
|
var session = Database.CreateSession();
|
||||||
//var dt = GetSchema(_.Databases, new String[] { databaseName.ToLower() });
|
//var dt = GetSchema(_.Databases, new String[] { databaseName.ToLower() });
|
||||||
var dt = GetSchema(_.Databases, new String[] { databaseName });
|
var dt = GetSchema(_.Databases, [databaseName]);
|
||||||
return dt != null && dt.Rows != null && dt.Rows.Count > 0;
|
return dt != null && dt.Rows != null && dt.Rows.Count > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建数据库的 SQL 语句,强制带上双引号。
|
/// 创建数据库的 SQL 语句,强制带上双引号。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public override string CreateDatabaseSQL(string dbname, string? file)
|
public override String CreateDatabaseSQL(String dbname, String? file)
|
||||||
{
|
{
|
||||||
return String.Format("Create Database \"{0}\"", dbname.Replace("\"", "\"\""));
|
return String.Format("Create Database \"{0}\"", dbname.Replace("\"", "\"\""));
|
||||||
}
|
}
|
||||||
|
@ -751,12 +750,12 @@ order by
|
||||||
if (idxs.Length > 0)
|
if (idxs.Length > 0)
|
||||||
{
|
{
|
||||||
var idx_sql = $"SELECT conname FROM pg_constraint WHERE contype = 'p' AND conname IN (" +
|
var idx_sql = $"SELECT conname FROM pg_constraint WHERE contype = 'p' AND conname IN (" +
|
||||||
$"{string.Join(",", idxs.Select(f => $"'{f}'"))})";
|
$"{String.Join(",", idxs.Select(f => $"'{f}'"))})";
|
||||||
ds = session.Query(idx_sql);
|
ds = session.Query(idx_sql);
|
||||||
if (ds.Tables.Count != 0)
|
if (ds.Tables.Count != 0)
|
||||||
{
|
{
|
||||||
var dt = ds.Tables[0]!;
|
var dt = ds.Tables[0]!;
|
||||||
var set = new HashSet<string>();
|
var set = new HashSet<String>();
|
||||||
foreach (DataRow dr in dt.Rows)
|
foreach (DataRow dr in dt.Rows)
|
||||||
{
|
{
|
||||||
set.Add(Convert.ToString(dr[0]));
|
set.Add(Convert.ToString(dr[0]));
|
||||||
|
@ -767,7 +766,7 @@ order by
|
||||||
{
|
{
|
||||||
foreach (var idx in tbl.Indexes)
|
foreach (var idx in tbl.Indexes)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrWhiteSpace(idx.Name) && set.Contains(idx.Name!)) idx.PrimaryKey = true;
|
if (!String.IsNullOrWhiteSpace(idx.Name) && set.Contains(idx.Name!)) idx.PrimaryKey = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ using System.Diagnostics;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using NewLife;
|
|
||||||
using NewLife.Collections;
|
using NewLife.Collections;
|
||||||
using NewLife.Data;
|
using NewLife.Data;
|
||||||
using NewLife.Log;
|
using NewLife.Log;
|
||||||
|
@ -21,11 +20,11 @@ internal class SQLite : FileDbBase
|
||||||
|
|
||||||
/// <summary>创建工厂</summary>
|
/// <summary>创建工厂</summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
protected override DbProviderFactory CreateFactory()
|
protected override DbProviderFactory? CreateFactory()
|
||||||
{
|
{
|
||||||
// Mono有自己的驱动,因为SQLite是混合编译,里面的C++代码与平台相关,不能通用;注意大小写问题
|
// Mono有自己的驱动,因为SQLite是混合编译,里面的C++代码与平台相关,不能通用;注意大小写问题
|
||||||
if (Runtime.Mono)
|
if (Runtime.Mono)
|
||||||
return GetProviderFactory(null, "Mono.Data.Sqlite.dll", "System.Data.SqliteFactory");
|
return GetProviderFactory(null, "Mono.Data.Sqlite.dll", "System.Data.SqliteFactory")!;
|
||||||
|
|
||||||
var type =
|
var type =
|
||||||
PluginHelper.LoadPlugin("System.Data.SQLite.SQLiteFactory", null, "System.Data.SQLite.dll", null) ??
|
PluginHelper.LoadPlugin("System.Data.SQLite.SQLiteFactory", null, "System.Data.SQLite.dll", null) ??
|
||||||
|
@ -498,7 +497,7 @@ internal class SQLiteMetaData : FileDbMetaData
|
||||||
var ds = ss.Query(sql, null);
|
var ds = ss.Query(sql, null);
|
||||||
if (ds.Rows.Count == 0) return list;
|
if (ds.Rows.Count == 0) return list;
|
||||||
|
|
||||||
var hs = new HashSet<String>(names ?? new String[0], StringComparer.OrdinalIgnoreCase);
|
var hs = new HashSet<String>(names ?? [], StringComparer.OrdinalIgnoreCase);
|
||||||
|
|
||||||
var dts = Select(ds, "type", "table");
|
var dts = Select(ds, "type", "table");
|
||||||
var dis = Select(ds, "type", "index");
|
var dis = Select(ds, "type", "index");
|
||||||
|
@ -824,7 +823,7 @@ internal class SQLiteMetaData : FileDbMetaData
|
||||||
sb.Append("Create Index ");
|
sb.Append("Create Index ");
|
||||||
|
|
||||||
// SQLite索引优先采用自带索引名
|
// SQLite索引优先采用自带索引名
|
||||||
if (!String.IsNullOrEmpty(index.Name) && index.Name.Contains(index.Table.TableName))
|
if (!index.Name.IsNullOrEmpty() && index.Name.Contains(index.Table.TableName))
|
||||||
sb.Append(index.Name);
|
sb.Append(index.Name);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,7 +20,7 @@ class SqlCe : FileDbBase
|
||||||
|
|
||||||
/// <summary>创建工厂</summary>
|
/// <summary>创建工厂</summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
protected override DbProviderFactory CreateFactory()
|
protected override DbProviderFactory? CreateFactory()
|
||||||
{
|
{
|
||||||
// 找不到驱动时,再到线上下载
|
// 找不到驱动时,再到线上下载
|
||||||
var factory = GetProviderFactory(null, "System.Data.SqlServerCe.dll", "System.Data.SqlServerCe.SqlCeProviderFactory");
|
var factory = GetProviderFactory(null, "System.Data.SqlServerCe.dll", "System.Data.SqlServerCe.SqlCeProviderFactory");
|
||||||
|
|
|
@ -4,7 +4,6 @@ using System.Diagnostics;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using NewLife;
|
|
||||||
using NewLife.Collections;
|
using NewLife.Collections;
|
||||||
using NewLife.Data;
|
using NewLife.Data;
|
||||||
using NewLife.Log;
|
using NewLife.Log;
|
||||||
|
@ -21,7 +20,7 @@ internal class SqlServer : RemoteDb
|
||||||
|
|
||||||
/// <summary>创建工厂</summary>
|
/// <summary>创建工厂</summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
protected override DbProviderFactory CreateFactory()
|
protected override DbProviderFactory? CreateFactory()
|
||||||
{
|
{
|
||||||
// Microsoft 是最新的跨平台版本,优先使用
|
// Microsoft 是最新的跨平台版本,优先使用
|
||||||
//if (_Factory == null) _Factory = GetProviderFactory("Microsoft.Data.SqlClient.dll", "Microsoft.Data.SqlClient.SqlClientFactory", false, true);
|
//if (_Factory == null) _Factory = GetProviderFactory("Microsoft.Data.SqlClient.dll", "Microsoft.Data.SqlClient.SqlClientFactory", false, true);
|
||||||
|
@ -210,7 +209,7 @@ internal class SqlServer : RemoteDb
|
||||||
// 如果包含分组,则必须作为子查询
|
// 如果包含分组,则必须作为子查询
|
||||||
var builder1 = builder.CloneWithGroupBy("XCode_T0", true);
|
var builder1 = builder.CloneWithGroupBy("XCode_T0", true);
|
||||||
// *替换为{builder.Column},否则会出现查询字段不一致的问题
|
// *替换为{builder.Column},否则会出现查询字段不一致的问题
|
||||||
var column = string.IsNullOrEmpty(builder.Column) ? "*" : builder.Column;
|
var column = String.IsNullOrEmpty(builder.Column) ? "*" : builder.Column;
|
||||||
builder1.Column = $"{column}, row_number() over(Order By {builder.OrderBy ?? builder.Key}) as rowNumber";
|
builder1.Column = $"{column}, row_number() over(Order By {builder.OrderBy ?? builder.Key}) as rowNumber";
|
||||||
|
|
||||||
var builder2 = builder1.AsChild("XCode_T1", true);
|
var builder2 = builder1.AsChild("XCode_T1", true);
|
||||||
|
@ -252,7 +251,7 @@ internal class SqlServer : RemoteDb
|
||||||
|
|
||||||
#region Max/Min分页
|
#region Max/Min分页
|
||||||
// 如果要使用max/min分页法,首先keyColumn必须有asc或者desc
|
// 如果要使用max/min分页法,首先keyColumn必须有asc或者desc
|
||||||
if (!String.IsNullOrEmpty(keyColumn))
|
if (!keyColumn.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
var kc = keyColumn.ToLower();
|
var kc = keyColumn.ToLower();
|
||||||
if (kc.EndsWith(" desc") || kc.EndsWith(" asc") || kc.EndsWith(" unknown"))
|
if (kc.EndsWith(" desc") || kc.EndsWith(" asc") || kc.EndsWith(" unknown"))
|
||||||
|
@ -1329,7 +1328,7 @@ internal class SqlServerMetaData : RemoteDbMetaData
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
protected override Boolean DatabaseExist(String dbname)
|
protected override Boolean DatabaseExist(String dbname)
|
||||||
{
|
{
|
||||||
var dt = GetSchema(_.Databases, new String[] { dbname });
|
var dt = GetSchema(_.Databases, [dbname]);
|
||||||
return dt != null && dt.Rows != null && dt.Rows.Count > 0;
|
return dt != null && dt.Rows != null && dt.Rows.Count > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1498,7 +1497,7 @@ internal class SqlServerMetaData : RemoteDbMetaData
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public Boolean TableExist(IDataTable table)
|
public Boolean TableExist(IDataTable table)
|
||||||
{
|
{
|
||||||
var dt = GetSchema(_.Tables, new String[] { null, null, table.TableName, null });
|
var dt = GetSchema(_.Tables, [null, null, table.TableName, null]);
|
||||||
return dt != null && dt.Rows != null && dt.Rows.Count > 0;
|
return dt != null && dt.Rows != null && dt.Rows.Count > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -284,7 +284,7 @@ class TDengineMetaData : RemoteDbMetaData
|
||||||
var dt = ss.Query(sql, null);
|
var dt = ss.Query(sql, null);
|
||||||
if (dt.Rows.Count == 0) return null;
|
if (dt.Rows.Count == 0) return null;
|
||||||
|
|
||||||
var hs = new HashSet<String>(names ?? new String[0], StringComparer.OrdinalIgnoreCase);
|
var hs = new HashSet<String>(names ?? [], StringComparer.OrdinalIgnoreCase);
|
||||||
|
|
||||||
// 所有表
|
// 所有表
|
||||||
foreach (var dr in dt)
|
foreach (var dr in dt)
|
||||||
|
|
|
@ -338,9 +338,9 @@ internal partial class DbMetaData
|
||||||
{
|
{
|
||||||
foreach (var col in table.Columns)
|
foreach (var col in table.Columns)
|
||||||
{
|
{
|
||||||
if (string.Equals(col.Name, name, StringComparison.OrdinalIgnoreCase)) return col;
|
if (String.Equals(col.Name, name, StringComparison.OrdinalIgnoreCase)) return col;
|
||||||
if (string.Equals(col.ColumnName, name, StringComparison.OrdinalIgnoreCase)) return col;
|
if (String.Equals(col.ColumnName, name, StringComparison.OrdinalIgnoreCase)) return col;
|
||||||
if (string.Equals(FormatName(col), name, StringComparison.OrdinalIgnoreCase)) return col;
|
if (String.Equals(FormatName(col), name, StringComparison.OrdinalIgnoreCase)) return col;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -860,7 +860,7 @@ internal partial class DbMetaData
|
||||||
if (/*schema == DDLSchema.TableExist ||*/ schema == DDLSchema.DatabaseExist) return session.QueryCount(sql) > 0;
|
if (/*schema == DDLSchema.TableExist ||*/ schema == DDLSchema.DatabaseExist) return session.QueryCount(sql) > 0;
|
||||||
|
|
||||||
// 分隔符是分号加换行,如果不想被拆开执行(比如有事务),可以在分号和换行之间加一个空格
|
// 分隔符是分号加换行,如果不想被拆开执行(比如有事务),可以在分号和换行之间加一个空格
|
||||||
var sqls = sql.Split(new[] { ";" + Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
|
var sqls = sql.Split([";" + Environment.NewLine], StringSplitOptions.RemoveEmptyEntries);
|
||||||
if (sqls == null || sqls.Length <= 1) return session.Execute(sql);
|
if (sqls == null || sqls.Length <= 1) return session.Execute(sql);
|
||||||
|
|
||||||
session.BeginTransaction(IsolationLevel.Serializable);
|
session.BeginTransaction(IsolationLevel.Serializable);
|
||||||
|
|
|
@ -393,7 +393,7 @@ partial class DbMetaData
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual bool IsArrayField(Type type)
|
protected virtual Boolean IsArrayField(Type type)
|
||||||
{
|
{
|
||||||
return type.IsArray && !Types.ContainsKey(type);
|
return type.IsArray && !Types.ContainsKey(type);
|
||||||
}
|
}
|
||||||
|
@ -420,7 +420,7 @@ partial class DbMetaData
|
||||||
switch (trueType.Name)
|
switch (trueType.Name)
|
||||||
{
|
{
|
||||||
case "Int64":
|
case "Int64":
|
||||||
type = typeof(long);
|
type = typeof(Int64);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
type = typeof(Int32);
|
type = typeof(Int32);
|
||||||
|
|
|
@ -55,7 +55,7 @@ public class ModelResolver : IModelResolver
|
||||||
public Boolean Camel { get; set; } = true;
|
public Boolean Camel { get; set; } = true;
|
||||||
|
|
||||||
/// <summary>描述信息分隔符。从描述信息前部分隔出显示名</summary>
|
/// <summary>描述信息分隔符。从描述信息前部分隔出显示名</summary>
|
||||||
public Char[] SeparateChars { get; set; } = new Char[] { '.', '。', ',', ',', ';', ';', ':', ':', '\r', '\n' };
|
public Char[] SeparateChars { get; set; } = ['.', '。', ',', ',', ';', ';', ':', ':', '\r', '\n'];
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 名称处理
|
#region 名称处理
|
||||||
|
@ -342,7 +342,7 @@ public class ModelResolver : IModelResolver
|
||||||
if (di == null)
|
if (di == null)
|
||||||
{
|
{
|
||||||
di = table.CreateIndex();
|
di = table.CreateIndex();
|
||||||
di.Columns = new String[] { dc.ColumnName };
|
di.Columns = [dc.ColumnName];
|
||||||
//di.Computed = true;
|
//di.Computed = true;
|
||||||
}
|
}
|
||||||
// 不管是不是原来有的索引,都要唯一
|
// 不管是不是原来有的索引,都要唯一
|
||||||
|
|
|
@ -561,7 +561,7 @@ public static class ModelHelper
|
||||||
|
|
||||||
if (pi.PropertyType == typeof(String[]))
|
if (pi.PropertyType == typeof(String[]))
|
||||||
{
|
{
|
||||||
var ss = v.Split(new String[] { "," }, StringSplitOptions.RemoveEmptyEntries);
|
var ss = v.Split([","], StringSplitOptions.RemoveEmptyEntries);
|
||||||
// 去除前后空格,因为手工修改xml的时候,可能在逗号后加上空格
|
// 去除前后空格,因为手工修改xml的时候,可能在逗号后加上空格
|
||||||
for (var i = 0; i < ss.Length; i++)
|
for (var i = 0; i < ss.Length; i++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -103,7 +103,7 @@ class XField : SerializableDataMember, IDataColumn, ICloneable
|
||||||
[XmlAttribute]
|
[XmlAttribute]
|
||||||
[DisplayName("是否数组")]
|
[DisplayName("是否数组")]
|
||||||
[Description("是否数组")]
|
[Description("是否数组")]
|
||||||
public bool IsArray { get; set; }
|
public Boolean IsArray { get; set; }
|
||||||
|
|
||||||
/// <summary>默认值</summary>
|
/// <summary>默认值</summary>
|
||||||
[XmlAttribute]
|
[XmlAttribute]
|
||||||
|
|
|
@ -55,7 +55,7 @@ class XIndex : SerializableDataMember, IDataIndex, ICloneable
|
||||||
/// <summary>实例化</summary>
|
/// <summary>实例化</summary>
|
||||||
public XIndex()
|
public XIndex()
|
||||||
{
|
{
|
||||||
Columns = new String[0];
|
Columns = [];
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
|
@ -127,7 +127,7 @@ $";
|
||||||
// 分析排序字句,从中分析出分页用的主键
|
// 分析排序字句,从中分析出分页用的主键
|
||||||
if (!value.IsNullOrEmpty() && Key.IsNullOrEmpty())
|
if (!value.IsNullOrEmpty() && Key.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
var p = value.IndexOfAny(new[] { ',', ' ' });
|
var p = value.IndexOfAny([',', ' ']);
|
||||||
if (p > 0)
|
if (p > 0)
|
||||||
Key = value[..p];
|
Key = value[..p];
|
||||||
else
|
else
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class EntityModules : IEnumerable<IEntityModule>
|
||||||
public Type? EntityType { get; set; }
|
public Type? EntityType { get; set; }
|
||||||
|
|
||||||
/// <summary>模块集合</summary>
|
/// <summary>模块集合</summary>
|
||||||
public IEntityModule[] Modules { get; set; } = new IEntityModule[0];
|
public IEntityModule[] Modules { get; set; } = [];
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 构造
|
#region 构造
|
||||||
|
|
|
@ -1225,7 +1225,7 @@ public partial class Area : Entity<Area>
|
||||||
Level = 4;
|
Level = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static readonly String[] minzu = new String[] { "汉族", "壮族", "满族", "回族", "苗族", "维吾尔族", "土家族", "彝族", "蒙古族", "藏族", "布依族", "侗族", "瑶族", "朝鲜族", "白族", "哈尼族", "哈萨克族", "黎族", "傣族", "畲族", "傈僳族", "仡佬族", "东乡族", "高山族", "拉祜族", "水族", "佤族", "纳西族", "羌族", "土族", "仫佬族", "锡伯族", "柯尔克孜族", "达斡尔族", "景颇族", "毛南族", "撒拉族", "布朗族", "塔吉克族", "阿昌族", "普米族", "鄂温克族", "怒族", "京族", "基诺族", "德昂族", "保安族", "俄罗斯族", "裕固族", "乌孜别克族", "门巴族", "鄂伦春族", "独龙族", "塔塔尔族", "赫哲族", "珞巴族" };
|
private static readonly String[] minzu = ["汉族", "壮族", "满族", "回族", "苗族", "维吾尔族", "土家族", "彝族", "蒙古族", "藏族", "布依族", "侗族", "瑶族", "朝鲜族", "白族", "哈尼族", "哈萨克族", "黎族", "傣族", "畲族", "傈僳族", "仡佬族", "东乡族", "高山族", "拉祜族", "水族", "佤族", "纳西族", "羌族", "土族", "仫佬族", "锡伯族", "柯尔克孜族", "达斡尔族", "景颇族", "毛南族", "撒拉族", "布朗族", "塔吉克族", "阿昌族", "普米族", "鄂温克族", "怒族", "京族", "基诺族", "德昂族", "保安族", "俄罗斯族", "裕固族", "乌孜别克族", "门巴族", "鄂伦春族", "独龙族", "塔塔尔族", "赫哲族", "珞巴族"];
|
||||||
|
|
||||||
private static readonly Dictionary<String, String> _map = new()
|
private static readonly Dictionary<String, String> _map = new()
|
||||||
{
|
{
|
||||||
|
|
|
@ -93,7 +93,7 @@ public class WhereBuilder
|
||||||
// StartSiteId in {#SiteIds} or CityId={#CityId}
|
// StartSiteId in {#SiteIds} or CityId={#CityId}
|
||||||
|
|
||||||
// 解析表达式
|
// 解析表达式
|
||||||
var model = Parse(exp, new[] { "==", "!=", "<>", "=", " in" });
|
var model = Parse(exp, ["==", "!=", "<>", "=", " in"]);
|
||||||
if (model != null)
|
if (model != null)
|
||||||
{
|
{
|
||||||
switch (model.Action)
|
switch (model.Action)
|
||||||
|
@ -222,7 +222,7 @@ public class WhereBuilder
|
||||||
|
|
||||||
// 等号运算
|
// 等号运算
|
||||||
// 解析表达式
|
// 解析表达式
|
||||||
var model = Parse(exp, new[] { "==", "!=", "<>", "=", " in" });
|
var model = Parse(exp, ["==", "!=", "<>", "=", " in"]);
|
||||||
if (model != null)
|
if (model != null)
|
||||||
{
|
{
|
||||||
var eval = entity[model.Field.Name];
|
var eval = entity[model.Field.Name];
|
||||||
|
|
|
@ -372,7 +372,7 @@ public abstract partial class EntityTree<TKey, TEntity> : Entity<TEntity>, IEnti
|
||||||
{
|
{
|
||||||
if (String.IsNullOrEmpty(Setting.Name)) return null;
|
if (String.IsNullOrEmpty(Setting.Name)) return null;
|
||||||
|
|
||||||
keys = new String[] { Setting.Name };
|
keys = [Setting.Name];
|
||||||
}
|
}
|
||||||
|
|
||||||
//var list = Childs;
|
//var list = Childs;
|
||||||
|
@ -383,7 +383,7 @@ public abstract partial class EntityTree<TKey, TEntity> : Entity<TEntity>, IEnti
|
||||||
//TEntity entity = list.Find(name, path);
|
//TEntity entity = list.Find(name, path);
|
||||||
//if (entity != null) return entity;
|
//if (entity != null) return entity;
|
||||||
|
|
||||||
var ss = path.Split(new Char[] { '.', '/', '\\' }, StringSplitOptions.RemoveEmptyEntries);
|
var ss = path.Split(['.', '/', '\\'], StringSplitOptions.RemoveEmptyEntries);
|
||||||
if (ss == null || ss.Length <= 0) return null;
|
if (ss == null || ss.Length <= 0) return null;
|
||||||
|
|
||||||
// 找第一级
|
// 找第一级
|
||||||
|
|
|
@ -76,7 +76,8 @@ public class MySqlTests
|
||||||
var connstr = db.ConnectionString;
|
var connstr = db.ConnectionString;
|
||||||
Assert.Equal("sys", db.DatabaseName);
|
Assert.Equal("sys", db.DatabaseName);
|
||||||
//Assert.EndsWith("CharSet=utf8mb4;Sslmode=none;AllowPublicKeyRetrieval=true", connstr);
|
//Assert.EndsWith("CharSet=utf8mb4;Sslmode=none;AllowPublicKeyRetrieval=true", connstr);
|
||||||
Assert.EndsWith("CharSet=utf8mb4;Sslmode=none", connstr);
|
//Assert.EndsWith("CharSet=utf8mb4;Sslmode=none", connstr);
|
||||||
|
Assert.EndsWith("sslmode=none;CharSet=utf8mb4", connstr);
|
||||||
|
|
||||||
using var conn = db.OpenConnection();
|
using var conn = db.OpenConnection();
|
||||||
connstr = conn.ConnectionString;
|
connstr = conn.ConnectionString;
|
||||||
|
|
|
@ -258,7 +258,7 @@ public class AreaTests
|
||||||
await http.DownloadFileAsync(url, file);
|
await http.DownloadFileAsync(url, file);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Area.Meta.Session.Truncate();
|
Area.Meta.Session.Truncate();
|
||||||
var rs = Area.Import(file, true, 3, false);
|
var rs = Area.Import(file, true, 3, false);
|
||||||
Assert.Equal(3624, rs);
|
Assert.Equal(3624, rs);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue