Skip to content

Commit

Permalink
还原为上一个版本,修复仓储Update方法的一个重载方法BUG;
Browse files Browse the repository at this point in the history
  • Loading branch information
zqlovejyc committed Sep 17, 2018
1 parent 6b70584 commit 6409a53
Show file tree
Hide file tree
Showing 14 changed files with 584 additions and 749 deletions.
164 changes: 82 additions & 82 deletions SQLBuilder.Core.Console/Program.cs

Large diffs are not rendered by default.

42 changes: 21 additions & 21 deletions SQLBuilder.Core.UnitTest/InsertTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class InsertTest
[TestMethod]
public void Test_Insert_01()
{
var builder = SqlBuilder.Insert<UserInfo, object>(() => new
var builder = SqlBuilder.Insert<UserInfo>(() => new
{
Name = "张三",
Sex = 2
Expand All @@ -33,7 +33,7 @@ public void Test_Insert_01()
[TestMethod]
public void Test_Insert_02()
{
var builder = SqlBuilder.Insert<UserInfo, object>(() => new UserInfo
var builder = SqlBuilder.Insert<UserInfo>(() => new UserInfo
{
Name = "张三",
Sex = 2
Expand All @@ -53,7 +53,7 @@ public void Test_Insert_03()
Name = "张强",
Sex = 2
};
var builder = SqlBuilder.Insert<UserInfo, object>(() => userInfo);
var builder = SqlBuilder.Insert<UserInfo>(() => userInfo);
Assert.AreEqual("INSERT INTO [Base_UserInfo] ([Id],[Sex],[Name],[Email]) VALUES (NULL,@Param0,@Param1,NULL)", builder.Sql);
Assert.AreEqual(2, builder.Parameters.Count);
}
Expand All @@ -64,7 +64,7 @@ public void Test_Insert_03()
[TestMethod]
public void Test_Insert_04()
{
var builder = SqlBuilder.Insert<Student, object>(() => new Student
var builder = SqlBuilder.Insert<Student>(() => new Student
{
Name = DateTime.Now.ToLongTimeString(),
AccountId = (new Random()).Next(1, 100)
Expand All @@ -84,7 +84,7 @@ public void Test_Insert_05()
Name = "张强",
Sex = 2
};
var builder = SqlBuilder.Insert<UserInfo, object>(() => userInfo, isEnableNullValue: false);
var builder = SqlBuilder.Insert<UserInfo>(() => userInfo, isEnableNullValue: false);
Assert.AreEqual("INSERT INTO [Base_UserInfo] ([Sex],[Name]) VALUES (@Param0,@Param1)", builder.Sql);
Assert.AreEqual(2, builder.Parameters.Count);
}
Expand All @@ -97,8 +97,8 @@ public void Test_Insert_05()
[TestMethod]
public void Test_Batch_Insert_01()
{
var builder = SqlBuilder.Insert<UserInfo, object>(() => new[]
{
var builder = SqlBuilder.Insert<UserInfo>(() => new[]
{
new UserInfo { Name = "张三", Sex = 2 },
new UserInfo { Name = "张三", Sex = 2 }
});
Expand All @@ -112,8 +112,8 @@ public void Test_Batch_Insert_01()
[TestMethod]
public void Test_Batch_Insert_02()
{
var builder = SqlBuilder.Insert<UserInfo, object>(() => new[]
{
var builder = SqlBuilder.Insert<UserInfo>(() => new[]
{
new { Name = "张三", Sex = 2 },
new { Name = "张三", Sex = 2 }
});
Expand All @@ -132,7 +132,7 @@ public void Test_Batch_Insert_03()
new UserInfo { Name = "张三", Sex = 2 },
new UserInfo { Name = "张三", Sex = 2 }
}.ToArray();
var builder = SqlBuilder.Insert<UserInfo, object>(() => array);
var builder = SqlBuilder.Insert<UserInfo>(() => array);
Assert.AreEqual("INSERT INTO [Base_UserInfo] ([Id],[Sex],[Name],[Email]) VALUES (NULL,@Param0,@Param1,NULL),(NULL,@Param2,@Param3,NULL)", builder.Sql);
Assert.AreEqual(4, builder.Parameters.Count);
}
Expand All @@ -148,7 +148,7 @@ public void Test_Batch_Insert_04()
new { Name = "张三", Sex = 2 },
new { Name = "张三", Sex = 2 }
}.ToArray();
var builder = SqlBuilder.Insert<UserInfo, object>(() => array);
var builder = SqlBuilder.Insert<UserInfo>(() => array);
Assert.AreEqual("INSERT INTO [Base_UserInfo] ([Name],[Sex]) VALUES (@Param0,@Param1),(@Param2,@Param3)", builder.Sql);
Assert.AreEqual(4, builder.Parameters.Count);
}
Expand All @@ -159,8 +159,8 @@ public void Test_Batch_Insert_04()
[TestMethod]
public void Test_Batch_Insert_05()
{
var builder = SqlBuilder.Insert<Class, object>(() => new[]
{
var builder = SqlBuilder.Insert<Class>(() => new[]
{
new Class { CityId = 2, UserId = 2, Name = "张三" },
new Class { CityId = 3, UserId = 3, Name = "李四" }
});
Expand All @@ -179,7 +179,7 @@ public void Test_Batch_Insert_06()
new Class { CityId = 2, UserId = 2, Name = "张三" },
new Class { CityId = 3, UserId = 3, Name = "李四" }
};
var builder = SqlBuilder.Insert<Class, object>(() => data);
var builder = SqlBuilder.Insert<Class>(() => data);
Assert.AreEqual("INSERT INTO [Base_Class] ([UserId],[Name]) VALUES (@Param0,@Param1),(@Param2,@Param3)", builder.Sql);
Assert.AreEqual(4, builder.Parameters.Count);
}
Expand All @@ -190,8 +190,8 @@ public void Test_Batch_Insert_06()
[TestMethod]
public void Test_Batch_Insert_07()
{
var builder = SqlBuilder.Insert<Class, object>(() => new[]
{
var builder = SqlBuilder.Insert<Class>(() => new[]
{
new { CityId = 2, UserId = 2, Name = "张三" },
new { CityId = 3, UserId = 3, Name = "李四" }
});
Expand All @@ -210,7 +210,7 @@ public void Test_Batch_Insert_08()
new { CityId = 2, UserId = 2, Name = "张三" },
new { CityId = 3, UserId = 3, Name = "李四" }
};
var builder = SqlBuilder.Insert<Class, object>(() => data);
var builder = SqlBuilder.Insert<Class>(() => data);
Assert.AreEqual("INSERT INTO [Base_Class] ([UserId],[Name]) VALUES (@Param0,@Param1),(@Param2,@Param3)", builder.Sql);
Assert.AreEqual(4, builder.Parameters.Count);
}
Expand All @@ -226,7 +226,7 @@ public void Test_Batch_Insert_09()
new UserInfo{ Name = "张三", Sex = 2 },
new UserInfo { Name = "张三", Sex = 2 }
};
var builder = SqlBuilder.Insert<UserInfo, object>(() => list.ToArray());
var builder = SqlBuilder.Insert<UserInfo>(() => list.ToArray());
Assert.AreEqual("INSERT INTO [Base_UserInfo] ([Id],[Sex],[Name],[Email]) VALUES (NULL,@Param0,@Param1,NULL),(NULL,@Param2,@Param3,NULL)", builder.Sql);
Assert.AreEqual(4, builder.Parameters.Count);
}
Expand All @@ -242,7 +242,7 @@ public void Test_Batch_Insert_10()
new UserInfo{ Name = "张三", Sex = 2 },
new UserInfo { Name = "张三", Sex = 2 }
};
var builder = SqlBuilder.Insert<UserInfo, object>(() => list);
var builder = SqlBuilder.Insert<UserInfo>(() => list);
Assert.AreEqual("INSERT INTO [Base_UserInfo] ([Id],[Sex],[Name],[Email]) VALUES (NULL,@Param0,@Param1,NULL),(NULL,@Param2,@Param3,NULL)", builder.Sql);
Assert.AreEqual(4, builder.Parameters.Count);
}
Expand All @@ -253,7 +253,7 @@ public void Test_Batch_Insert_10()
[TestMethod]
public void Test_Batch_Insert_11()
{
var builder = SqlBuilder.Insert<UserInfo, object>(() => new List<UserInfo>
var builder = SqlBuilder.Insert<UserInfo>(() => new List<UserInfo>
{
new UserInfo{ Name = "张三", Sex = 2 },
new UserInfo { Name = "张三", Sex = 2 }
Expand All @@ -268,7 +268,7 @@ public void Test_Batch_Insert_11()
[TestMethod]
public void Test_Batch_Insert_12()
{
var builder = SqlBuilder.Insert<UserInfo, object>(() => new List<dynamic>
var builder = SqlBuilder.Insert<UserInfo>(() => new List<dynamic>
{
new { Name = "张三", Sex = 2 },
new { Name = "张三", Sex = 2 }
Expand Down
Loading

0 comments on commit 6409a53

Please sign in to comment.