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

Commit 7362dd2

Browse files
committed
throw OptimisticConcurrencyException if Save() doesn't insert or update a row
1 parent 32b43be commit 7362dd2

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/ServiceStack.OrmLite/OrmLiteWriteCommandExtensions.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,9 @@ internal static bool Save<T>(this IDbCommand dbCmd, T obj)
871871
return true;
872872
}
873873

874-
dbCmd.Update(obj);
874+
var rowsUpdated = dbCmd.Update(obj);
875+
if (rowsUpdated == 0)
876+
throw new OptimisticConcurrencyException("No rows were inserted or updated");
875877

876878
modelDef.RowVersion?.SetValueFn(obj, dbCmd.GetRowVersion(modelDef, id, modelDef.RowVersion.ColumnType));
877879

0 commit comments

Comments
 (0)