internal static void UpdateOnlySql<T>(this IDbCommand dbCmd, T model, SqlExpression<T> onlyFields) { if (OrmLiteConfig.UpdateFilter != null) OrmLiteConfig.UpdateFilter(dbCmd, model); var fieldsToUpdate = onlyFields.UpdateFields.Count == 0 ? onlyFields.GetAllFields() : onlyFields.UpdateFields; onlyFields.CopyParamsTo(dbCmd); dbCmd.GetDialectProvider().PrepareUpdateRowStatement(dbCmd, model, fieldsToUpdate); if (!onlyFields.WhereExpression.IsNullOrEmpty()) dbCmd.CommandText += " " + onlyFields.WhereExpression; }
internal static void UpdateAddSql <T>(this IDbCommand dbCmd, T model, SqlExpression <T> fields) { if (OrmLiteConfig.UpdateFilter != null) { OrmLiteConfig.UpdateFilter(dbCmd, model); } fields.CopyParamsTo(dbCmd); dbCmd.GetDialectProvider().PrepareUpdateRowAddStatement(dbCmd, model, fields.UpdateFields); if (!fields.WhereExpression.IsNullOrEmpty()) { dbCmd.CommandText += " " + fields.WhereExpression; } }
internal static IDbCommand InitUpdateOnly <T>(this IDbCommand dbCmd, Expression <Func <T> > updateFields, SqlExpression <T> q) { if (updateFields == null) { throw new ArgumentNullException(nameof(updateFields)); } OrmLiteConfig.UpdateFilter?.Invoke(dbCmd, updateFields.EvalFactoryFn()); q.CopyParamsTo(dbCmd); var updateFieldValues = updateFields.AssignedValues(); dbCmd.GetDialectProvider().PrepareUpdateRowStatement <T>(dbCmd, updateFieldValues, q.WhereExpression); return(dbCmd); }
public static int UpdateAdd<T>(this IDbCommand dbCmd, Expression<Func<T>> updateFields, SqlExpression<T> q) { if (updateFields == null) throw new ArgumentNullException("updateFields"); if (OrmLiteConfig.UpdateFilter != null) OrmLiteConfig.UpdateFilter(dbCmd, CachedExpressionCompiler.Evaluate(updateFields)); q.CopyParamsTo(dbCmd); var updateFieldValues = updateFields.AssignedValues(); dbCmd.GetDialectProvider().PrepareUpdateRowAddStatement<T>(dbCmd, updateFieldValues, q.WhereExpression); return dbCmd.ExecNonQuery(); }
internal static Task <int> UpdateOnlyAsync <T>(this IDbCommand dbCmd, Expression <Func <T> > updateFields, SqlExpression <T> q, CancellationToken token) { if (updateFields == null) { throw new ArgumentNullException("updateFields"); } if (OrmLiteConfig.UpdateFilter != null) { OrmLiteConfig.UpdateFilter(dbCmd, CachedExpressionCompiler.Evaluate(updateFields)); } q.CopyParamsTo(dbCmd); var updateFieldValues = updateFields.AssignedValues(); dbCmd.GetDialectProvider().PrepareUpdateRowStatement <T>(dbCmd, updateFieldValues, q.WhereExpression); return(dbCmd.ExecNonQueryAsync(token)); }