mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-22 10:42:52 +08:00
- 增加 IUpdate.SetIf 方法;#309
This commit is contained in:
parent
2853c356e6
commit
a0acece7e5
@ -93,6 +93,15 @@ namespace FreeSql
|
||||
/// <returns></returns>
|
||||
IUpdate<T1> Set<TMember>(Expression<Func<T1, TMember>> column, TMember value);
|
||||
/// <summary>
|
||||
/// 设置列的新值,Set(a => a.Name, "newvalue")
|
||||
/// </summary>
|
||||
/// <typeparam name="TMember"></typeparam>
|
||||
/// <param name="condition">true 时生效</param>
|
||||
/// <param name="column">lambda选择列</param>
|
||||
/// <param name="value">新值</param>
|
||||
/// <returns></returns>
|
||||
IUpdate<T1> SetIf<TMember>(bool condition, Expression<Func<T1, TMember>> column, TMember value);
|
||||
/// <summary>
|
||||
/// 设置列的的新值为基础上增加,格式:Set(a => a.Clicks + 1) 相当于 clicks=clicks+1
|
||||
/// <para></para>
|
||||
/// 指定更新,格式:Set(a => new T { Clicks = a.Clicks + 1, Time = DateTime.Now }) 相当于 set clicks=clicks+1,time='2019-06-19....'
|
||||
@ -102,6 +111,16 @@ namespace FreeSql
|
||||
/// <returns></returns>
|
||||
IUpdate<T1> Set<TMember>(Expression<Func<T1, TMember>> exp);
|
||||
/// <summary>
|
||||
/// 设置列的的新值为基础上增加,格式:Set(a => a.Clicks + 1) 相当于 clicks=clicks+1
|
||||
/// <para></para>
|
||||
/// 指定更新,格式:Set(a => new T { Clicks = a.Clicks + 1, Time = DateTime.Now }) 相当于 set clicks=clicks+1,time='2019-06-19....'
|
||||
/// </summary>
|
||||
/// <typeparam name="TMember"></typeparam>
|
||||
/// <param name="condition">true 时生效</param>
|
||||
/// <param name="exp"></param>
|
||||
/// <returns></returns>
|
||||
IUpdate<T1> SetIf<TMember>(bool condition, Expression<Func<T1, TMember>> exp);
|
||||
/// <summary>
|
||||
/// 设置值,自定义SQL语法,SetRaw("title = ?title", new { title = "newtitle" })
|
||||
/// </summary>
|
||||
/// <param name="sql">sql语法</param>
|
||||
|
@ -400,6 +400,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
SetPriv(cols.First().Column, value);
|
||||
return this;
|
||||
}
|
||||
public IUpdate<T1> SetIf<TMember>(bool condition, Expression<Func<T1, TMember>> column, TMember value) => condition ? Set(column, value) : this;
|
||||
public IUpdate<T1> Set<TMember>(Expression<Func<T1, TMember>> exp)
|
||||
{
|
||||
var body = exp?.Body;
|
||||
@ -459,6 +460,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
_setIncr.Append(", ").Append(_commonUtils.QuoteSqlName(cols.First().Column.Attribute.Name)).Append(" = ").Append(expt);
|
||||
return this;
|
||||
}
|
||||
public IUpdate<T1> SetIf<TMember>(bool condition, Expression<Func<T1, TMember>> exp) => condition ? Set(exp) : this;
|
||||
public IUpdate<T1> SetRaw(string sql, object parms = null)
|
||||
{
|
||||
if (string.IsNullOrEmpty(sql)) return this;
|
||||
|
Loading…
x
Reference in New Issue
Block a user