Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 71db32b

Browse files
committed
Check all UpdateOnly dictionary APIs for RowVersion field
1 parent 1df5fa4 commit 71db32b

File tree

3 files changed

+424
-496
lines changed

3 files changed

+424
-496
lines changed

src/ServiceStack.OrmLite/Async/WriteExpressionCommandExtensionsAsync.cs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public static Task<int> UpdateAddAsync<T>(this IDbCommand dbCmd,
9393
return cmd.ExecNonQueryAsync(token);
9494
}
9595

96-
public static Task<int> UpdateOnlyAsync<T>(this IDbCommand cmd,
96+
public static Task<int> UpdateOnlyAsync<T>(this IDbCommand dbCmd,
9797
Dictionary<string, object> updateFields,
9898
Expression<Func<T, bool>> where,
9999
Action<IDbCommand> commandFilter = null,
@@ -104,14 +104,12 @@ public static Task<int> UpdateOnlyAsync<T>(this IDbCommand cmd,
104104
if (updateFields == null)
105105
throw new ArgumentNullException(nameof(updateFields));
106106

107-
OrmLiteConfig.UpdateFilter?.Invoke(cmd, updateFields.ToFilterType<T>());
107+
OrmLiteConfig.UpdateFilter?.Invoke(dbCmd, updateFields.ToFilterType<T>());
108108

109-
var q = cmd.GetDialectProvider().SqlExpression<T>();
109+
var q = dbCmd.GetDialectProvider().SqlExpression<T>();
110110
q.Where(where);
111-
q.PrepareUpdateStatement(cmd, updateFields);
112-
commandFilter?.Invoke(cmd);
113-
114-
return cmd.ExecNonQueryAsync(token);
111+
q.PrepareUpdateStatement(dbCmd, updateFields);
112+
return dbCmd.UpdateAndVerifyAsync<T>(commandFilter, updateFields.ContainsKey(ModelDefinition.RowVersionName), token);
115113
}
116114

117115
public static Task<int> UpdateOnlyAsync<T>(this IDbCommand dbCmd,
@@ -143,9 +141,7 @@ public static Task<int> UpdateOnlyAsync<T>(this IDbCommand dbCmd,
143141
var q = dbCmd.GetDialectProvider().SqlExpression<T>();
144142
q.Where(whereExpression, whereParams);
145143
q.PrepareUpdateStatement(dbCmd, updateFields);
146-
commandFilter?.Invoke(dbCmd);
147-
148-
return dbCmd.ExecNonQueryAsync(token);
144+
return dbCmd.UpdateAndVerifyAsync<T>(commandFilter, updateFields.ContainsKey(ModelDefinition.RowVersionName), token);
149145
}
150146

151147
internal static Task<int> UpdateNonDefaultsAsync<T>(this IDbCommand dbCmd, T item, Expression<Func<T, bool>> obj, CancellationToken token)

src/ServiceStack.OrmLite/Expressions/WriteExpressionCommandExtensions.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,7 @@ public static int UpdateOnly<T>(this IDbCommand dbCmd,
169169
var q = dbCmd.GetDialectProvider().SqlExpression<T>();
170170
q.Where(where);
171171
q.PrepareUpdateStatement(dbCmd, updateFields);
172-
commandFilter?.Invoke(dbCmd);
173-
174-
return dbCmd.ExecNonQuery();
172+
return dbCmd.UpdateAndVerify<T>(commandFilter, updateFields.ContainsKey(ModelDefinition.RowVersionName));
175173
}
176174

177175
internal static string GetUpdateOnlyWhereExpression<T>(this IOrmLiteDialectProvider dialectProvider,
@@ -226,9 +224,7 @@ public static int UpdateOnly<T>(this IDbCommand dbCmd,
226224
Action<IDbCommand> commandFilter = null)
227225
{
228226
dbCmd.PrepareUpdateOnly<T>(updateFields, whereExpression, whereParams);
229-
commandFilter?.Invoke(dbCmd);
230-
231-
return dbCmd.ExecNonQuery();
227+
return dbCmd.UpdateAndVerify<T>(commandFilter, updateFields.ContainsKey(ModelDefinition.RowVersionName));
232228
}
233229

234230
internal static void PrepareUpdateOnly<T>(this IDbCommand dbCmd, Dictionary<string, object> updateFields, string whereExpression, object[] whereParams)

0 commit comments

Comments
 (0)