This commit is contained in:
610262374@qq.com
2018-10-08 17:21:13 +08:00
35 changed files with 126 additions and 39 deletions

View File

@@ -8,6 +8,6 @@ namespace OrmTest
{ {
public class Config public class Config
{ {
public static string ConnectionString = "Data Source=SUNKAIXUAN.htinns.loc/ORCL;User ID=system;Password=manager;"; public static string ConnectionString = "Data Source=localhost/orcl;User ID=system;Password=JHL52771jhl;";
} }
} }

View File

@@ -8,8 +8,8 @@ namespace OrmTest
{ {
public class Config public class Config
{ {
public static string ConnectionString = "server=.;uid=sa;pwd=@jhl85661501;database=SqlSugar4XTest"; public static string ConnectionString = "server=.;uid=sa;pwd=sasa;database=SqlSugar4XTest";
public static string ConnectionString2 = "server=.;uid=sa;pwd=@jhl85661501;database=SQLSUGAR4XTEST"; public static string ConnectionString2 = "server=.;uid=sa;pwd=sasa;database=SQLSUGAR4XTEST";
public static string ConnectionString3 = "server=.;uid=sa;pwd=@jhl85661501;database=sqlsugar4xtest"; public static string ConnectionString3 = "server=.;uid=sa;pwd=sasa;database=sqlsugar4xtest";
} }
} }

View File

@@ -1217,6 +1217,7 @@ namespace SqlSugar
asyncQueryableBuilder.GroupByValue = this.QueryBuilder.GroupByValue; asyncQueryableBuilder.GroupByValue = this.QueryBuilder.GroupByValue;
asyncQueryableBuilder.OrderByValue = this.QueryBuilder.OrderByValue; asyncQueryableBuilder.OrderByValue = this.QueryBuilder.OrderByValue;
asyncQueryableBuilder.IsDisabledGobalFilter = this.QueryBuilder.IsDisabledGobalFilter; asyncQueryableBuilder.IsDisabledGobalFilter = this.QueryBuilder.IsDisabledGobalFilter;
asyncQueryableBuilder.PartitionByValue = this.QueryBuilder.PartitionByValue;
return asyncQueryable; return asyncQueryable;
} }
#endregion #endregion

View File

