public List <T> PerformSpRead <T>(ParametersAndReader <T> parametersAndReader, String storedProcedureName, int commandTimeout)
        {
            return(ExecuteStoredProcedure(storedProcedureName, parametersAndReader, reader =>
            {
                var result = new List <T>();

                if (reader != null)
                {
                    while (reader.Read())
                    {
                        result.Add(parametersAndReader.RecordReader(reader));
                    }
                }

                return result;
            }, commandTimeout));
        }
        public T PerformSpReadSingle <T>(ParametersAndReader <T> parametersAndReader, string storedProcedureName)
        {
            return(ExecuteStoredProcedure(storedProcedureName, parametersAndReader,
                                          reader =>
            {
                T result = default(T);

                if (reader != null)
                {
                    if (reader.Read())
                    {
                        result = parametersAndReader.RecordReader(reader);
                    }
                }

                return result;
            }));
        }
        private TResult ExecuteStoredProcedure <T, TResult>(string storedProcedureName, ParametersAndReader <T> parametersAndReader, Func <SqlDataReader, TResult> func, int commandTimeout)
        {
            return(ExecuteCommand(cmd =>
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = storedProcedureName;
                if (commandTimeout != 0)
                {
                    cmd.CommandTimeout = commandTimeout;
                }

                parametersAndReader.Parameters(cmd.Parameters);

                using (var reader = cmd.ExecuteReader())
                {
                    return func(reader);
                }
            }));
        }
 public List <T> PerformSpRead <T>(ParametersAndReader <T> parametersAndReader, String storedProcedure)
 {
     return(PerformSpRead(parametersAndReader, storedProcedure, 0));
 }
 private TResult ExecuteStoredProcedure <T, TResult>(string storedProcedureName, ParametersAndReader <T> parametersAndReader, Func <SqlDataReader, TResult> func)
 {
     return(ExecuteStoredProcedure(storedProcedureName, parametersAndReader, func, 0));
 }