tatic IFreeSql fsql = new FreeSql.FreeSqlBuilder()
    .UseConnectionString(FreeSql.DataType.MySql, 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; }
}

保存实体,忽略一些列

fsql.Update<Topic>().SetSource(item).IgnoreColumns(a => a.Clicks).ExecuteAffrows();//UPDATE `Topic` SET `Title` = @p_0, `CreateTime` = @p_1 WHERE (`Id` = 1)

fsql.Update<Topic>().SetSource(item).IgnoreColumns(a => new { a.Clicks, a.CreateTime }).ExecuteAffrows();//UPDATE `Topic` SET `Title` = @p_0 WHERE (`Id` = 1)

API

方法返回值参数描述
SetSource<this>T1 | IEnumerable更新数据,设置更新的实体
IgnoreColumns<this>Lambda忽略的列
Set<this>Lambda, value设置列的新值,Set(a => a.Name, "newvalue")
Set<this>Lambda设置列的的新值为基础上增加,Set(a => a.Clicks + 1),相当于 clicks=clicks+1
SetDto<this>object根据 dto 更新的方法
SetRaw<this>string, parms设置值,自定义SQL语法,SetRaw("title = @title", new { title = "newtitle" })
Where<this>Lambda表达式条件,仅支持实体基础成员(不包含导航对象)
Where<this>string, parms原生sql语法条件,Where("id = @id", new { id = 1 })
Where<this>T1 | IEnumerable传入实体或集合,将其主键作为条件
WhereExists<this>ISelect子查询是否存在
CommandTimeout<this>int命令超时设置(秒)
WithTransaction<this>DbTransaction设置事务对象
WithConnection<this>DbConnection设置连接对象
ToSqlstring 返回即将执行的SQL语句
ExecuteAffrowslong 执行SQL语句,返回影响的行数
ExecuteUpdatedList<T1> 执行SQL语句,返回更新后的记录