Esempio n. 1
0
        public static NpgsqlCommand ToCommand(IQueryHandler handler)
        {
            var command = new NpgsqlCommand();

            using (var builder = new CommandBuilder(command))
            {
                handler.ConfigureCommand(builder);
                command.CommandText = builder._sql.ToString();

                return(command);
            }
        }
Esempio n. 2
0
        protected T executeHandler <T>(IQueryHandler <T> handler, QueryStatistics stats)
        {
            var cmd     = new NpgsqlCommand();
            var builder = new CommandBuilder(cmd);

            handler.ConfigureCommand(builder, this);

            cmd.CommandText = builder.ToString();

            using (var reader = Database.ExecuteReader(cmd))
            {
                return(handler.Handle(reader, this, stats));
            }
        }
Esempio n. 3
0
        protected async Task <T> executeHandlerAsync <T>(IQueryHandler <T> handler, QueryStatistics stats, CancellationToken token)
        {
            var cmd     = new NpgsqlCommand();
            var builder = new CommandBuilder(cmd);

            handler.ConfigureCommand(builder, this);

            cmd.CommandText = builder.ToString();

            using (var reader = await Database.ExecuteReaderAsync(cmd, token).ConfigureAwait(false))
            {
                return(await handler.HandleAsync(reader, this, stats, token).ConfigureAwait(false));
            }
        }
Esempio n. 4
0
        public static async Task <T> FetchAsync <T>(this IManagedConnection runner, IQueryHandler <T> handler, IIdentityMap map, CancellationToken token)
        {
            var command = new NpgsqlCommand();

            handler.ConfigureCommand(command);

            return(await runner.ExecuteAsync(command, async (c, tkn) =>
            {
                using (var reader = await command.ExecuteReaderAsync(tkn).ConfigureAwait(false))
                {
                    return await handler.HandleAsync(reader, map, tkn).ConfigureAwait(false);
                }
            }, token).ConfigureAwait(false));
        }
Esempio n. 5
0
        public static T Fetch <T>(this IManagedConnection runner, IQueryHandler <T> handler, IIdentityMap map)
        {
            var command = new NpgsqlCommand();

            handler.ConfigureCommand(command);

            return(runner.Execute(command, c =>
            {
                using (var reader = command.ExecuteReader())
                {
                    return handler.Handle(reader, map);
                }
            }));
        }
Esempio n. 6
0
        public static NpgsqlCommand ToCommand(ITenant tenant, IQueryHandler handler)
        {
            var command = new NpgsqlCommand();

            using (var builder = new CommandBuilder(command))
            {
                handler.ConfigureCommand(builder);
                command.CommandText = builder._sql.ToString();

                if (command.CommandText.Contains(TenantIdArg))
                {
                    command.AddNamedParameter(TenantIdArgument.ArgName, tenant.TenantId);
                }

                return(command);
            }
        }
Esempio n. 7
0
        public static NpgsqlCommand BuildCommand(this IMartenSession session, IQueryHandler handler)
        {
            var command = new NpgsqlCommand();
            var builder = new CommandBuilder(command);

            handler.ConfigureCommand(builder, session);

            command.CommandText = builder.ToString();

            var tenantParameter = command.Parameters.FirstOrDefault(x => x.ParameterName == TenantIdArgument.ArgName);

            if (tenantParameter != null)
            {
                tenantParameter.Value = session.Tenant.TenantId;
            }

            return(command);
        }
Esempio n. 8
0
 public void ConfigureCommand(NpgsqlCommand command)
 {
     _inner.ConfigureCommand(command);
 }
Esempio n. 9
0
 public void ConfigureCommand(CommandBuilder builder)
 {
     _inner.ConfigureCommand(builder);
 }
Esempio n. 10
0
 public void Configure(IDocumentSchema schema, NpgsqlCommand command)
 {
     _handler.ConfigureCommand(command);
 }