@@ -76,6 +76,15 @@ namespace SqlSugar
return this; return this;
} }
public IUpdateable<T> IgnoreColumns(bool ignoreAllNullColumns, bool isOffIdentity = false)
{
UpdateBuilder.IsOffIdentity = isOffIdentity;
if (this.UpdateBuilder.LambdaExpressions == null)
this.UpdateBuilder.LambdaExpressions = InstanceFactory.GetLambdaExpressions(this.Context.CurrentConnectionConfig);
this.UpdateBuilder.IsNoUpdateNull = ignoreAllNullColumns;
return this;
}
public IUpdateable<T> IgnoreColumns(Expression<Func<T, object>> columns) public IUpdateable<T> IgnoreColumns(Expression<Func<T, object>> columns)
{ {
var ignoreColumns = UpdateBuilder.GetExpressionValue(columns, ResolveExpressType.ArraySingle).GetResultArray().Select(it => this.SqlBuilder.GetNoTranslationColumnName(it)).ToList(); var ignoreColumns = UpdateBuilder.GetExpressionValue(columns, ResolveExpressType.ArraySingle).GetResultArray().Select(it => this.SqlBuilder.GetNoTranslationColumnName(it)).ToList();
@@ -183,6 +192,7 @@ namespace SqlSugar
this.UpdateBuilder.DbColumnInfoList = this.UpdateBuilder.DbColumnInfoList.Where(it => UpdateBuilder.SetValues.Any(v => SqlBuilder.GetNoTranslationColumnName(v.Key).Equals(it.DbColumnName,StringComparison.CurrentCultureIgnoreCase)|| SqlBuilder.GetNoTranslationColumnName(v.Key).Equals(it.PropertyName,StringComparison.CurrentCultureIgnoreCase)) || it.IsPrimarykey == true).ToList(); this.UpdateBuilder.DbColumnInfoList = this.UpdateBuilder.DbColumnInfoList.Where(it => UpdateBuilder.SetValues.Any(v => SqlBuilder.GetNoTranslationColumnName(v.Key).Equals(it.DbColumnName,StringComparison.CurrentCultureIgnoreCase)|| SqlBuilder.GetNoTranslationColumnName(v.Key).Equals(it.PropertyName,StringComparison.CurrentCultureIgnoreCase)) || it.IsPrimarykey == true).ToList();
return this; return this;
} }
[Obsolete("Use IUpdateable<T> IgnoreColumns(bool ignoreAllNullColumns, bool isOffIdentity = false);")]
public IUpdateable<T> Where(bool isUpdateNull, bool IsOffIdentity = false) public IUpdateable<T> Where(bool isUpdateNull, bool IsOffIdentity = false)
{ {

View File

@@ -16,6 +16,7 @@ namespace SqlSugar
Task<bool> ExecuteCommandHasChangeAsync(); Task<bool> ExecuteCommandHasChangeAsync();
IUpdateable<T> AS(string tableName); IUpdateable<T> AS(string tableName);
IUpdateable<T> With(string lockString); IUpdateable<T> With(string lockString);
[Obsolete("Use IUpdateable<T> IgnoreColumns(bool ignoreAllNullColumns, bool isOffIdentity = false);")]
IUpdateable<T> Where(bool isNoUpdateNull,bool IsOffIdentity = false); IUpdateable<T> Where(bool isNoUpdateNull,bool IsOffIdentity = false);
IUpdateable<T> Where(Expression<Func<T, bool>> expression); IUpdateable<T> Where(Expression<Func<T, bool>> expression);
IUpdateable<T> Where(string whereSql,object parameters=null); IUpdateable<T> Where(string whereSql,object parameters=null);
@@ -37,6 +38,7 @@ namespace SqlSugar
IUpdateable<T> UpdateColumns(Expression<Func<T, bool>> columns); IUpdateable<T> UpdateColumns(Expression<Func<T, bool>> columns);
IUpdateable<T> UpdateColumns(Func<string, bool> updateColumMethod); IUpdateable<T> UpdateColumns(Func<string, bool> updateColumMethod);
IUpdateable<T> UpdateColumns(Expression<Func<T, T>> columns); IUpdateable<T> UpdateColumns(Expression<Func<T, T>> columns);
IUpdateable<T> IgnoreColumns(bool ignoreAllNullColumns, bool isOffIdentity = false);
IUpdateable<T> IgnoreColumns(Expression<Func<T, object>> columns); IUpdateable<T> IgnoreColumns(Expression<Func<T, object>> columns);
IUpdateable<T> IgnoreColumns(Func<string, bool> ignoreColumMethod); IUpdateable<T> IgnoreColumns(Func<string, bool> ignoreColumMethod);
IUpdateable<T> ReSetValue(Expression<Func<T, bool>> setValueExpression); IUpdateable<T> ReSetValue(Expression<Func<T, bool>> setValueExpression);

View File

@@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("4.6.4.9")] [assembly: AssemblyVersion("4.7")]
[assembly: AssemblyFileVersion("4.6.4.9")] [assembly: AssemblyFileVersion("4.7")]

View File

@@ -111,7 +111,7 @@ namespace SqlSugar
} }
else if (type == UtilConstants.ByteArrayType) else if (type == UtilConstants.ByteArrayType)
{ {
string bytesString = "0x" + BitConverter.ToString((byte[])value); string bytesString = "0x" + BitConverter.ToString((byte[])value).Replace("-", "");
return bytesString; return bytesString;
} }
else if (type == UtilConstants.BoolType) else if (type == UtilConstants.BoolType)

View File

@@ -60,7 +60,7 @@ namespace SqlSugar
} }
else if (type == UtilConstants.ByteArrayType) else if (type == UtilConstants.ByteArrayType)
{ {
string bytesString = "0x" + BitConverter.ToString((byte[])value); string bytesString = "0x" + BitConverter.ToString((byte[])value).Replace("-", "");
return bytesString; return bytesString;
} }
else if (type == UtilConstants.BoolType) else if (type == UtilConstants.BoolType)

View File

