/// <summary> /// Deletes multiple rows in the database. /// </summary> /// <param name="keys">The keys of the rows to be deleted</param> /// <returns>The number of deleted rows</returns> public int Delete(IEnumerable <TKey> keys) { if (keys == null || !keys.Any()) { throw new ArgumentException("Keys must not be null or an empty enumerable."); } var parameters = new DynamicParameters(); parameters.Add(Key.Property, keys); int result; var connection = GetConnection(); try { var keyParamName = _queryGenerator.FormatSqlParameter(Key.Property); result = connection.Execute(_queryGenerator.DeleteMany(Table, Key, keyParamName), parameters); } finally { if (!_useProvidedConnection) { connection.Dispose(); } } return(result); }