Update Demo

This commit is contained in:
sunkaixuan 2017-09-15 13:33:52 +08:00
parent 5dd77d91e9
commit fef5049e24
2 changed files with 18 additions and 2 deletions

View File

@ -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; }
}
}

View File

@ -151,14 +151,19 @@ namespace OrmTest.UnitTest
[Name]=@Name WHERE [Id]=@Id", new List<SugarParameter>() {
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<Student>(new Dictionary<string, object>() { { "id", 0 }, { "name", "2" } }).ToSql();
base.Check(@"UPDATE [STudent] SET
[Name]=@Name WHERE [Id]=@Id", new List<SugarParameter>() {
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");
}
}