Skip to content

Commit 5cc383b

Browse files
committed
Merge pull request ThatRendle#111 from Mpdreamz/master
Passing null or empty IEnumerable data to bulk insert will just return 0
2 parents d738af1 + 937fe5a commit 5cc383b

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

Simple.Data.Ado/BulkUpdater.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ public int Update(AdoAdapter adapter, string tableName, IList<IDictionary<string
1818
public int Update(AdoAdapter adapter, string tableName, IList<IDictionary<string, object>> data, IEnumerable<string> criteriaFieldNames, IDbTransaction transaction)
1919
{
2020
int count = 0;
21-
if (data == null) throw new ArgumentNullException("data");
22-
if (data.Count < 2) throw new ArgumentException("UpdateMany requires more than one record.");
21+
if (data == null || !data.Any())
22+
return count;
2323

2424
var criteriaFieldNameList = criteriaFieldNames.ToList();
25-
2625
if (criteriaFieldNameList.Count == 0) throw new NotSupportedException("Adapter does not support key-based update for this object.");
26+
2727
if (!AllRowsHaveSameKeys(data)) throw new SimpleDataException("Records have different structures. Bulk updates are only valid on consistent records.");
2828
var table = adapter.GetSchema().FindTable(tableName);
2929

0 commit comments

Comments
 (0)