mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-07-15 14:04:44 +08:00
Update Core
This commit is contained in:
parent
7f5542c3e5
commit
1a63ccd707
@ -14,10 +14,10 @@ namespace SqlSugar
|
|||||||
void ChangeDatabase(dynamic configId);
|
void ChangeDatabase(dynamic configId);
|
||||||
void ChangeDatabase(Func<ConnectionConfig, bool> changeExpression);
|
void ChangeDatabase(Func<ConnectionConfig, bool> changeExpression);
|
||||||
DbResult<bool> UseTran(Action action, Action<Exception> errorCallBack = null);
|
DbResult<bool> UseTran(Action action, Action<Exception> errorCallBack = null);
|
||||||
Task<DbResult<bool>> UseTranAsync(Action action, Action<Exception> errorCallBack = null);
|
Task<DbResult<bool>> UseTranAsync(Func<Task> action, Action<Exception> errorCallBack = null);
|
||||||
DbResult<T> UseTran<T>(Func<T> action, Action<Exception> errorCallBack = null);
|
DbResult<T> UseTran<T>(Func<T> action, Action<Exception> errorCallBack = null);
|
||||||
|
|
||||||
Task<DbResult<T>> UseTranAsync<T>(Func<T> action, Action<Exception> errorCallBack = null);
|
Task<DbResult<T>> UseTranAsync<T>(Func<Task<T>> action, Action<Exception> errorCallBack = null);
|
||||||
void AddConnection(ConnectionConfig connection);
|
void AddConnection(ConnectionConfig connection);
|
||||||
SqlSugarProvider GetConnection(dynamic configId);
|
SqlSugarProvider GetConnection(dynamic configId);
|
||||||
bool IsAnyConnection(dynamic configId);
|
bool IsAnyConnection(dynamic configId);
|
||||||
|
@ -35,7 +35,7 @@ namespace SqlSugar
|
|||||||
numeric_scale as Scale,
|
numeric_scale as Scale,
|
||||||
numeric_scale as DecimalDigits
|
numeric_scale as DecimalDigits
|
||||||
FROM
|
FROM
|
||||||
Information_schema.columns where TABLE_NAME='{0}' and TABLE_SCHEMA=(select database()) ORDER BY TABLE_NAME";
|
Information_schema.columns where TABLE_NAME='{0}' and TABLE_SCHEMA=(select database()) ORDER BY ordinal_position";
|
||||||
return sql;
|
return sql;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -63,7 +63,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return "CREATE DATABASE {0} CHARACTER SET utf8 COLLATE utf8_general_ci ";
|
return "CREATE DATABASE `{0}` CHARACTER SET utf8 COLLATE utf8_general_ci ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected override string AddPrimaryKeySql
|
protected override string AddPrimaryKeySql
|
||||||
@ -252,7 +252,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return "CREATE {3} INDEX Index_{0}_{2} ON {0} ({1})";
|
return "CREATE {3} INDEX `Index_{0}_{2}` ON `{0}` ({1})";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Data.Common;
|
using System.Data.Common;
|
||||||
using Microsoft.Data.SqlClient;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@ -111,12 +111,12 @@ namespace SqlSugar
|
|||||||
new KeyValuePair<string, CSharpDataType>("timestamp",CSharpDataType.DateTime),
|
new KeyValuePair<string, CSharpDataType>("timestamp",CSharpDataType.DateTime),
|
||||||
new KeyValuePair<string, CSharpDataType>("timestamp with local time zone",CSharpDataType.DateTime),
|
new KeyValuePair<string, CSharpDataType>("timestamp with local time zone",CSharpDataType.DateTime),
|
||||||
new KeyValuePair<string, CSharpDataType>("timestamp with time zone",CSharpDataType.DateTime),
|
new KeyValuePair<string, CSharpDataType>("timestamp with time zone",CSharpDataType.DateTime),
|
||||||
new KeyValuePair<string, CSharpDataType>("timestamp with time zone",CSharpDataType.DateTime),
|
|
||||||
|
|
||||||
new KeyValuePair<string, CSharpDataType>("float",CSharpDataType.@decimal),
|
new KeyValuePair<string, CSharpDataType>("float",CSharpDataType.@decimal),
|
||||||
|
|
||||||
new KeyValuePair<string, CSharpDataType>("blob",CSharpDataType.byteArray),
|
new KeyValuePair<string, CSharpDataType>("blob",CSharpDataType.byteArray),
|
||||||
new KeyValuePair<string, CSharpDataType>("long raw",CSharpDataType.byteArray),
|
new KeyValuePair<string, CSharpDataType>("long raw",CSharpDataType.byteArray),
|
||||||
|
new KeyValuePair<string, CSharpDataType>("longraw",CSharpDataType.byteArray),
|
||||||
new KeyValuePair<string, CSharpDataType>("raw",CSharpDataType.byteArray),
|
new KeyValuePair<string, CSharpDataType>("raw",CSharpDataType.byteArray),
|
||||||
new KeyValuePair<string, CSharpDataType>("bfile",CSharpDataType.byteArray),
|
new KeyValuePair<string, CSharpDataType>("bfile",CSharpDataType.byteArray),
|
||||||
new KeyValuePair<string, CSharpDataType>("varbinary",CSharpDataType.byteArray) };
|
new KeyValuePair<string, CSharpDataType>("varbinary",CSharpDataType.byteArray) };
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
using Oracle.ManagedDataAccess.Client;
|
using Oracle.ManagedDataAccess.Client;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Data.Common;
|
using System.Data.Common;
|
||||||
using Microsoft.Data.SqlClient;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
@ -88,6 +87,7 @@ namespace SqlSugar
|
|||||||
sqlCommand.BindByName = true;
|
sqlCommand.BindByName = true;
|
||||||
sqlCommand.CommandType = this.CommandType;
|
sqlCommand.CommandType = this.CommandType;
|
||||||
sqlCommand.CommandTimeout = this.CommandTimeOut;
|
sqlCommand.CommandTimeout = this.CommandTimeOut;
|
||||||
|
sqlCommand.InitialLONGFetchSize = -1;
|
||||||
if (this.Transaction != null)
|
if (this.Transaction != null)
|
||||||
{
|
{
|
||||||
sqlCommand.Transaction = (OracleTransaction)this.Transaction;
|
sqlCommand.Transaction = (OracleTransaction)this.Transaction;
|
||||||
|
@ -21,8 +21,10 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
string sql = @"select cast (pclass.oid as int4) as TableId,cast(ptables.tablename as varchar) as TableName,
|
string sql = @"select cast (pclass.oid as int4) as TableId,cast(ptables.tablename as varchar) as TableName,
|
||||||
pcolumn.column_name as DbColumnName,pcolumn.udt_name as DataType,
|
pcolumn.column_name as DbColumnName,pcolumn.udt_name as DataType,
|
||||||
pcolumn.character_maximum_length as Length,
|
CASE WHEN pcolumn.numeric_scale >0 THEN pcolumn.numeric_precision ELSE pcolumn.character_maximum_length END as Length,
|
||||||
pcolumn.column_default as DefaultValue,
|
pcolumn.column_default as DefaultValue,
|
||||||
|
pcolumn.numeric_scale as DecimalDigits,
|
||||||
|
pcolumn.numeric_scale as Scale,
|
||||||
col_description(pclass.oid, pcolumn.ordinal_position) as ColumnDescription,
|
col_description(pclass.oid, pcolumn.ordinal_position) as ColumnDescription,
|
||||||
case when pkey.colname = pcolumn.column_name
|
case when pkey.colname = pcolumn.column_name
|
||||||
then true else false end as IsPrimaryKey,
|
then true else false end as IsPrimaryKey,
|
||||||
|
@ -687,9 +687,29 @@ namespace SqlSugar
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<DbResult<bool>> UseTranAsync(Action action, Action<Exception> errorCallBack = null)
|
public async Task<DbResult<bool>> UseTranAsync(Func<Task> action, Action<Exception> errorCallBack = null)
|
||||||
{
|
{
|
||||||
return Task.FromResult(UseTran(action, errorCallBack));
|
var result = new DbResult<bool>();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
this.BeginTran();
|
||||||
|
if (action != null)
|
||||||
|
await action();
|
||||||
|
this.CommitTran();
|
||||||
|
result.Data = result.IsSuccess = true;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
result.ErrorException = ex;
|
||||||
|
result.ErrorMessage = ex.Message;
|
||||||
|
result.IsSuccess = false;
|
||||||
|
this.RollbackTran();
|
||||||
|
if (errorCallBack != null)
|
||||||
|
{
|
||||||
|
errorCallBack(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DbResult<T> UseTran<T>(Func<T> action, Action<Exception> errorCallBack = null)
|
public DbResult<T> UseTran<T>(Func<T> action, Action<Exception> errorCallBack = null)
|
||||||
@ -717,9 +737,30 @@ namespace SqlSugar
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<DbResult<T>> UseTranAsync<T>(Func<T> action, Action<Exception> errorCallBack = null)
|
public async Task<DbResult<T>> UseTranAsync<T>(Func<Task<T>> action, Action<Exception> errorCallBack = null)
|
||||||
{
|
{
|
||||||
return Task.FromResult(UseTran(action, errorCallBack));
|
var result = new DbResult<T>();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
this.BeginTran();
|
||||||
|
T data=default(T);
|
||||||
|
if (action != null)
|
||||||
|
data = await action();
|
||||||
|
this.CommitTran();
|
||||||
|
result.Data = data;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
result.ErrorException = ex;
|
||||||
|
result.ErrorMessage = ex.Message;
|
||||||
|
result.IsSuccess = false;
|
||||||
|
this.RollbackTran();
|
||||||
|
if (errorCallBack != null)
|
||||||
|
{
|
||||||
|
errorCallBack(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RollbackTran()
|
public void RollbackTran()
|
||||||
|
@ -662,12 +662,12 @@ namespace SqlSugar
|
|||||||
return ScopedContext.UseTran(action,errorCallBack);
|
return ScopedContext.UseTran(action,errorCallBack);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<DbResult<bool>> UseTranAsync(Action action, Action<Exception> errorCallBack = null)
|
public Task<DbResult<bool>> UseTranAsync(Func<Task> action, Action<Exception> errorCallBack = null)
|
||||||
{
|
{
|
||||||
return ScopedContext.UseTranAsync(action, errorCallBack);
|
return ScopedContext.UseTranAsync(action, errorCallBack);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<DbResult<T>> UseTranAsync<T>(Func<T> action, Action<Exception> errorCallBack = null)
|
public Task<DbResult<T>> UseTranAsync<T>(Func<Task<T>> action, Action<Exception> errorCallBack = null)
|
||||||
{
|
{
|
||||||
return ScopedContext.UseTranAsync(action, errorCallBack);
|
return ScopedContext.UseTranAsync(action, errorCallBack);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user