@@ -157,7 +157,7 @@ namespace SqlSugar
var parameter = model.Args[0].MemberName; var parameter = model.Args[0].MemberName;
var parameter2 = model.Args[1].MemberName; var parameter2 = model.Args[1].MemberName;
int time = 1; int time = 1;
return string.Format(" Cast((JulianDay({0}) - JulianDay({1})) *{2} As INTEGER)", parameter, parameter2, time); return string.Format(" Cast((JulianDay({0}) - JulianDay({1})) *{2} As INTEGER)=0 ", parameter, parameter2, time);
} }
public override string DateIsSameByType(MethodCallExpressionModel model) public override string DateIsSameByType(MethodCallExpressionModel model)
{ {

View File

@@ -8,6 +8,6 @@ namespace OrmTest
{ {
public class Config public class Config
{ {
public static string ConnectionString = @"DataSource=D:\MyGit\SqlSugar\Src\Asp.Net\SqliteTest\DataBase\SqlSugar4xTest.sqlite"; public static string ConnectionString = @"DataSource=F:\MyOpenSource\SqlSugar4.XNew\SqlSugar\Src\Asp.Net\SqliteTest\DataBase\SqlSugar4xTest.sqlite";
} }
} }

View File

@@ -356,7 +356,7 @@ namespace OrmTest.UnitTest
expContext.Resolve(exp, ResolveExpressType.WhereSingle); expContext.Resolve(exp, ResolveExpressType.WhereSingle);
var value = expContext.Result.GetString(); var value = expContext.Result.GetString();
var pars = expContext.Parameters; var pars = expContext.Parameters;
base.Check(value, pars, " Cast((JulianDay(@MethodConst0) - JulianDay(@MethodConst1)) *1 As INTEGER)", new List<SugarParameter>() { base.Check(value, pars, " Cast((JulianDay(@MethodConst0) - JulianDay(@MethodConst1)) *1 As INTEGER)=0 ", new List<SugarParameter>() {
new SugarParameter("@MethodConst0",x2),new SugarParameter("@MethodConst1",x2) new SugarParameter("@MethodConst0",x2),new SugarParameter("@MethodConst1",x2)
}, "DateIsSameDay error"); }, "DateIsSameDay error");
} }

View File

@@ -194,6 +194,17 @@ namespace SqlSugar
} }
return result; return result;
} }
public Task<DbResult<bool>> UseTranAsync(Action action)
{
Task<DbResult<bool>> result = new Task<DbResult<bool>>(() =>
{
return UseTran(action);
});
TaskStart(result);
return result;
}
public DbResult<T> UseTran<T>(Func<T> action) public DbResult<T> UseTran<T>(Func<T> action)
{ {
var result = new DbResult<T>(); var result = new DbResult<T>();
@@ -214,6 +225,17 @@ namespace SqlSugar
} }
return result; return result;
} }
public Task<DbResult<T>> UseTranAsync<T>(Func<T> action)
{
Task<DbResult<T>> result = new Task<DbResult<T>>(() =>
{
return UseTran(action);
});
TaskStart(result);
return result;
}
public void UseStoredProcedure(Action action) public void UseStoredProcedure(Action action)
{ {
var oldCommandType = this.CommandType; var oldCommandType = this.CommandType;
@@ -624,6 +646,14 @@ namespace SqlSugar
#endregion #endregion
#region Helper #region Helper
private void TaskStart<Type>(Task<Type> result)
{
if (this.Context.CurrentConnectionConfig.IsShardSameThread)
{
Check.Exception(true, "IsShardSameThread=true can't be used async method");
}
result.Start();
}
private void ExecuteProcessingSQL(ref string sql, SugarParameter[] parameters) private void ExecuteProcessingSQL(ref string sql, SugarParameter[] parameters)
{ {
var result = this.ProcessingEventStartingSQL(sql, parameters); var result = this.ProcessingEventStartingSQL(sql, parameters);

View File

@@ -62,6 +62,10 @@ namespace SqlSugar
IsAs = true; IsAs = true;
OldMappingTableList = this.Context.MappingTables; OldMappingTableList = this.Context.MappingTables;
this.Context.MappingTables = this.Context.Utilities.TranslateCopy(this.Context.MappingTables); this.Context.MappingTables = this.Context.Utilities.TranslateCopy(this.Context.MappingTables);
if (this.Context.MappingTables.Any(it => it.EntityName == entityName))
{
this.Context.MappingTables.Add(this.Context.MappingTables.First(it => it.EntityName == entityName).DbTableName, tableName);
}
this.Context.MappingTables.Add(entityName, tableName); this.Context.MappingTables.Add(entityName, tableName);
return this; ; return this; ;
} }

View File

@@ -145,6 +145,10 @@ namespace SqlSugar
IsAs = true; IsAs = true;
OldMappingTableList = this.Context.MappingTables; OldMappingTableList = this.Context.MappingTables;
this.Context.MappingTables = this.Context.Utilities.TranslateCopy(this.Context.MappingTables); this.Context.MappingTables = this.Context.Utilities.TranslateCopy(this.Context.MappingTables);
if (this.Context.MappingTables.Any(it => it.EntityName == entityName))
{
this.Context.MappingTables.Add(this.Context.MappingTables.First(it => it.EntityName == entityName).DbTableName, tableName);
}
this.Context.MappingTables.Add(entityName, tableName); this.Context.MappingTables.Add(entityName, tableName);
return this; ; return this; ;
} }

View File

