Example #1
0
        private async Task SendMessagesForBatch(
            StatementBuilder statement,
            TBoundTypeInfo[] typeInfos,
            String statementName,
            MessageIOArgs ioArgs,
            Int32 chunkSize,
            Int32 batchCount
            )
        {
            var   singleRowParamCount = statement.SQLParameterCount;
            Int32 max;
            var   execMessage = new ExecuteMessage();

            for (var i = 0; i < batchCount; i = max)
            {
                max = Math.Min(batchCount, i + chunkSize);
                for (var j = i; j < max; ++j)
                {
                    // Send Bind and Execute messages
                    // TODO reuse BindMessage -> add Reset method.
                    await new BindMessage(
                        statement.GetParameterEnumerable(j),
                        singleRowParamCount,
                        typeInfos,
                        this.DisableBinaryProtocolSend,
                        this.DisableBinaryProtocolReceive,
                        statementName: statementName
                        ).SendMessageAsync(ioArgs, true);
                    await execMessage.SendMessageAsync(ioArgs, true);
                }

                // Now send flush message for backend to start sending results back
                await FrontEndMessageWithNoContent.FLUSH.SendMessageAsync(ioArgs, false);
            }
        }