From 628b9693cff329069a660509f40c188cb3566a1d Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Sat, 7 Jan 2023 19:55:02 +0800 Subject: [PATCH] Synchronization code --- .../Abstract/DeleteProvider/DeleteableProvider.cs | 2 +- .../ExecuteNavProvider/InsertNavProviderOneToOne.cs | 3 ++- .../Abstract/ExecuteNavProvider/UpdateNavOneToOne.cs | 3 ++- .../Abstract/FilterProvider/FilterProvider.cs | 12 ++++++++---- .../Abstract/QueryableProvider/NavigatManager.cs | 2 +- .../ExpressionsToSql/Subquery/Subquerable.cs | 8 ++++---- .../Realization/Dm/SqlBuilder/DmUpdateBuilder.cs | 2 +- .../SqlSugar/SpliteTable/SplitTableContext.cs | 2 +- 8 files changed, 20 insertions(+), 14 deletions(-) diff --git a/Src/Asp.NetCore2/SqlSugar/Abstract/DeleteProvider/DeleteableProvider.cs b/Src/Asp.NetCore2/SqlSugar/Abstract/DeleteProvider/DeleteableProvider.cs index c0d130f73..26da919cf 100644 --- a/Src/Asp.NetCore2/SqlSugar/Abstract/DeleteProvider/DeleteableProvider.cs +++ b/Src/Asp.NetCore2/SqlSugar/Abstract/DeleteProvider/DeleteableProvider.cs @@ -436,7 +436,7 @@ namespace SqlSugar var lamResult = DeleteBuilder.GetExpressionValue(inField, ResolveExpressType.FieldSingle); var fieldName = lamResult.GetResultString(); tempPrimaryKeys = new List() { fieldName }; - var result = In(primaryKeyValue);; + var result = In(primaryKeyValue); tempPrimaryKeys = null; return this; } diff --git a/Src/Asp.NetCore2/SqlSugar/Abstract/ExecuteNavProvider/InsertNavProviderOneToOne.cs b/Src/Asp.NetCore2/SqlSugar/Abstract/ExecuteNavProvider/InsertNavProviderOneToOne.cs index 4c57f82d9..44348097c 100644 --- a/Src/Asp.NetCore2/SqlSugar/Abstract/ExecuteNavProvider/InsertNavProviderOneToOne.cs +++ b/Src/Asp.NetCore2/SqlSugar/Abstract/ExecuteNavProvider/InsertNavProviderOneToOne.cs @@ -16,7 +16,8 @@ namespace SqlSugar var parentPkColumn = parentEntity.Columns.FirstOrDefault(it => it.IsPrimarykey); var thisEntity = this._Context.EntityMaintenance.GetEntityInfo(); EntityColumnInfo thisPkColumn = GetPkColumnByNav(thisEntity, nav); - Check.Exception(thisPkColumn == null, $" Navigate {parentEntity.EntityName} : {name} is error ", $"导航实体 {parentEntity.EntityName} 属性 {name} 配置错误"); + Check.ExceptionEasy(thisPkColumn == null, $" Navigate {parentEntity.EntityName} : {name} is error ", $"导航实体 {parentEntity.EntityName} 属性 {name} 配置错误"); + Check.ExceptionEasy(nav.Navigat.WhereSql.HasValue(), $" {name} Navigate(NavType,WhereSql) no support insert ", $"导航一对一 {name} 配置了 Sql变量 不支持插入"); List childList = new List(); foreach (var parent in parentList) { diff --git a/Src/Asp.NetCore2/SqlSugar/Abstract/ExecuteNavProvider/UpdateNavOneToOne.cs b/Src/Asp.NetCore2/SqlSugar/Abstract/ExecuteNavProvider/UpdateNavOneToOne.cs index 0cba19c8c..8fdf3e27e 100644 --- a/Src/Asp.NetCore2/SqlSugar/Abstract/ExecuteNavProvider/UpdateNavOneToOne.cs +++ b/Src/Asp.NetCore2/SqlSugar/Abstract/ExecuteNavProvider/UpdateNavOneToOne.cs @@ -17,7 +17,8 @@ namespace SqlSugar var parentPkColumn = parentEntity.Columns.FirstOrDefault(it => it.IsPrimarykey); var thisEntity = this._Context.EntityMaintenance.GetEntityInfo(); EntityColumnInfo thisPkColumn = GetPkColumnByNav(thisEntity, nav); - Check.Exception(thisPkColumn == null, $" Navigate {parentEntity.EntityName} : {name} is error ", $"导航实体 {parentEntity.EntityName} 属性 {name} 配置错误"); + Check.ExceptionEasy(thisPkColumn == null, $" Navigate {parentEntity.EntityName} : {name} is error ", $"导航实体 {parentEntity.EntityName} 属性 {name} 配置错误"); + Check.ExceptionEasy(nav.Navigat.WhereSql.HasValue(), $" {name} Navigate(NavType,WhereSql) no support update ", $"导航一对一 {name} 配置了 Sql变量 不支持更新"); List childList = new List(); foreach (var parent in parentList) { diff --git a/Src/Asp.NetCore2/SqlSugar/Abstract/FilterProvider/FilterProvider.cs b/Src/Asp.NetCore2/SqlSugar/Abstract/FilterProvider/FilterProvider.cs index d083762f1..c71105077 100644 --- a/Src/Asp.NetCore2/SqlSugar/Abstract/FilterProvider/FilterProvider.cs +++ b/Src/Asp.NetCore2/SqlSugar/Abstract/FilterProvider/FilterProvider.cs @@ -65,31 +65,35 @@ namespace SqlSugar } } - public void AddTableFilter(Expression> expression, FilterJoinPosition filterJoinType = FilterJoinPosition.On) where T : class,new() + public QueryFilterProvider AddTableFilter(Expression> expression, FilterJoinPosition filterJoinType = FilterJoinPosition.On) where T : class,new() { var isOn = filterJoinType == FilterJoinPosition.On; var tableFilter = new TableFilterItem(expression, isOn); this.Add(tableFilter); + return this; } - public void AddTableFilterIF(bool isAppendFilter,Expression> expression, FilterJoinPosition filterJoinType = FilterJoinPosition.On) where T : class, new() + public QueryFilterProvider AddTableFilterIF(bool isAppendFilter,Expression> expression, FilterJoinPosition filterJoinType = FilterJoinPosition.On) where T : class, new() { if (isAppendFilter) { AddTableFilter(expression, filterJoinType); } + return this; } - public void AddTableFilter(Type type,Expression expression, FilterJoinPosition filterJoinType = FilterJoinPosition.On) + public QueryFilterProvider AddTableFilter(Type type,Expression expression, FilterJoinPosition filterJoinType = FilterJoinPosition.On) { var isOn = filterJoinType == FilterJoinPosition.On; this.Add(new TableFilterItem(type, expression, isOn)); + return this; } - public void AddTableFilterIF(bool isAppendFilter, Type type, Expression expression, FilterJoinPosition posType = FilterJoinPosition.On) + public QueryFilterProvider AddTableFilterIF(bool isAppendFilter, Type type, Expression expression, FilterJoinPosition posType = FilterJoinPosition.On) { if (isAppendFilter) { AddTableFilter(type, expression, posType); } + return this; } public enum FilterJoinPosition { diff --git a/Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/NavigatManager.cs b/Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/NavigatManager.cs index 51286e3b3..f040887c5 100644 --- a/Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/NavigatManager.cs +++ b/Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/NavigatManager.cs @@ -538,7 +538,7 @@ namespace SqlSugar SqlInfo result = new SqlInfo(); result.Parameters = new List(); var isList = false; - int parameterIndex = 0; + int parameterIndex = 100; foreach (var item in _ListCallFunc) { var method = item as MethodCallExpression; diff --git a/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/Subquery/Subquerable.cs b/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/Subquery/Subquerable.cs index 069e10cfd..d7520ad57 100644 --- a/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/Subquery/Subquerable.cs +++ b/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/Subquery/Subquerable.cs @@ -71,7 +71,7 @@ namespace SqlSugar return this; } - public TResult Select(Func expression) where TResult :struct + public TResult Select(Func expression) { return default(TResult); } @@ -89,7 +89,7 @@ namespace SqlSugar return default(string); } - public TResult Max(Func expression) where TResult : struct + public TResult Max(Func expression) { return default(TResult); } @@ -106,7 +106,7 @@ namespace SqlSugar { return default(string); } - public TResult Min(Func expression) where TResult : struct + public TResult Min(Func expression) { return default(TResult); } @@ -125,7 +125,7 @@ namespace SqlSugar { return default(int); } - public TResult Sum(Func expression) where TResult : struct + public TResult Sum(Func expression) { return default(TResult); } diff --git a/Src/Asp.NetCore2/SqlSugar/Realization/Dm/SqlBuilder/DmUpdateBuilder.cs b/Src/Asp.NetCore2/SqlSugar/Realization/Dm/SqlBuilder/DmUpdateBuilder.cs index dde717320..1ebdf5d97 100644 --- a/Src/Asp.NetCore2/SqlSugar/Realization/Dm/SqlBuilder/DmUpdateBuilder.cs +++ b/Src/Asp.NetCore2/SqlSugar/Realization/Dm/SqlBuilder/DmUpdateBuilder.cs @@ -28,7 +28,7 @@ namespace SqlSugar return string.Format("{0} {1} WHERE {2};", updateTable, setValues, string.Join("AND", whereList)); }).ToArray())); var result= sb.ToString(); - if (result == "\r\n") + if (groupList.Count==0) { return null; } diff --git a/Src/Asp.NetCore2/SqlSugar/SpliteTable/SplitTableContext.cs b/Src/Asp.NetCore2/SqlSugar/SpliteTable/SplitTableContext.cs index 8fac07b99..f222a4c6b 100644 --- a/Src/Asp.NetCore2/SqlSugar/SpliteTable/SplitTableContext.cs +++ b/Src/Asp.NetCore2/SqlSugar/SpliteTable/SplitTableContext.cs @@ -26,7 +26,7 @@ namespace SqlSugar } public string[] GetTableNames(SplitType splitType) { - List result = new List();; + List result = new List(); foreach (var item in Items) { result.Add(Helper.GetTableName(Helper.GetValue(splitType, item)));