@@ -628,7 +628,7 @@ namespace SqlSugar
} }
public ISugarQueryable<T> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue) public ISugarQueryable<T> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue)
{ {
if (IsCache) if (isCache)
{ {
this.IsCache = true; this.IsCache = true;
this.CacheTime = cacheDurationInSeconds; this.CacheTime = cacheDurationInSeconds;
@@ -1019,6 +1019,10 @@ namespace SqlSugar
IsAs = true; IsAs = true;
OldMappingTableList = this.Context.MappingTables; OldMappingTableList = this.Context.MappingTables;
this.Context.MappingTables = this.Context.Utilities.TranslateCopy(this.Context.MappingTables); this.Context.MappingTables = this.Context.Utilities.TranslateCopy(this.Context.MappingTables);
if (this.Context.MappingTables.Any(it => it.EntityName == entityName))
{
this.Context.MappingTables.Add(this.Context.MappingTables.First(it => it.EntityName == entityName).DbTableName, tableName);
}
this.Context.MappingTables.Add(entityName, tableName); this.Context.MappingTables.Add(entityName, tableName);
this.QueryableMappingTableList = this.Context.MappingTables; this.QueryableMappingTableList = this.Context.MappingTables;
return this; return this;
@@ -1212,6 +1216,8 @@ namespace SqlSugar
asyncQueryableBuilder.TableWithString = this.QueryBuilder.TableWithString; asyncQueryableBuilder.TableWithString = this.QueryBuilder.TableWithString;
asyncQueryableBuilder.GroupByValue = this.QueryBuilder.GroupByValue; asyncQueryableBuilder.GroupByValue = this.QueryBuilder.GroupByValue;
asyncQueryableBuilder.OrderByValue = this.QueryBuilder.OrderByValue; asyncQueryableBuilder.OrderByValue = this.QueryBuilder.OrderByValue;
asyncQueryableBuilder.IsDisabledGobalFilter = this.QueryBuilder.IsDisabledGobalFilter;
asyncQueryableBuilder.PartitionByValue = this.QueryBuilder.PartitionByValue;
return asyncQueryable; return asyncQueryable;
} }
#endregion #endregion

View File

@@ -169,7 +169,7 @@ namespace SqlSugar
} }
else if (type == UtilConstants.ByteArrayType) else if (type == UtilConstants.ByteArrayType)
{ {
string bytesString = "0x" + BitConverter.ToString((byte[])value); string bytesString = "0x" + BitConverter.ToString((byte[])value).Replace("-", "");
return bytesString; return bytesString;
} }
else if (type.IsEnum()) else if (type.IsEnum())

View File

@@ -262,7 +262,7 @@ namespace SqlSugar
} }
else if (type == UtilConstants.ByteArrayType) else if (type == UtilConstants.ByteArrayType)
{ {
string bytesString = "0x" + BitConverter.ToString((byte[])value); string bytesString = "0x" + BitConverter.ToString((byte[])value).Replace("-", "");
return bytesString; return bytesString;
} }
else if (type.IsEnum()) else if (type.IsEnum())

View File

