Exemplo n.º 1
0
        public IEnumerable <T> ExecuteMultiple <T>(Func <IDataReader, IDataReaderBuilder, IEnumerable <TableObjectMapping>, IEnumerable <T> > readerDelegate,
                                                   IDataReaderBuilder dataReaderBuilder, IEnumerable <TableObjectMapping> tableObjectMappings)
        {
            try
            {
                Guard.ThrowIfNull("readerDelegate", readerDelegate);
                Guard.ThrowIfNull("dataReaderBuilder", dataReaderBuilder);
                Guard.ThrowIfNullOrEmpty("tableObjectMappings", tableObjectMappings);

                List <T> values;

                VerifyCommandText();

                using (var connection = new SqlConnection(_connectionString))
                {
                    connection.Open();

                    using (var command = GetCommand(_commandText, _queryType, connection))
                    {
                        using (var reader = command.ExecuteReader())
                        {
                            values = readerDelegate(reader, dataReaderBuilder, tableObjectMappings).ToSafeList();
                        }
                    }
                }

                return(values);
            }
            finally
            {
                ClearParameters();
            }
        }
Exemplo n.º 2
0
 protected PagingRepositoryHelper(string databaseName, IDatabaseFactory databaseFactory,
                                  IMapper mapper, IQueryBuilder queryBuilder, IDataReaderBuilder builder,
                                  IBuilderStrategyFactory builderStrategyFactory,
                                  IBuilder <IDataReader, PagingModel> pagingModelBuilder)
     : base(databaseName, databaseFactory, mapper, queryBuilder,
            builderStrategyFactory)
 {
     PagingModelBuilder = Guard.ThrowIfNull("pagingModelBuilder", pagingModelBuilder);
     Builder            = Guard.ThrowIfNull("builder", builder);
 }
 protected DataReaderBuilderStrategyBase(IDataReaderBuilder dataReaderBuilder)
 {
     DataReaderBuilder = Guard.ThrowIfNull("dataReaderBuilder", dataReaderBuilder);
 }
 public DictionaryBasedDataReaderJoinedBuilderStrategy(IDataReaderBuilder dataReaderBuilder, IObjectMapperFactory objectMappingFactory,
                                                       IDatabaseConfiguration databaseConfiguration) : base(dataReaderBuilder)
 {
     _objectMappingFactory  = objectMappingFactory.ThrowIfNull(nameof(objectMappingFactory));
     _databaseConfiguration = databaseConfiguration.ThrowIfNull(nameof(databaseConfiguration));
 }
 public DataReaderSingleBuilderStrategy(IDataReaderBuilder dataReaderBuilder) : base(dataReaderBuilder)
 {
 }
 protected DataReaderBuilderStrategyBase(IDataReaderBuilder dataReaderBuilder)
 {
     DataReaderBuilder = Guard.EnsureIsNotNull("dataReaderBuilder", dataReaderBuilder);
 }