ThinkDev.Data
在使用数据库的过程中,经常会碰到此类需求:生成语句:UPDATE dbo.UserInfo SET UserName = UserName + '_old' WHERE UserID = 1
此次更新,为该功能添加了支持:
组件版本号:V1.0.0.2
//首先定义实体类定义
public class UserInfo
{
public int UserID { get; set; }
public string UserName { get; set; }
public string NickName { get; set; }
public int Sex { get; set; }
public string HeadPic { get; set; }
public string Introduction { get; set; }
public string Other { get ; set; }
public DateTime RegTime { get; set; }
}
Public string GetSql()
{
string sql = SqlBuilder<UserInfo>.From(user, "dbo.UserInfo")
.Update()
.Set(u => u.UserName, u => u.UserName, "+", "_old")
.Where(u => u.UserID)
.And(u=>u.UserName, MatchType.In, "user1", "user2", "user3")
.GetSql();
}
//或者
Public string GetSql()
{
string sql = SqlBuilder.From("dbo.UserInfo")
.Update()
.Set("UserName", "UserName", "+", "_old")
.Where("UserID", 1)
.GetSql();
}


浙公网安备 33010602011771号