Esempio n. 1
0
        public static IDataReader GetDataReader(IDbConnection connection, QueryPlan queryPlan)
        {
            if (queryPlan.Parameters?.Any() ?? false)
            {
                var parameters = new DynamicParameters();
                foreach (var parameter in queryPlan.Parameters)
                {
                    parameters.Add(
                        parameter.Name,
                        parameter.Value,
                        parameter.DbType,
                        parameter.Direction,
                        parameter.Size,
                        parameter.Precision,
                        parameter.Scale);
                }

                return(ExecuteReader(connection, queryPlan.Query, parameters));
            }

            return(ExecuteReader(connection, queryPlan.Query, null));
        }
Esempio n. 2
0
        public static async Task <IDataReader> GetDataReaderAsync(IDbConnection connection, QueryPlan queryPlan)
        {
            if (queryPlan.Parameters?.Any() ?? false)
            {
                var parameters = new DynamicParameters();
                foreach (var parameter in queryPlan.Parameters)
                {
                    parameters.Add(
                        parameter.Name,
                        parameter.Value,
                        parameter.DbType,
                        parameter.Direction,
                        parameter.Size,
                        parameter.Precision,
                        parameter.Scale);
                }

                return(await ExecuteReaderAsync(connection, queryPlan.Query, parameters)
                       .ConfigureAwait(false));
            }

            return(await ExecuteReaderAsync(connection, queryPlan.Query, null)
                   .ConfigureAwait(false));
        }