public SqlProvider <T> FormatUpdate(T entity) { var update = ResolveExpression.ResolveUpdate <T>(a => entity); var where = ResolveExpression.ResolveWhere(entity); var whereSql = where.SqlCmd; Params = where.Param; Params.AddDynamicParams(update.Param); SqlString = $"UPDATE {FormatTableName(false)} {update.SqlCmd} {whereSql}"; return(this); }
public SqlProvider <T> FormatUpdate(Expression <Func <T, T> > updateExpression) { var update = ResolveExpression.ResolveUpdate(updateExpression); var where = ResolveExpression.ResolveWhere(Context.CommandSet.WhereExpression); var whereSql = where.SqlCmd; Params = where.Param; Params.AddDynamicParams(update.Param); SqlString = $"UPDATE {FormatTableName(false)} {update.SqlCmd} {whereSql}"; return(this); }
public SqlProvider <T> FormatUpdateSelect(Expression <Func <T, T> > updator) { var update = ResolveExpression.ResolveUpdate(updator); var selectSql = ResolveExpression.ResolveSelectOfUpdate(typeof(T).GetProperties(), Context.QuerySet.SelectExpression); var where = ResolveExpression.ResolveWhere(Context.QuerySet.WhereExpression); var whereSql = where.SqlCmd; Params = where.Param; Params.AddDynamicParams(update.Param); var topSql = Context.QuerySet.TopNum.HasValue ? " TOP " + Context.QuerySet.TopNum.Value : ""; SqlString = $"UPDATE {topSql} {FormatTableName(false)} WITH ( UPDLOCK, READPAST ) {update.SqlCmd} {selectSql} {whereSql}"; return(this); }