From dd749d890e429948e6f5abe67fd015ebef58444f Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Mon, 10 Jul 2017 12:12:35 +0800 Subject: [PATCH] Update Core --- Src/Asp.Net/SqlSugar/SqlSugar.nuspec | 2 +- .../IDataReaderEntityBuilder.cs | 2 +- .../DbFirstProvider/DbFirstProvider.cs | 9 ++- .../DbFirstProvider/DbFirstTemplate.cs | 4 +- .../QueryableProvider/QueryableProvider.cs | 66 +++++++++---------- .../src/SqlSugar/Properties/AssemblyInfo.cs | 4 +- .../src/SqlSugar/SqlSugarForCore.nuspec | 5 +- 7 files changed, 49 insertions(+), 43 deletions(-) diff --git a/Src/Asp.Net/SqlSugar/SqlSugar.nuspec b/Src/Asp.Net/SqlSugar/SqlSugar.nuspec index efc09eb41..f7ee61aab 100644 --- a/Src/Asp.Net/SqlSugar/SqlSugar.nuspec +++ b/Src/Asp.Net/SqlSugar/SqlSugar.nuspec @@ -2,7 +2,7 @@ sqlSugar - 4.2 + 4.2.0.1 SqlSugar SqlServer ORM sun kaixuan landa diff --git a/Src/Asp.NetCore/SqlServerTest/src/SqlSugar/Abstract/DbBindProvider/IDataReaderEntityBuilder.cs b/Src/Asp.NetCore/SqlServerTest/src/SqlSugar/Abstract/DbBindProvider/IDataReaderEntityBuilder.cs index a67c5f354..6a3ba335e 100644 --- a/Src/Asp.NetCore/SqlServerTest/src/SqlSugar/Abstract/DbBindProvider/IDataReaderEntityBuilder.cs +++ b/Src/Asp.NetCore/SqlServerTest/src/SqlSugar/Abstract/DbBindProvider/IDataReaderEntityBuilder.cs @@ -108,7 +108,7 @@ namespace SqlSugar { if (!ReaderKeys.Contains(mappInfo.DbColumnName)) { - fileName = ReaderKeys.Single(it=>it.Equals(mappInfo.DbColumnName,StringComparison.CurrentCultureIgnoreCase)); + fileName = ReaderKeys.Single(it => it.Equals(mappInfo.DbColumnName, StringComparison.CurrentCultureIgnoreCase)); } else { diff --git a/Src/Asp.NetCore/SqlServerTest/src/SqlSugar/Abstract/DbFirstProvider/DbFirstProvider.cs b/Src/Asp.NetCore/SqlServerTest/src/SqlSugar/Abstract/DbFirstProvider/DbFirstProvider.cs index c00dea70d..d6d25ca95 100644 --- a/Src/Asp.NetCore/SqlServerTest/src/SqlSugar/Abstract/DbFirstProvider/DbFirstProvider.cs +++ b/Src/Asp.NetCore/SqlServerTest/src/SqlSugar/Abstract/DbFirstProvider/DbFirstProvider.cs @@ -162,6 +162,7 @@ namespace SqlSugar foreach (var item in columns) { var isLast = columns.Last() == item; + var index = columns.IndexOf(item); string PropertyText = this.PropertyTemplate; string PropertyDescriptionText = this.PropertyDescriptionTemplate; string propertyName = GetPropertyName(item); @@ -172,8 +173,9 @@ namespace SqlSugar classText = classText.Replace(DbFirstTemplate.KeyPropertyName, PropertyText + (isLast ? "" : ("\r\n" + DbFirstTemplate.KeyPropertyName))); if (ConstructorText.IsValuable() && item.DefaultValue.IsValuable()) { + var hasDefaultValue = columns.Skip(index + 1).Any(it=>it.DefaultValue.IsValuable()); ConstructorText = ConstructorText.Replace(DbFirstTemplate.KeyPropertyName, propertyName); - ConstructorText = ConstructorText.Replace(DbFirstTemplate.KeyDefaultValue, GetPropertyTypeConvert(item)) + (isLast ? "" : this.ConstructorTemplate); + ConstructorText = ConstructorText.Replace(DbFirstTemplate.KeyDefaultValue, GetPropertyTypeConvert(item)) + (!hasDefaultValue ? "" : this.ConstructorTemplate); } } } @@ -289,7 +291,10 @@ namespace SqlSugar private string GetPropertyTypeConvert(DbColumnInfo item) { var convertString = GetProertypeDefaultValue(item); - if (convertString == "DateTime.Now" || convertString == null) return convertString; + if (convertString == "DateTime.Now" || convertString == null) + return convertString; + if (item.DataType == "bit") + return (convertString == "1" || convertString.Equals("true",StringComparison.CurrentCultureIgnoreCase)).ToString().ToLower(); string result = this.Context.Ado.DbBind.GetConvertString(item.DataType) + "(\"" + convertString + "\")"; return result; } diff --git a/Src/Asp.NetCore/SqlServerTest/src/SqlSugar/Abstract/DbFirstProvider/DbFirstTemplate.cs b/Src/Asp.NetCore/SqlServerTest/src/SqlSugar/Abstract/DbFirstProvider/DbFirstTemplate.cs index 0db40efc0..ab7fdd23c 100644 --- a/Src/Asp.NetCore/SqlServerTest/src/SqlSugar/Abstract/DbFirstProvider/DbFirstTemplate.cs +++ b/Src/Asp.NetCore/SqlServerTest/src/SqlSugar/Abstract/DbFirstProvider/DbFirstTemplate.cs @@ -12,9 +12,9 @@ namespace SqlSugar "namespace {Namespace}\r\n" + "{\r\n" + "{ClassDescription}{SugarTable}\r\n" + - ClassSpace+"public class {ClassName}\r\n" + + ClassSpace+ "public partial class {ClassName}\r\n" + ClassSpace + "{\r\n" + - PropertySpace + "public {ClassName}(){\r\n" + + PropertySpace + "public {ClassName}(){\r\n\r\n" + "{Constructor}\r\n" + PropertySpace + "}\r\n" + "{PropertyName}\r\n" + diff --git a/Src/Asp.NetCore/SqlServerTest/src/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs b/Src/Asp.NetCore/SqlServerTest/src/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs index d6e276b0e..2b1cf0c6a 100644 --- a/Src/Asp.NetCore/SqlServerTest/src/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs +++ b/Src/Asp.NetCore/SqlServerTest/src/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs @@ -793,18 +793,18 @@ namespace SqlSugar #region Order public ISugarQueryable OrderBy(Expression> expression, OrderByType type = OrderByType.Asc) { - _OrderBy(expression); + _OrderBy(expression,type); return this; } public ISugarQueryable OrderBy(Expression> expression, OrderByType type = OrderByType.Asc) { - _OrderBy(expression); + _OrderBy(expression, type); return this; } public new ISugarQueryable OrderBy(Expression> expression, OrderByType type) { - _OrderBy(expression); + _OrderBy(expression, type); return this; } #endregion @@ -980,22 +980,22 @@ namespace SqlSugar #region OrderBy public new ISugarQueryable OrderBy(Expression> expression, OrderByType type = OrderByType.Asc) { - _OrderBy(expression); + _OrderBy(expression, type); return this; } public ISugarQueryable OrderBy(Expression> expression, OrderByType type = OrderByType.Asc) { - _OrderBy(expression); + _OrderBy(expression, type); return this; } public ISugarQueryable OrderBy(Expression> expression, OrderByType type = OrderByType.Asc) { - _OrderBy(expression); + _OrderBy(expression, type); return this; } public ISugarQueryable OrderBy(Expression> expression, OrderByType type = OrderByType.Asc) { - _OrderBy(expression); + _OrderBy(expression, type); return this; } #endregion @@ -1144,27 +1144,27 @@ namespace SqlSugar #region OrderBy public new ISugarQueryable OrderBy(Expression> expression, OrderByType type = OrderByType.Asc) { - _OrderBy(expression); + _OrderBy(expression, type); return this; } public ISugarQueryable OrderBy(Expression> expression, OrderByType type = OrderByType.Asc) { - _OrderBy(expression); + _OrderBy(expression, type); return this; } public ISugarQueryable OrderBy(Expression> expression, OrderByType type = OrderByType.Asc) { - _OrderBy(expression); + _OrderBy(expression, type); return this; } public ISugarQueryable OrderBy(Expression> expression, OrderByType type = OrderByType.Asc) { - _OrderBy(expression); + _OrderBy(expression, type); return this; } public ISugarQueryable OrderBy(Expression> expression, OrderByType type = OrderByType.Asc) { - _OrderBy(expression); + _OrderBy(expression, type); return this; } #endregion @@ -1334,32 +1334,32 @@ namespace SqlSugar #region OrderBy public new ISugarQueryable OrderBy(Expression> expression, OrderByType type = OrderByType.Asc) { - _OrderBy(expression); + _OrderBy(expression, type); return this; } public ISugarQueryable OrderBy(Expression> expression, OrderByType type = OrderByType.Asc) { - _OrderBy(expression); + _OrderBy(expression, type); return this; } public ISugarQueryable OrderBy(Expression> expression, OrderByType type = OrderByType.Asc) { - _OrderBy(expression); + _OrderBy(expression, type); return this; } public ISugarQueryable OrderBy(Expression> expression, OrderByType type = OrderByType.Asc) { - _OrderBy(expression); + _OrderBy(expression, type); return this; } public ISugarQueryable OrderBy(Expression> expression, OrderByType type = OrderByType.Asc) { - _OrderBy(expression); + _OrderBy(expression, type); return this; } public ISugarQueryable OrderBy(Expression> expression, OrderByType type = OrderByType.Asc) { - _OrderBy(expression); + _OrderBy(expression, type); return this; } #endregion @@ -1550,37 +1550,37 @@ namespace SqlSugar #region OrderBy public new ISugarQueryable OrderBy(Expression> expression, OrderByType type = OrderByType.Asc) { - _OrderBy(expression); + _OrderBy(expression, type); return this; } public ISugarQueryable OrderBy(Expression> expression, OrderByType type = OrderByType.Asc) { - _OrderBy(expression); + _OrderBy(expression, type); return this; } public ISugarQueryable OrderBy(Expression> expression, OrderByType type = OrderByType.Asc) { - _OrderBy(expression); + _OrderBy(expression, type); return this; } public ISugarQueryable OrderBy(Expression> expression, OrderByType type = OrderByType.Asc) { - _OrderBy(expression); + _OrderBy(expression, type); return this; } public ISugarQueryable OrderBy(Expression> expression, OrderByType type = OrderByType.Asc) { - _OrderBy(expression); + _OrderBy(expression, type); return this; } public ISugarQueryable OrderBy(Expression> expression, OrderByType type = OrderByType.Asc) { - _OrderBy(expression); + _OrderBy(expression, type); return this; } public ISugarQueryable OrderBy(Expression> expression, OrderByType type = OrderByType.Asc) { - _OrderBy(expression); + _OrderBy(expression, type); return this; } #endregion @@ -1793,42 +1793,42 @@ namespace SqlSugar #region OrderBy public new ISugarQueryable OrderBy(Expression> expression, OrderByType type = OrderByType.Asc) { - _OrderBy(expression); + _OrderBy(expression, type); return this; } public ISugarQueryable OrderBy(Expression> expression, OrderByType type = OrderByType.Asc) { - _OrderBy(expression); + _OrderBy(expression, type); return this; } public ISugarQueryable OrderBy(Expression> expression, OrderByType type = OrderByType.Asc) { - _OrderBy(expression); + _OrderBy(expression, type); return this; } public ISugarQueryable OrderBy(Expression> expression, OrderByType type = OrderByType.Asc) { - _OrderBy(expression); + _OrderBy(expression, type); return this; } public ISugarQueryable OrderBy(Expression> expression, OrderByType type = OrderByType.Asc) { - _OrderBy(expression); + _OrderBy(expression, type); return this; } public ISugarQueryable OrderBy(Expression> expression, OrderByType type = OrderByType.Asc) { - _OrderBy(expression); + _OrderBy(expression, type); return this; } public ISugarQueryable OrderBy(Expression> expression, OrderByType type = OrderByType.Asc) { - _OrderBy(expression); + _OrderBy(expression, type); return this; } public ISugarQueryable OrderBy(Expression> expression, OrderByType type = OrderByType.Asc) { - _OrderBy(expression); + _OrderBy(expression, type); return this; } #endregion diff --git a/Src/Asp.NetCore/SqlServerTest/src/SqlSugar/Properties/AssemblyInfo.cs b/Src/Asp.NetCore/SqlServerTest/src/SqlSugar/Properties/AssemblyInfo.cs index cb0bd82e9..5f7837a90 100644 --- a/Src/Asp.NetCore/SqlServerTest/src/SqlSugar/Properties/AssemblyInfo.cs +++ b/Src/Asp.NetCore/SqlServerTest/src/SqlSugar/Properties/AssemblyInfo.cs @@ -17,5 +17,5 @@ using System.Runtime.InteropServices; // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("1c022a5c-4e4d-4026-a8a3-f659b9740a1a")] -[assembly: AssemblyVersion("4.2")] -[assembly: AssemblyFileVersion("4.2")] +[assembly: AssemblyVersion("4.2.0.1")] +[assembly: AssemblyFileVersion("4.2.0.1")] diff --git a/Src/Asp.NetCore/SqlServerTest/src/SqlSugar/SqlSugarForCore.nuspec b/Src/Asp.NetCore/SqlServerTest/src/SqlSugar/SqlSugarForCore.nuspec index 73bd34880..00adb976a 100644 --- a/Src/Asp.NetCore/SqlServerTest/src/SqlSugar/SqlSugarForCore.nuspec +++ b/Src/Asp.NetCore/SqlServerTest/src/SqlSugar/SqlSugarForCore.nuspec @@ -2,7 +2,7 @@ sqlSugarCore - 4.2 + 4.2.0.1 sunkaixuan Landa http://www.apache.org/licenses/LICENSE-2.0.html @@ -20,7 +20,8 @@ - + +