Exemplo n.º 1
0
 public static async Task ExecuteAsync(
     this SdmapContext ctx,
     ISession session,
     string statementId,
     object parameters = null)
 {
     var statement = ctx.Emit(statementId, parameters);
     var cursor    = await session.RunAsync(statement, parameters.ToDictionary());
 }
Exemplo n.º 2
0
        public static Task <object> ExecuteScalarAsync(this SdmapContext ctx, IDbConnection cnn,
                                                       string statementId,
                                                       object parameters          = null,
                                                       IDbTransaction transaction = null,
                                                       int?commandTimeout         = null,
                                                       CommandType?commandType    = null)
        {
            var statement = ctx.Emit(statementId, parameters);

            return(cnn.ExecuteScalarAsync(statement, parameters, transaction, commandTimeout, commandType));
        }
Exemplo n.º 3
0
        public static Task <T> QuerySingleOrDefaultAsync <T>(this SdmapContext ctx, IDbConnection cnn,
                                                             string statementId,
                                                             object parameters          = null,
                                                             IDbTransaction transaction = null,
                                                             int?commandTimeout         = null,
                                                             CommandType?commandType    = null)
        {
            var statement = ctx.Emit(statementId, parameters);

            return(cnn.QuerySingleOrDefaultAsync <T>(statement, parameters, transaction, commandTimeout, commandType));
        }
Exemplo n.º 4
0
        // asyncs
        public static Task <IEnumerable <dynamic> > QueryAsync(this SdmapContext ctx, IDbConnection cnn,
                                                               string statementId,
                                                               object parameters          = null,
                                                               IDbTransaction transaction = null,
                                                               int?commandTimeout         = null,
                                                               CommandType?commandType    = null)
        {
            var statement = ctx.Emit(statementId, parameters);

            return(cnn.QueryAsync(statement, parameters, transaction, commandTimeout, commandType));
        }
Exemplo n.º 5
0
        public static SqlMapper.GridReader QueryMultiple(this SdmapContext ctx, IDbConnection cnn,
                                                         string statementId,
                                                         object parameters          = null,
                                                         IDbTransaction transaction = null,
                                                         int?commandTimeout         = null,
                                                         CommandType?commandType    = null)
        {
            var statement = ctx.Emit(statementId, parameters);

            return(cnn.QueryMultiple(statement, parameters, transaction, commandTimeout, commandType));
        }
Exemplo n.º 6
0
        public static IEnumerable <T> Query <T>(this SdmapContext ctx, IDbConnection cnn,
                                                string statementId,
                                                object parameters          = null,
                                                IDbTransaction transaction = null,
                                                bool buffered           = true,
                                                int?commandTimeout      = null,
                                                CommandType?commandType = null)
        {
            var statement = ctx.Emit(statementId, parameters);

            return(cnn.Query <T>(statement, parameters, transaction, buffered, commandTimeout, commandType));
        }
Exemplo n.º 7
0
        public static object QueryFirstOrDefault(this SdmapContext ctx, IDbConnection cnn,
                                                 Type type,
                                                 string statementId,
                                                 object parameters          = null,
                                                 IDbTransaction transaction = null,
                                                 int?commandTimeout         = null,
                                                 CommandType?commandType    = null)
        {
            var statement = ctx.Emit(statementId, parameters);

            return(cnn.QueryFirstOrDefault(type, statement, parameters, transaction, commandTimeout, commandType));
        }
Exemplo n.º 8
0
        public static async Task <T> ExecuteScalarAsync <T>(
            this SdmapContext ctx,
            ISession session,
            string statementId,
            object parameters = null)
        {
            var statement = ctx.Emit(statementId, parameters);
            var cursor    = await session.RunAsync(statement, parameters.ToDictionary());

            var fected = await cursor.FetchAsync();

            return(fected ?
                   cursor.Current[0].As <T>() : default);
Exemplo n.º 9
0
        public static IEnumerable <TReturn> Query <TFirst, TSecond, TReturn>(
            this SdmapContext ctx, IDbConnection cnn,
            string statementId,
            Func <TFirst, TSecond, TReturn> map,
            object parameters          = null,
            IDbTransaction transaction = null,
            bool buffered           = true,
            string splitOn          = "Id",
            int?commandTimeout      = null,
            CommandType?commandType = null)
        {
            var statement = ctx.Emit(statementId, parameters);

            return(cnn.Query(statement, map, parameters, transaction, buffered, splitOn, commandTimeout, commandType));
        }
Exemplo n.º 10
0
        public static async Task <List <T> > QueryListAsync <T>(
            this SdmapContext ctx,
            ISession session,
            string statementId,
            object parameters = null)
        {
            var statement = ctx.Emit(statementId, parameters);
            var cursor    = await session.RunAsync(statement, parameters.ToDictionary());

            var result = new List <T>();

            while (await cursor.FetchAsync())
            {
                IRecord record = cursor.Current;
                result.Add(record.MapTo <T>());
            }
            return(result);
        }