@@ -64,25 +64,27 @@ namespace SqlSugar
IsAs = true; IsAs = true;
OldMappingTableList = this.Context.MappingTables; OldMappingTableList = this.Context.MappingTables;
this.Context.MappingTables = this.Context.Utilities.TranslateCopy(this.Context.MappingTables); this.Context.MappingTables = this.Context.Utilities.TranslateCopy(this.Context.MappingTables);
if (this.Context.MappingTables.Any(it => it.EntityName == entityName)) {
this.Context.MappingTables.Add(this.Context.MappingTables.First(it => it.EntityName == entityName).DbTableName, tableName);
}
this.Context.MappingTables.Add(entityName, tableName); this.Context.MappingTables.Add(entityName, tableName);
return this; ; return this; ;
} }
public IUpdateable<T> IgnoreColumns(bool IgnoreAllNullColumns, bool IsOffIdentity = false)
{
UpdateBuilder.IsOffIdentity = IsOffIdentity;
if (this.UpdateBuilder.LambdaExpressions == null)
this.UpdateBuilder.LambdaExpressions = InstanceFactory.GetLambdaExpressions(this.Context.CurrentConnectionConfig);
this.UpdateBuilder.IsNoUpdateNull = IgnoreAllNullColumns;
return this;
}
public IUpdateable<T> IgnoreColumns(Func<string, bool> ignoreColumMethod) public IUpdateable<T> IgnoreColumns(Func<string, bool> ignoreColumMethod)
{ {
this.UpdateBuilder.DbColumnInfoList = this.UpdateBuilder.DbColumnInfoList.Where(it => !ignoreColumMethod(it.PropertyName)).ToList(); this.UpdateBuilder.DbColumnInfoList = this.UpdateBuilder.DbColumnInfoList.Where(it => !ignoreColumMethod(it.PropertyName)).ToList();
return this; return this;
} }
public IUpdateable<T> IgnoreColumns(bool ignoreAllNullColumns, bool isOffIdentity = false)
{
UpdateBuilder.IsOffIdentity = isOffIdentity;
if (this.UpdateBuilder.LambdaExpressions == null)
this.UpdateBuilder.LambdaExpressions = InstanceFactory.GetLambdaExpressions(this.Context.CurrentConnectionConfig);
this.UpdateBuilder.IsNoUpdateNull = ignoreAllNullColumns;
return this;
}
public IUpdateable<T> IgnoreColumns(Expression<Func<T, object>> columns) public IUpdateable<T> IgnoreColumns(Expression<Func<T, object>> columns)
{ {
var ignoreColumns = UpdateBuilder.GetExpressionValue(columns, ResolveExpressType.ArraySingle).GetResultArray().Select(it => this.SqlBuilder.GetNoTranslationColumnName(it)).ToList(); var ignoreColumns = UpdateBuilder.GetExpressionValue(columns, ResolveExpressType.ArraySingle).GetResultArray().Select(it => this.SqlBuilder.GetNoTranslationColumnName(it)).ToList();
@@ -190,8 +192,8 @@ namespace SqlSugar
this.UpdateBuilder.DbColumnInfoList = this.UpdateBuilder.DbColumnInfoList.Where(it => UpdateBuilder.SetValues.Any(v => SqlBuilder.GetNoTranslationColumnName(v.Key).Equals(it.DbColumnName,StringComparison.CurrentCultureIgnoreCase)|| SqlBuilder.GetNoTranslationColumnName(v.Key).Equals(it.PropertyName,StringComparison.CurrentCultureIgnoreCase)) || it.IsPrimarykey == true).ToList(); this.UpdateBuilder.DbColumnInfoList = this.UpdateBuilder.DbColumnInfoList.Where(it => UpdateBuilder.SetValues.Any(v => SqlBuilder.GetNoTranslationColumnName(v.Key).Equals(it.DbColumnName,StringComparison.CurrentCultureIgnoreCase)|| SqlBuilder.GetNoTranslationColumnName(v.Key).Equals(it.PropertyName,StringComparison.CurrentCultureIgnoreCase)) || it.IsPrimarykey == true).ToList();
return this; return this;
} }
[Obsolete("Use IUpdateable<T> IgnoreColumns(bool ignoreAllNullColumns, bool isOffIdentity = false);")]
[Obsolete]
public IUpdateable<T> Where(bool isUpdateNull, bool IsOffIdentity = false) public IUpdateable<T> Where(bool isUpdateNull, bool IsOffIdentity = false)
{ {
UpdateBuilder.IsOffIdentity = IsOffIdentity; UpdateBuilder.IsOffIdentity = IsOffIdentity;
@@ -200,7 +202,6 @@ namespace SqlSugar
this.UpdateBuilder.IsNoUpdateNull = isUpdateNull; this.UpdateBuilder.IsNoUpdateNull = isUpdateNull;
return this; return this;
} }
public IUpdateable<T> Where(Expression<Func<T, bool>> expression) public IUpdateable<T> Where(Expression<Func<T, bool>> expression)
{ {
var expResult = UpdateBuilder.GetExpressionValue(expression, ResolveExpressType.WhereSingle); var expResult = UpdateBuilder.GetExpressionValue(expression, ResolveExpressType.WhereSingle);
@@ -294,6 +295,7 @@ namespace SqlSugar
{ {
foreach (var column in EntityInfo.Columns) foreach (var column in EntityInfo.Columns)
{ {
if (column.IsIgnore) continue;
var columnInfo = new DbColumnInfo() var columnInfo = new DbColumnInfo()
{ {
Value = column.PropertyInfo.GetValue(item, null), Value = column.PropertyInfo.GetValue(item, null),

View File

@@ -325,6 +325,11 @@ namespace SqlSugar
return "GETDATE()"; return "GETDATE()";
} }
public virtual string GetRandom()
{
return "NEWID()";
}
public virtual string CaseWhen(List<KeyValuePair<string, string>> sqls) public virtual string CaseWhen(List<KeyValuePair<string, string>> sqls)
{ {
StringBuilder reslut = new StringBuilder(); StringBuilder reslut = new StringBuilder();

View File

@@ -59,5 +59,6 @@ namespace SqlSugar
string Pack(string sql); string Pack(string sql);
string Null(); string Null();
string GetDate(); string GetDate();
string GetRandom();
} }
} }

View File

@@ -110,6 +110,7 @@ namespace SqlSugar
/// <returns></returns> /// <returns></returns>
public static TResult GetSelfAndAutoFill<TResult>(TResult value) { throw new NotSupportedException("Can only be used in expressions"); } public static TResult GetSelfAndAutoFill<TResult>(TResult value) { throw new NotSupportedException("Can only be used in expressions"); }
public static DateTime GetDate() { throw new NotSupportedException("Can only be used in expressions"); } public static DateTime GetDate() { throw new NotSupportedException("Can only be used in expressions"); }
public static string GetRandom() { throw new NotSupportedException("Can only be used in expressions"); }
/// <summary> /// <summary>
/// Subquery /// Subquery
/// </summary> /// </summary>

View File

@@ -504,6 +504,8 @@ namespace SqlSugar
return this.Context.DbMehtods.GetSelfAndAutoFill(model.Args[0].MemberValue.ObjToString(), this.Context.IsSingle); return this.Context.DbMehtods.GetSelfAndAutoFill(model.Args[0].MemberValue.ObjToString(), this.Context.IsSingle);
case "GetDate": case "GetDate":
return this.Context.DbMehtods.GetDate(); return this.Context.DbMehtods.GetDate();
case "GetRandom":
return this.Context.DbMehtods.GetRandom();
default: default:
break; break;
} }

View File

@@ -40,7 +40,7 @@ namespace SqlSugar
{ {
var exp = expression as MethodCallExpression; var exp = expression as MethodCallExpression;
var argExp= exp.Arguments[0]; var argExp= exp.Arguments[0];
var result= "WHERE "+SubTools.GetMethodValue(Context, argExp, ResolveExpressType.WhereMultiple); var result= "WHERE "+SubTools.GetMethodValue(Context, argExp, ResolveExpressType.WhereMultiple);;
var selfParameterName = Context.GetTranslationColumnName((argExp as LambdaExpression).Parameters.First().Name)+UtilConstants.Dot; var selfParameterName = Context.GetTranslationColumnName((argExp as LambdaExpression).Parameters.First().Name)+UtilConstants.Dot;
result = result.Replace(selfParameterName,string.Empty); result = result.Replace(selfParameterName,string.Empty);
return result; return result;

View File

@@ -278,6 +278,7 @@ namespace SqlSugar
newClient.Ado.LogEventStarting = Context.Ado.LogEventStarting; newClient.Ado.LogEventStarting = Context.Ado.LogEventStarting;
newClient.Ado.LogEventCompleted = Context.Ado.LogEventCompleted; newClient.Ado.LogEventCompleted = Context.Ado.LogEventCompleted;
newClient.Ado.ProcessingEventStartingSQL = Context.Ado.ProcessingEventStartingSQL; newClient.Ado.ProcessingEventStartingSQL = Context.Ado.ProcessingEventStartingSQL;
newClient.QueryFilter = Context.QueryFilter;
} }
return newClient; return newClient;
} }

