Browse Source

Update insert bug

pull/12/MERGE
sunkaixuan 6 years ago
parent
commit
7c676b4062
  1. 2
      Src/Asp.Net/SqlServerTest/Config.cs
  2. 6
      Src/Asp.Net/SqlSugar/Abstract/InsertableProvider/InsertableProvider.cs

2
Src/Asp.Net/SqlServerTest/Config.cs

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

6
Src/Asp.Net/SqlSugar/Abstract/InsertableProvider/InsertableProvider.cs

@ -41,10 +41,12 @@ namespace SqlSugar
foreach (var item in InsertBuilder.DbColumnInfoList)
{
var isPk = pks.Any(y => y.Equals(item.DbColumnName, StringComparison.CurrentCultureIgnoreCase)) || item.IsPrimarykey;
if (isPk && item.PropertyType == UtilConstants.GuidType&&item.Value.ObjToString()==Guid.Empty.ToString()) {
if (isPk && item.PropertyType == UtilConstants.GuidType && item.Value.ObjToString() == Guid.Empty.ToString())
{
item.Value = Guid.NewGuid();
if (InsertObjs.First().GetType().GetProperties().Any(it => it.Name == item.PropertyName))
InsertObjs.First().GetType().GetProperties().First(it => it.Name == item.PropertyName).SetValue(InsertObjs.First(), item.Value, null);
}
InsertObjs.First().GetType().GetProperties().First(it => it.Name == item.PropertyName).SetValue(InsertObjs.First(),item.Value,null);
}
}
InsertBuilder.IsReturnIdentity = false;

Loading…
Cancel
Save