From fef5049e246fb14b24c6f293b94e627dfc6115e7 Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Fri, 15 Sep 2017 13:33:52 +0800 Subject: [PATCH] Update Demo --- Src/Asp.Net/SqlServerTest/Models/Student.cs | 11 +++++++++++ Src/Asp.Net/SqlServerTest/UnitTest/Update.cs | 9 +++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Src/Asp.Net/SqlServerTest/Models/Student.cs b/Src/Asp.Net/SqlServerTest/Models/Student.cs index 421b87bcf..fe6c6362a 100644 --- a/Src/Asp.Net/SqlServerTest/Models/Student.cs +++ b/Src/Asp.Net/SqlServerTest/Models/Student.cs @@ -19,4 +19,15 @@ namespace OrmTest.Models [SugarColumn(IsIgnore=true)] public int TestId { get; set; } } + + public class StudentTest + { + [SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "ID")] + public int Id { get; set; } + public int? SchoolId { get; set; } + public string Name { get; set; } + public DateTime? CreateTime { get; set; } + [SugarColumn(IsIgnore = true)] + public int TestId { get; set; } + } } diff --git a/Src/Asp.Net/SqlServerTest/UnitTest/Update.cs b/Src/Asp.Net/SqlServerTest/UnitTest/Update.cs index 62a1fa491..7b2590bc8 100644 --- a/Src/Asp.Net/SqlServerTest/UnitTest/Update.cs +++ b/Src/Asp.Net/SqlServerTest/UnitTest/Update.cs @@ -151,14 +151,19 @@ namespace OrmTest.UnitTest [Name]=@Name WHERE [Id]=@Id", new List() { new SugarParameter("@Name","a"), new SugarParameter("@ID",1) - }, t13.Key, t13.Value, "Insert t13 error"); + }, t13.Key, t13.Value, "Update t13 error"); var t14 = db.Updateable(new Dictionary() { { "id", 0 }, { "name", "2" } }).ToSql(); base.Check(@"UPDATE [STudent] SET [Name]=@Name WHERE [Id]=@Id", new List() { new SugarParameter("@Name", "2"), new SugarParameter("@ID", 0) - }, t14.Key, t14.Value, "Insert t14 error"); + }, t14.Key, t14.Value, "Update t14 error"); + + + var t15 = db.Updateable(new StudentTest() { Id = 1, Name = "1" }).AS("student").ToSql(); + base.Check(@"UPDATE [student] SET + [SchoolId]=@SchoolId,[Name]=@Name,[CreateTime]=@CreateTime WHERE [Id]=@Id", null, t15.Key, null, "Update t15 error"); } }