View File

@@ -14,7 +14,7 @@ namespace SqlSugar
{ {
get get
{ {
var result = _Context; var result = _Context; ;
if (CurrentConnectionConfig.IsShardSameThread) if (CurrentConnectionConfig.IsShardSameThread)
{ {
if (CallContext.ContextList.Value.IsNullOrEmpty()) if (CallContext.ContextList.Value.IsNullOrEmpty())
@@ -268,7 +268,7 @@ namespace SqlSugar
protected InsertableProvider<T> CreateInsertable<T>(T[] insertObjs) where T : class, new() protected InsertableProvider<T> CreateInsertable<T>(T[] insertObjs) where T : class, new()
{ {
var result = InstanceFactory.GetInsertableProvider<T>(this.CurrentConnectionConfig); var result = InstanceFactory.GetInsertableProvider<T>(this.CurrentConnectionConfig);
var sqlBuilder = InstanceFactory.GetSqlbuilder(this.CurrentConnectionConfig); var sqlBuilder = InstanceFactory.GetSqlbuilder(this.CurrentConnectionConfig); ;
result.Context = this.Context; result.Context = this.Context;
result.EntityInfo = this.Context.EntityMaintenance.GetEntityInfo<T>(); result.EntityInfo = this.Context.EntityMaintenance.GetEntityInfo<T>();
result.SqlBuilder = sqlBuilder; result.SqlBuilder = sqlBuilder;
@@ -283,7 +283,7 @@ namespace SqlSugar
protected DeleteableProvider<T> CreateDeleteable<T>() where T : class, new() protected DeleteableProvider<T> CreateDeleteable<T>() where T : class, new()
{ {
var result = InstanceFactory.GetDeleteableProvider<T>(this.CurrentConnectionConfig); var result = InstanceFactory.GetDeleteableProvider<T>(this.CurrentConnectionConfig);
var sqlBuilder = InstanceFactory.GetSqlbuilder(this.CurrentConnectionConfig); var sqlBuilder = InstanceFactory.GetSqlbuilder(this.CurrentConnectionConfig); ;
result.Context = this.Context; result.Context = this.Context;
result.SqlBuilder = sqlBuilder; result.SqlBuilder = sqlBuilder;
sqlBuilder.DeleteBuilder = result.DeleteBuilder = InstanceFactory.GetDeleteBuilder(this.CurrentConnectionConfig); sqlBuilder.DeleteBuilder = result.DeleteBuilder = InstanceFactory.GetDeleteBuilder(this.CurrentConnectionConfig);
@@ -295,7 +295,7 @@ namespace SqlSugar
protected UpdateableProvider<T> CreateUpdateable<T>(T[] UpdateObjs) where T : class, new() protected UpdateableProvider<T> CreateUpdateable<T>(T[] UpdateObjs) where T : class, new()
{ {
var result = InstanceFactory.GetUpdateableProvider<T>(this.CurrentConnectionConfig); var result = InstanceFactory.GetUpdateableProvider<T>(this.CurrentConnectionConfig);
var sqlBuilder = InstanceFactory.GetSqlbuilder(this.CurrentConnectionConfig); var sqlBuilder = InstanceFactory.GetSqlbuilder(this.CurrentConnectionConfig); ;
result.Context = this.Context; result.Context = this.Context;
result.EntityInfo = this.Context.EntityMaintenance.GetEntityInfo<T>(); result.EntityInfo = this.Context.EntityMaintenance.GetEntityInfo<T>();
result.SqlBuilder = sqlBuilder; result.SqlBuilder = sqlBuilder;
@@ -400,7 +400,7 @@ namespace SqlSugar
result.Add(joinValue); result.Add(joinValue);
} }
} }
return result.ToArray(); return result.ToArray(); ;
} }
protected Dictionary<string, string> GetEasyJoinInfo(Expression joinExpression, ref string shortName, ISqlBuilder builder, params Type[] entityTypeArray) protected Dictionary<string, string> GetEasyJoinInfo(Expression joinExpression, ref string shortName, ISqlBuilder builder, params Type[] entityTypeArray)

View File

@@ -86,6 +86,9 @@ namespace SqlSugar
DbResult<bool> UseTran(Action action); DbResult<bool> UseTran(Action action);
DbResult<T> UseTran<T>(Func<T> action); DbResult<T> UseTran<T>(Func<T> action);
Task<DbResult<bool>> UseTranAsync(Action action);
Task<DbResult<T>> UseTranAsync<T>(Func<T> action);
void UseStoredProcedure(Action action); void UseStoredProcedure(Action action);
T UseStoredProcedure<T>(Func<T> action); T UseStoredProcedure<T>(Func<T> action);
IAdo UseStoredProcedure(); IAdo UseStoredProcedure();

View File

@@ -16,7 +16,7 @@ namespace SqlSugar
Task<bool> ExecuteCommandHasChangeAsync(); Task<bool> ExecuteCommandHasChangeAsync();
IUpdateable<T> AS(string tableName); IUpdateable<T> AS(string tableName);
IUpdateable<T> With(string lockString); IUpdateable<T> With(string lockString);
[Obsolete] [Obsolete("Use IUpdateable<T> IgnoreColumns(bool ignoreAllNullColumns, bool isOffIdentity = false);")]
IUpdateable<T> Where(bool isNoUpdateNull,bool IsOffIdentity = false); IUpdateable<T> Where(bool isNoUpdateNull,bool IsOffIdentity = false);
IUpdateable<T> Where(Expression<Func<T, bool>> expression); IUpdateable<T> Where(Expression<Func<T, bool>> expression);
IUpdateable<T> Where(string whereSql,object parameters=null); IUpdateable<T> Where(string whereSql,object parameters=null);
@@ -33,12 +33,12 @@ namespace SqlSugar
/// </summary> /// </summary>
/// <param name="columns"></param> /// <param name="columns"></param>
/// <returns></returns> /// <returns></returns>
IUpdateable<T> IgnoreColumns(bool IgnoreAllNullColumns, bool IsOffIdentity = false);
IUpdateable<T> WhereColumns(Expression<Func<T, object>> columns); IUpdateable<T> WhereColumns(Expression<Func<T, object>> columns);
IUpdateable<T> UpdateColumns(Expression<Func<T, object>> columns); IUpdateable<T> UpdateColumns(Expression<Func<T, object>> columns);
IUpdateable<T> UpdateColumns(Expression<Func<T, bool>> columns); IUpdateable<T> UpdateColumns(Expression<Func<T, bool>> columns);
IUpdateable<T> UpdateColumns(Func<string, bool> updateColumMethod); IUpdateable<T> UpdateColumns(Func<string, bool> updateColumMethod);
IUpdateable<T> UpdateColumns(Expression<Func<T, T>> columns); IUpdateable<T> UpdateColumns(Expression<Func<T, T>> columns);
IUpdateable<T> IgnoreColumns(bool ignoreAllNullColumns, bool isOffIdentity = false);
IUpdateable<T> IgnoreColumns(Expression<Func<T, object>> columns); IUpdateable<T> IgnoreColumns(Expression<Func<T, object>> columns);
IUpdateable<T> IgnoreColumns(Func<string, bool> ignoreColumMethod); IUpdateable<T> IgnoreColumns(Func<string, bool> ignoreColumMethod);
IUpdateable<T> ReSetValue(Expression<Func<T, bool>> setValueExpression); IUpdateable<T> ReSetValue(Expression<Func<T, bool>> setValueExpression);

View File

@@ -133,5 +133,10 @@ namespace SqlSugar
{ {
return "NOW()"; return "NOW()";
} }
public override string GetRandom()
{
return "rand()";
}
} }
} }

View File

@@ -180,5 +180,10 @@ namespace SqlSugar
{ {
return "sysdate"; return "sysdate";
} }
public override string GetRandom()
{
return "dbms_random.value";
}
} }
} }

