提交 a3cbd35c 编写于 作者: S Shay Rojansky

End batch if too many parameters

No more than int.MaxValue

Closes #109
上级 f5cccd21
......@@ -53,6 +53,7 @@ public class NpgsqlModificationCommandBatch : ReaderModificationCommandBatch
{
const int DefaultBatchSize = 1000;
readonly int _maxBatchSize;
long _parameterCount;
public NpgsqlModificationCommandBatch(
[NotNull] IRelationalCommandBuilderFactory commandBuilderFactory,
......@@ -68,8 +69,21 @@ public class NpgsqlModificationCommandBatch : ReaderModificationCommandBatch
_maxBatchSize = maxBatchSize ?? DefaultBatchSize;
}
protected override int GetParameterCount() => (int)_parameterCount;
protected override bool CanAddCommand(ModificationCommand modificationCommand)
=> ModificationCommands.Count < _maxBatchSize;
{
if (ModificationCommands.Count >= _maxBatchSize)
return false;
var newParamCount = _parameterCount + modificationCommand.ColumnModifications.Count;
if (newParamCount > int.MaxValue)
return false;
_parameterCount = newParamCount;
return true;
}
protected override bool IsCommandTextValid()
=> true;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册