示例#1
0
        public BatchCommand Current()
        {
            try
            {
                _lock.EnterUpgradeableReadLock();
                if (hasCurrentExceededCommandSizeLimit())
                {
                    _lock.EnterWriteLock();
                    try
                    {
                        _current = new BatchCommand(_store.Serializer, _tenant);
                        _commands.Add(_current);
                    }
                    finally
                    {
                        _lock.ExitWriteLock();
                    }
                }

                return(_current);
            }
            finally
            {
                _lock.ExitUpgradeableReadLock();
            }
        }
示例#2
0
        public SprocCall(BatchCommand parent, FunctionName function)
        {
            if (parent == null) throw new ArgumentNullException(nameof(parent));
            if (function == null) throw new ArgumentNullException(nameof(function));

            _parent = parent;
            _function = function;
        }
示例#3
0
        public SprocCall(BatchCommand parent, FunctionName function)
        {
            if (parent == null)
            {
                throw new ArgumentNullException(nameof(parent));
            }
            if (function == null)
            {
                throw new ArgumentNullException(nameof(function));
            }

            _parent   = parent;
            _function = function;
        }
示例#4
0
        private static void executeCallbacks(NpgsqlCommand cmd, BatchCommand batch, List <Exception> list)
        {
            using (var reader = cmd.ExecuteReader())
            {
                if (batch.Callbacks.Any())
                {
                    batch.Callbacks[0]?.Postprocess(reader, list);

                    for (int i = 1; i < batch.Callbacks.Count; i++)
                    {
                        reader.NextResult();

                        batch.Callbacks[i]?.Postprocess(reader, list);
                    }
                }
            }
        }
示例#5
0
        public UpdateBatch(DocumentStore store, IManagedConnection connection, VersionTracker versions, MemoryPool <char> writerPool, ITenant tenant, ConcurrencyChecks concurrency)
        {
            _store      = store;
            _writerPool = writerPool;
            Versions    = versions ?? throw new ArgumentNullException(nameof(versions));

            var current = new BatchCommand(_store.Serializer, tenant);

            _commands.Add(current);

            _current = current;

            Connection  = connection;
            Concurrency = concurrency;
            TenantId    = tenant.TenantId;
            _tenant     = tenant;
        }
示例#6
0
        private static async Task executeCallbacksAsync(NpgsqlCommand cmd, CancellationToken tkn, BatchCommand batch,
                                                        List <Exception> list)
        {
            using (var reader = await cmd.ExecuteReaderAsync(tkn).ConfigureAwait(false))
            {
                if (batch.Callbacks.Any())
                {
                    if (batch.Callbacks[0] != null)
                    {
                        await batch.Callbacks[0].PostprocessAsync(reader, list, tkn).ConfigureAwait(false);
                    }

                    for (var i = 1; i < batch.Callbacks.Count; i++)
                    {
                        if (!(batch.Calls[i - 1] is NoDataReturnedCall))
                        {
                            await reader.NextResultAsync(tkn).ConfigureAwait(false);
                        }



                        if (batch.Callbacks[i] != null)
                        {
                            await batch.Callbacks[i].PostprocessAsync(reader, list, tkn).ConfigureAwait(false);
                        }
                    }
                }
            }
        }
示例#7
0
 public SprocCall(BatchCommand parent, DbObjectName function)
 {
     _parent   = parent ?? throw new ArgumentNullException(nameof(parent));
     _function = function ?? throw new ArgumentNullException(nameof(function));
 }
示例#8
0
 public SprocCall(BatchCommand parent, string sprocName)
 {
     _parent = parent;
     _sprocName = sprocName;
 }
示例#9
0
 public SprocCall(BatchCommand parent, string sprocName)
 {
     _parent    = parent;
     _sprocName = sprocName;
 }
示例#10
0
        private static void executeCallbacks(NpgsqlCommand cmd, BatchCommand batch, List<Exception> list)
        {
            using (var reader = cmd.ExecuteReader())
            {
                if (batch.Callbacks.Any())
                {
                    batch.Callbacks[0]?.Postprocess(reader, list);

                    for (int i = 1; i < batch.Callbacks.Count; i++)
                    {
                        reader.NextResult();

                        batch.Callbacks[i]?.Postprocess(reader, list);
                    }
                }
            }
        }
示例#11
0
        private static async Task executeCallbacksAsync(NpgsqlCommand cmd, CancellationToken tkn, BatchCommand batch, List<Exception> list)
        {
            using (var reader = await cmd.ExecuteReaderAsync(tkn).ConfigureAwait(false))
            {
                if (batch.Callbacks.Any())
                {
                    if (batch.Callbacks[0] != null)
                    {
                        await batch.Callbacks[0].PostprocessAsync(reader, list, tkn).ConfigureAwait(false);
                    }

                    for (int i = 1; i < batch.Callbacks.Count; i++)
                    {
                        await reader.NextResultAsync(tkn).ConfigureAwait(false);

                        if (batch.Callbacks[i] != null)
                        {
                            await batch.Callbacks[i].PostprocessAsync(reader, list, tkn).ConfigureAwait(false);
                        }
                    }
                }
            }
        }