View File

@@ -111,7 +111,7 @@ namespace SqlSugar
} }
else if (type == UtilConstants.ByteArrayType) else if (type == UtilConstants.ByteArrayType)
{ {
string bytesString = "0x" + BitConverter.ToString((byte[])value); string bytesString = "0x" + BitConverter.ToString((byte[])value).Replace("-", "");
return bytesString; return bytesString;
} }
else if (type == UtilConstants.BoolType) else if (type == UtilConstants.BoolType)

View File

@@ -60,7 +60,7 @@ namespace SqlSugar
} }
else if (type == UtilConstants.ByteArrayType) else if (type == UtilConstants.ByteArrayType)
{ {
string bytesString = "0x" + BitConverter.ToString((byte[])value); string bytesString = "0x" + BitConverter.ToString((byte[])value).Replace("-", "");
return bytesString; return bytesString;
} }
else if (type == UtilConstants.BoolType) else if (type == UtilConstants.BoolType)

View File

@@ -157,7 +157,7 @@ namespace SqlSugar
var parameter = model.Args[0].MemberName; var parameter = model.Args[0].MemberName;
var parameter2 = model.Args[1].MemberName; var parameter2 = model.Args[1].MemberName;
int time = 1; int time = 1;
return string.Format(" Cast((JulianDay({0}) - JulianDay({1})) *{2} As INTEGER)", parameter, parameter2, time); return string.Format(" Cast((JulianDay({0}) - JulianDay({1})) *{2} As INTEGER)=0 ", parameter, parameter2, time);
} }
public override string DateIsSameByType(MethodCallExpressionModel model) public override string DateIsSameByType(MethodCallExpressionModel model)
{ {
@@ -208,5 +208,10 @@ namespace SqlSugar
{ {
return "DATETIME('now')"; return "DATETIME('now')";
} }
public override string GetRandom()
{
return "RANDOM()";
}
} }
} }

View File

@@ -2,7 +2,7 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>netstandard2.0</TargetFramework>
<Version>4.6.4.9</Version> <Version>4.7</Version>
<Copyright>sun_kai_xuan</Copyright> <Copyright>sun_kai_xuan</Copyright>
<PackageProjectUrl>https://github.com/sunkaixuan/SqlSugar</PackageProjectUrl> <PackageProjectUrl>https://github.com/sunkaixuan/SqlSugar</PackageProjectUrl>
<PackageLicenseUrl></PackageLicenseUrl> <PackageLicenseUrl></PackageLicenseUrl>

View File

@@ -2,7 +2,7 @@
<package > <package >
<metadata> <metadata>
<id>sqlSugarCore</id> <id>sqlSugarCore</id>
<version>4.6.4.7</version> <version>4.7</version>
<authors>sunkaixuan</authors> <authors>sunkaixuan</authors>
<owners>Landa</owners> <owners>Landa</owners>
<licenseUrl>http://www.apache.org/licenses/LICENSE-2.0.html</licenseUrl> <licenseUrl>http://www.apache.org/licenses/LICENSE-2.0.html</licenseUrl>