mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-24 18:04:52 +08:00
Update Core
This commit is contained in:
parent
71fd340f69
commit
dc2f09549b
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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 } };
|
||||
|
@ -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
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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";
|
||||
}
|
||||
|
@ -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…
Reference in New Issue
Block a user