Browse Source

Update Core

pull/10/MERGE
sunkaixuna 3 years ago
parent
commit
dc2f09549b
  1. 49
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/AdoProvider/AdoProvider.cs
  2. 2
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/DbBindProvider/DbBindProvider.cs
  3. 22
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/DeleteProvider/DeleteableProvider.cs
  4. 5
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/DistributedSystem/Snowflake/IdWorker.cs
  5. 32
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/DistributedSystem/Snowflake/SnowFlakeSingle.cs
  6. 24
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve.cs
  7. 16
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Interface/IAdo.cs
  8. 2
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Realization/Oracle/DbBind/OracleDbBind.cs
  9. 4
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/SimpleClient.cs

49
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/AdoProvider/AdoProvider.cs

@ -1500,54 +1500,5 @@ namespace SqlSugar
return result;
}
#endregion
#region Obsolete
[Obsolete]
public virtual dynamic SqlQueryDynamic(string sql, object parameters = null)
{
var dt = this.GetDataTable(sql, parameters);
return dt == null ? null : this.Context.Utilities.DataTableToDynamic(dt);
}
[Obsolete]
public virtual dynamic SqlQueryDynamic(string sql, params SugarParameter[] parameters)
{
var dt = this.GetDataTable(sql, parameters);
return dt == null ? null : this.Context.Utilities.DataTableToDynamic(dt);
}
[Obsolete]
public dynamic SqlQueryDynamic(string sql, List<SugarParameter> parameters)
{
var dt = this.GetDataTable(sql, parameters);
return dt == null ? null : this.Context.Utilities.DataTableToDynamic(dt);
}
[Obsolete]
public void UseStoredProcedure(Action action)
{
var oldCommandType = this.CommandType;
this.CommandType = CommandType.StoredProcedure;
this.IsClearParameters = false;
if (action != null)
{
action();
}
this.CommandType = oldCommandType;
this.IsClearParameters = true;
}
[Obsolete]
public T UseStoredProcedure<T>(Func<T> action)
{
T result = default(T);
var oldCommandType = this.CommandType;
this.CommandType = CommandType.StoredProcedure;
this.IsClearParameters = false;
if (action != null)
{
result = action();
}
this.CommandType = oldCommandType;
this.IsClearParameters = true;
return result;
}
#endregion
}
}

2
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/DbBindProvider/DbBindProvider.cs

@ -314,7 +314,7 @@ namespace SqlSugar
{
get
{
return new List<string>() { "int32", "datetime", "decimal", "double", "byte", "guid" };
return new List<string>() { "int32", "datetime", "decimal", "double", "byte" };
}
}
#endregion

22
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/DeleteProvider/DeleteableProvider.cs

@ -140,17 +140,33 @@ namespace SqlSugar
var entityPropertyName = this.Context.EntityMaintenance.GetPropertyName<T>(primaryField);
var columnInfo = EntityInfo.Columns.Single(it => it.PropertyName == entityPropertyName);
var entityValue = columnInfo.PropertyInfo.GetValue(deleteObj, null);
var tempequals = DeleteBuilder.WhereInEqualTemplate;
if (this.Context.CurrentConnectionConfig.MoreSettings != null && this.Context.CurrentConnectionConfig.MoreSettings.DisableNvarchar == true)
{
tempequals = "\"{0}\"='{1}' ";
}
if (this.Context.CurrentConnectionConfig.DbType == DbType.Oracle)
{
andString.AppendFormat(DeleteBuilder.WhereInEqualTemplate, primaryField.ToUpper(), entityValue);
if (entityValue != null && UtilMethods.GetUnderType(entityValue.GetType()) == UtilConstants.DateType)
{
andString.AppendFormat("\"{0}\"={1} ", primaryField.ToUpper(), "to_date('" + entityValue.ObjToDate().ToString("yyyy-MM-dd HH:mm:ss") + "', 'YYYY-MM-DD HH24:MI:SS') ");
}
else
{
andString.AppendFormat(tempequals, primaryField.ToUpper(), entityValue);
}
}
else if (this.Context.CurrentConnectionConfig.DbType == DbType.PostgreSQL&& (this.Context.CurrentConnectionConfig.MoreSettings==null||this.Context.CurrentConnectionConfig.MoreSettings?.PgSqlIsAutoToLower==true))
else if (this.Context.CurrentConnectionConfig.DbType == DbType.PostgreSQL && (this.Context.CurrentConnectionConfig.MoreSettings == null || this.Context.CurrentConnectionConfig.MoreSettings?.PgSqlIsAutoToLower == true))
{
andString.AppendFormat("\"{0}\"={1} ", primaryField.ToLower(), new PostgreSQLExpressionContext().GetValue(entityValue));
}
else if (this.Context.CurrentConnectionConfig.DbType == DbType.SqlServer && entityValue != null && UtilMethods.GetUnderType(entityValue.GetType()) == UtilConstants.DateType)
{
andString.AppendFormat("\"{0}\"={1} ", primaryField,$"'{entityValue.ObjToDate().ToString("yyyy-MM-dd HH:mm:ss.fff")}'");
}
else
{
andString.AppendFormat(DeleteBuilder.WhereInEqualTemplate, primaryField, entityValue);
andString.AppendFormat(tempequals, primaryField, entityValue);
}
++i;
}

