Inheritance: SqlMapper.IDynamicParameters
コード例 #1
0
        void InternalExecute(ManagedConnection managedConnection, string sql, List <Parameter> parameters, int expectedRowCount)
        {
            var fastParameters = new FastDynamicParameters(parameters);
            var rowcount       = managedConnection.Connection.Execute(sql, fastParameters);

            Interlocked.Increment(ref numberOfRequests);
            if (rowcount != expectedRowCount)
            {
                throw new ConcurrencyException();
            }
        }
コード例 #2
0
        public IEnumerable <T> RawQuery <T>(string sql, object parameters = null)
        {
            var hdbParams = parameters as IEnumerable <Parameter>;

            if (hdbParams != null)
            {
                parameters = new FastDynamicParameters(hdbParams);
            }

            store.Logger.Debug(sql);

            using (var connection = Connect())
            {
                return(connection.Connection.Query <T>(sql, parameters));
            }
        }
コード例 #3
0
        public int RawExecute(string sql, object parameters = null)
        {
            var hdbParams = parameters as IEnumerable <Parameter>;

            if (hdbParams != null)
            {
                parameters = new FastDynamicParameters(hdbParams);
            }

            store.Logger.Debug(sql);

            using (var connection = Connect())
            {
                var result = connection.Connection.Execute(sql, parameters);
                connection.Complete();

                return(result);
            }
        }
コード例 #4
0
        IEnumerable <T> InternalQuery <T>(ManagedConnection connection, SqlBuilder sql, object parameters, bool hasTotalsQuery, out QueryStats stats)
        {
            var normalizedParameters = new FastDynamicParameters(
                parameters as IEnumerable <Parameter> ?? ConvertToParameters <T>(parameters));

            if (hasTotalsQuery)
            {
                using (var reader = connection.Connection.QueryMultiple(sql.ToString(), normalizedParameters))
                {
                    stats = reader.Read <QueryStats>(buffered: true).Single();
                    return(reader.Read <T, object, T>((first, second) => first, "RowNumber", buffered: true));
                }
            }

            using (var reader = connection.Connection.QueryMultiple(sql.ToString(), normalizedParameters))
            {
                List <T> rows = reader.Read <T, object, T>((first, second) => first, "RowNumber", buffered: true).ToList();
                stats = new QueryStats
                {
                    TotalResults = rows.Count
                };
                return(rows);
            }
        }