Skip to content

Commit 2157a3f

Browse files
committed
Added beginTransaction option to InsertAll
You may want to use InsertAll in a transaction but this wasn't possible because it always tried to start its own. Now it is possible.
1 parent 0dfbf6e commit 2157a3f

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/SQLite.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -865,14 +865,18 @@ public void RunInTransaction (Action action)
865865
/// <returns>
866866
/// The number of rows added to the table.
867867
/// </returns>
868-
public int InsertAll (System.Collections.IEnumerable objects)
868+
public int InsertAll (System.Collections.IEnumerable objects, bool beginTransaction = true)
869869
{
870-
BeginTransaction ();
870+
if (beginTransaction) {
871+
BeginTransaction ();
872+
}
871873
var c = 0;
872874
foreach (var r in objects) {
873875
c += Insert (r);
874876
}
875-
Commit ();
877+
if (beginTransaction) {
878+
Commit ();
879+
}
876880
return c;
877881
}
878882

0 commit comments

Comments
 (0)