更新简介
1. 接口
2. 基类
3. 方法
3.1 Set
3.1.1 Set扩展方法
TUpdate Set<TUpdate>(this TUpdate update, IAssignInfo operation)
where TUpdate : UpdateBase, IUpdate;
var table = new UserTable();
var update = new TableUpdate(table, table.Id.Equal())
.Set(table.Status.AssignValue(false));
// UPDATE [Users] SET [Status]=0 WHERE [Id]=@Id
3.1.2 Set重载扩展方法
TUpdate Set<TUpdate>(this TUpdate update, string columnName, string op = "=", string parameter = "")
where TUpdate : UpdateBase, IUpdate;
var update = TableUpdate.Create("Users", id.EqualValue(1))
.Set("Status", "=", "DenyStatus");
// UPDATE [Users] SET [Status]=@DenyStatus WHERE [Id]=1
3.2 SetAssign扩展方法
- SetAssign是SetParameter的简化
- op固定为=
TUpdate SetAssign<TUpdate>(this TUpdate update, string columnName, string parameter = "")
where TUpdate : UpdateBase, IUpdate;
var id = Column.Use("Id");
var update = TableUpdate.Create("Users", id.EqualValue(1))
.SetAssign("Status", "DenyStatus");
// UPDATE [Users] SET [Status]=@DenyStatus WHERE [Id]=1
3.3 SetValue扩展方法
TUpdate SetValue<TUpdate, TValue>(this TUpdate update, string columnName, TValue value, string op)
where TUpdate : UpdateBase, IUpdate;
var id = Column.Use("Id");
var update = TableUpdate.Create("Students", id.EqualValue(1))
.SetValue("Score", 8, "+=");
// UPDATE [Students] SET [Score]+=8 WHERE [Id]=1
3.4 SetValue重载扩展方法
TUpdate SetValue<TUpdate, TValue>(this TUpdate update, string columnName, TValue value)
where TUpdate : UpdateBase, IUpdate;
var id = Column.Use("Id");
var update = TableUpdate.Create("Students", id.EqualValue(1))
.SetValue("Score", 60);
// UPDATE [Students] SET [Score]=60 WHERE [Id]=1
3.5 SetRaw扩展方法
TUpdate SetRaw<TUpdate>(this TUpdate update, string assignSql)
where TUpdate : UpdateBase, IUpdate;
var id = Column.Use("Id");
var update = TableUpdate.Create("Students", id.EqualValue(1))
.SetRaw("Score=60");
// UPDATE [Students] SET Score=60 WHERE [Id]=1
4. 其他相关功能