mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-07-31 15:56:25 +08:00
DbFirst bug
This commit is contained in:
parent
c031eb3948
commit
2119e813de
@ -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 isLastHasDefaultValue = 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)) + (isLastHasDefaultValue ? "" : 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;
|
||||
}
|
||||
|
@ -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" +
|
||||
|
@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("4.2")]
|
||||
[assembly: AssemblyFileVersion("4.2")]
|
||||
[assembly: AssemblyVersion("4.2.0.1")]
|
||||
[assembly: AssemblyFileVersion("4.2.0.1")]
|
||||
|
Loading…
Reference in New Issue
Block a user