Browse Source

Inset Identity Off Bug

pull/12/MERGE
sunkaixuan 8 years ago
parent
commit
89fc5714dd
  1. 2
      SqlServerTest/Demos/3_Insert.cs
  2. 2
      SqlServerTest/Program.cs
  3. 5
      SqlServerTest/UnitTest/Insert.cs
  4. 2
      SqlSugar/Abstract/InsertableProvider/InsertableProvider.cs

2
SqlServerTest/Demos/3_Insert.cs

@ -42,7 +42,7 @@ namespace OrmTest.Demo
var insertObj2 = new Student() { Name = null, CreateTime = Convert.ToDateTime("2010-1-1") };
var t9 = db.Insertable(insertObj2).Where(true/* Is insert null */, true/*off identity*/).ExecuteCommand();
var t9 = db.Insertable(insertObj2).Where(true/* Is insert null */, false/*off identity*/).ExecuteCommand();
//Insert List<T>
var insertObjs = new List<Student>();

2
SqlServerTest/Program.cs

@ -25,7 +25,7 @@ namespace OrmTest
//new SingleQuery(1).Init();
//new SelectQuery(1).Init();
//new AutoClose(1).Init();
//new Insert(1).Init();
new Insert(1).Init();
//new Delete(1).Init();
//new Update(1).Init();
//new Mapping(1).Init();

5
SqlServerTest/UnitTest/Insert.cs

@ -89,11 +89,12 @@ new List<SugarParameter>() {
var insertObj2 = new Student() { Name = null,SchoolId=0, CreateTime = Convert.ToDateTime("2010-1-1") };
var t8 = db.Insertable(insertObj2).Where(true/* Is insert null */, true/*off identity*/).ToSql();
base.Check(@"INSERT INTO [STudent]
([SchoolId],[CreateTime])
([ID],[SchoolId],[CreateTime])
VALUES
(@SchoolId,@CreateTime) ;SELECT SCOPE_IDENTITY();",
(@ID,@SchoolId,@CreateTime) ;SELECT SCOPE_IDENTITY();",
new List<SugarParameter>() {
new SugarParameter("@SchoolId", 0),
new SugarParameter("@ID", 0),
new SugarParameter("@CreateTime", Convert.ToDateTime("2010-1-1"))
},
t8.Key,

2
SqlSugar/Abstract/InsertableProvider/InsertableProvider.cs

@ -98,7 +98,7 @@ namespace SqlSugar
public IInsertable<T> Where(bool isNoInsertNull, bool isOffIdentity = false)
{
this.IsOffIdentity = IsOffIdentity;
this.IsOffIdentity = isOffIdentity;
if (this.InsertBuilder.LambdaExpressions == null)
this.InsertBuilder.LambdaExpressions = InstanceFactory.GetLambdaExpressions(this.Context.CurrentConnectionConfig);
this.InsertBuilder.IsNoInsertNull = isNoInsertNull;

Loading…
Cancel
Save