2023年8月3日发(作者:)
FreeSql(⼗⼀)更新数据Wherestatic IFreeSql fsql = new lBuilder() .UseConnectionString(, connectionString) .UseAutoSyncStructure(true) //⾃动同步实体结构到数据库 .Build(); //请务必定义成 Singleton 单例模式class Topic { [Column(IsIdentity = true, IsPrimary = true)] public int Id { get; set; } public int Clicks { get; set; } public string Title { get; set; } public DateTime CreateTime { get; set; }}动态条件(object dywhere)dywhere ⽀持主键值new[] { 主键值1, 主键值2 }Topic对象new[] { Topic对象1, Topic对象2 }new { id = 1 }其他条件除了上⾯介绍的 dywhere 构造参数外,还⽀持 Where lambda/sql ⽅法出于安全考虑,没有条件不执⾏更新动作,避免误更新全表数据 更新全表数据:().Where("1=1").Set(a => == xxx).ExecuteAffrows()() .Set(a => , "新标题") .Set(a => , ) .Where(a => == 1) .ExecuteAffrows();//UPDATE `Topic` SET `Title` = @Title, `Time` = @Time
//WHERE (Id = 1)API⽅法WhereWhereWhereWhereExistsToSqlExecuteAffrows返回值stringlong参数Lambdastring, parms描述表达式条件,仅⽀持实体基础成员(不包含导航对象)原⽣sql语法条件,Where("id = @id", new { id = 1 })T1 | IEnumerable传⼊实体或集合,将其主键作为条件ISelect⼦查询是否存在返回即将执⾏的SQL语句执⾏SQL语句,返回影响的⾏数执⾏SQL语句,返回更新后的记录ExecuteUpdatedList系列⽂章导航(⼗⼀)更新数据 Where
2023年8月3日发(作者:)
FreeSql(⼗⼀)更新数据Wherestatic IFreeSql fsql = new lBuilder() .UseConnectionString(, connectionString) .UseAutoSyncStructure(true) //⾃动同步实体结构到数据库 .Build(); //请务必定义成 Singleton 单例模式class Topic { [Column(IsIdentity = true, IsPrimary = true)] public int Id { get; set; } public int Clicks { get; set; } public string Title { get; set; } public DateTime CreateTime { get; set; }}动态条件(object dywhere)dywhere ⽀持主键值new[] { 主键值1, 主键值2 }Topic对象new[] { Topic对象1, Topic对象2 }new { id = 1 }其他条件除了上⾯介绍的 dywhere 构造参数外,还⽀持 Where lambda/sql ⽅法出于安全考虑,没有条件不执⾏更新动作,避免误更新全表数据 更新全表数据:().Where("1=1").Set(a => == xxx).ExecuteAffrows()() .Set(a => , "新标题") .Set(a => , ) .Where(a => == 1) .ExecuteAffrows();//UPDATE `Topic` SET `Title` = @Title, `Time` = @Time
//WHERE (Id = 1)API⽅法WhereWhereWhereWhereExistsToSqlExecuteAffrows返回值stringlong参数Lambdastring, parms描述表达式条件,仅⽀持实体基础成员(不包含导航对象)原⽣sql语法条件,Where("id = @id", new { id = 1 })T1 | IEnumerable传⼊实体或集合,将其主键作为条件ISelect⼦查询是否存在返回即将执⾏的SQL语句执⾏SQL语句,返回影响的⾏数执⾏SQL语句,返回更新后的记录ExecuteUpdatedList系列⽂章导航(⼗⼀)更新数据 Where
发布评论