5
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/DistributedSystem/Snowflake/IdWorker.cs

@ -65,7 +65,10 @@ namespace SqlSugar.DistributedSystem.Snowflake
// def get_timestamp() = System.currentTimeMillis
readonly object _lock = new Object();
public long getID()
{
return NextId();
}
public virtual long NextId()
{
lock(_lock)

32
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/DistributedSystem/Snowflake/SnowFlakeSingle.cs

@ -8,22 +8,38 @@ namespace SqlSugar
{
public sealed class SnowFlakeSingle
{
public static readonly SnowFlakeSingle instance = new SnowFlakeSingle();
private static object LockObject = new object();
private static DistributedSystem.Snowflake.IdWorker worker;
public static int WorkId = 1;
public static int DatacenterId = 1;
private SnowFlakeSingle()
{
worker = new DistributedSystem.Snowflake.IdWorker(WorkId, DatacenterId);
}
static SnowFlakeSingle() { }
public static SnowFlakeSingle Instance
public static DistributedSystem.Snowflake.IdWorker Instance
{
get { return instance; }
get
{
if (worker == null)
{
lock (LockObject)
{
if (worker == null)
{
worker = new DistributedSystem.Snowflake.IdWorker(WorkId, DatacenterId);
}
}
}
return worker;
}
}
private DistributedSystem.Snowflake.IdWorker worker;
public long getID()
{
return worker.NextId();
public static DistributedSystem.Snowflake.IdWorker instance
{
get
{
return Instance;
}
}
}
}

24
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve.cs

@ -878,6 +878,30 @@ namespace SqlSugar
public string GeDateFormat(string formatString, string value)
{
if (IsOracle())
{
return $"to_char({value},'{formatString}') ";
}
else if (IsMySql()&& formatString == "yyyy-MM-dd")
{
return $"DATE_FORMAT({value}, '%Y-%m-%d')";
}
else if (formatString == "yyyy-MM-dd" && IsSqlServer())
{
return $"CONVERT(varchar(100),convert(datetime,{value}), 23)";
}
else if (formatString == "yyyy-MM-dd HH:mm:ss" && IsSqlServer())
{
return $"CONVERT(varchar(100),convert(datetime,{value}), 120)";
}
else if (formatString == "yyyy-MM-dd hh:mm:ss" && IsSqlServer())
{
return $"CONVERT(varchar(100),convert(datetime,{value}), 120)";
}
else if (formatString == "yyyy-MM-dd hh:mm:ss.ms" && IsSqlServer())
{
return $"CONVERT(varchar(100),convert(datetime,{value}), 121)";
}
var parameter = new MethodCallExpressionArgs() { IsMember = true, MemberValue = DateType.Year };
var parameter2 = new MethodCallExpressionArgs() { IsMember = true, MemberName = value };
var parameters = new MethodCallExpressionModel() { Args = new List<MethodCallExpressionArgs>() { parameter2, parameter } };

16
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Interface/IAdo.cs

@ -177,20 +177,6 @@ namespace SqlSugar
Task<DbResult<bool>> UseTranAsync(Func<Task> action, Action<Exception> errorCallBack = null);
Task<DbResult<T>> UseTranAsync<T>(Func<Task<T>> action, Action<Exception> errorCallBack = null);
IAdo UseStoredProcedure();
#region Obsolete
[Obsolete("Use db.ado.UseStoredProcedure().MethodName()")]
void UseStoredProcedure(Action action);
[Obsolete("Use db.ado.UseStoredProcedure().MethodName()")]
T UseStoredProcedure<T>(Func<T> action);
[Obsolete("Use SqlQuery<dynamic>(sql)")]
dynamic SqlQueryDynamic(string sql, object whereObj = null);
[Obsolete("Use SqlQuery<dynamic>(sql)")]
dynamic SqlQueryDynamic(string sql, params SugarParameter[] parameters);
[Obsolete("Use SqlQuery<dynamic>(sql)")]
dynamic SqlQueryDynamic(string sql, List<SugarParameter> parameters);
#endregion
}
}

2
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Realization/Oracle/DbBind/OracleDbBind.cs

@ -18,6 +18,8 @@ namespace SqlSugar
csharpTypeName = "long";
if (csharpTypeName.ToLower().IsIn("boolean", "bool"))
csharpTypeName = "bool";
if (csharpTypeName == "Guid")
csharpTypeName = "string";
var mappings = this.MappingTypes.Where(it => it.Value.ToString().Equals(csharpTypeName, StringComparison.CurrentCultureIgnoreCase));
return mappings.HasValue() ? mappings.First().Key : "varchar";
}

4
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/SimpleClient.cs

@ -327,8 +327,6 @@ namespace SqlSugar
return await this.Context.Deleteable<T>().In(ids).ExecuteCommandAsync() > 0;
}
#endregion
[Obsolete("Use AsSugarClient()")]
public ISqlSugarClient FullClient { get { return this.Context; } }
}
}

Loading…
Cancel
Save