DbFirst BUG

This commit is contained in:
sunkaixuan 2017-07-10 12:04:24 +08:00
parent 2119e813de
commit 37108aeefb

View File

@ -173,9 +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());
var hasDefaultValue = columns.Skip(index + 1).Any(it=>it.DefaultValue.IsValuable());
ConstructorText = ConstructorText.Replace(DbFirstTemplate.KeyPropertyName, propertyName);
ConstructorText = ConstructorText.Replace(DbFirstTemplate.KeyDefaultValue, GetPropertyTypeConvert(item)) + (isLastHasDefaultValue ? "" : this.ConstructorTemplate);
ConstructorText = ConstructorText.Replace(DbFirstTemplate.KeyDefaultValue, GetPropertyTypeConvert(item)) + (!hasDefaultValue ? "" : this.ConstructorTemplate);
}
}
}