/// <summary> /// Initializes a new instance of the <see cref="Query{TResultType}"/> class. /// </summary> /// <param name="connector">The database connector.</param> /// <param name="descriptor">The table type descriptor.</param> public Query(IDatabaseConnector connector, ITableTypeDescriptor descriptor) { this.Connector = connector; this.Descriptor = descriptor; this.SelectCommandBuilder = connector.GetCommandBuilderFactory().CreateSelectCommandBuilder(descriptor); this.Mapper = new DatabaseReaderMapper <TResultType>(connector, descriptor); }
/// <summary> /// Initializes a new instance of the <see cref="CustomQuery{TResultType}"/> class. /// </summary> /// <param name="connector">The database connector.</param> /// <param name="query">The query.</param> public CustomQuery(IDatabaseConnector connector, string query) { this.Connector = connector; this.Descriptor = DescriptorCache.Instance.GetCustomTypeDescriptor(typeof(TResultType)); this.CommandText = query; this.Mapper = new DatabaseReaderMapper <TResultType>(connector, this.Descriptor); }
/// <summary> /// Executes after the initialization. /// </summary> protected void Initialize() { this.Mapper1 = this.Mapper1 ?? this.ServiceProvider.GetServiceIfAvailable <IDatabaseReaderMapper <TResult1> >(() => new DatabaseReaderMapper <TResult1>(this.Connector)); this.Mapper2 = this.Mapper2 ?? this.ServiceProvider.GetServiceIfAvailable <IDatabaseReaderMapper <TResult2> >(() => new DatabaseReaderMapper <TResult2>(this.Connector)); this.Mapper3 = this.Mapper3 ?? this.ServiceProvider.GetServiceIfAvailable <IDatabaseReaderMapper <TResult3> >(() => new DatabaseReaderMapper <TResult3>(this.Connector)); this.Mapper4 = this.Mapper4 ?? this.ServiceProvider.GetServiceIfAvailable <IDatabaseReaderMapper <TResult4> >(() => new DatabaseReaderMapper <TResult4>(this.Connector)); this.Mapper5 = this.Mapper5 ?? this.ServiceProvider.GetServiceIfAvailable <IDatabaseReaderMapper <TResult5> >(() => new DatabaseReaderMapper <TResult5>(this.Connector)); if (this.Mapper1 == null) { throw new OrmException("The first mapper can not be null."); } if (this.Mapper2 == null) { throw new OrmException("The second mapper can not be null."); } if (this.Mapper3 == null) { throw new OrmException("The third mapper can not be null."); } if (this.Mapper4 == null) { throw new OrmException("The fourth mapper can not be null."); } if (this.Mapper5 == null) { throw new OrmException("The fifth mapper can not be null."); } }
/// <summary> /// Executes after the initialization. /// </summary> protected override void AfterInitialize() { base.AfterInitialize(); this.Mapper1 = this.Mapper1 ?? this.ServiceProvider.GetServiceIfAvailable <IDatabaseReaderMapper <TResult1> >(() => new DatabaseReaderMapper <TResult1>(this.Connector, new TableTypeDescriptor(typeof(TResult1)))); this.Mapper2 = this.Mapper2 ?? this.ServiceProvider.GetServiceIfAvailable <IDatabaseReaderMapper <TResult2> >(() => new DatabaseReaderMapper <TResult2>(this.Connector, new TableTypeDescriptor(typeof(TResult2)))); this.Mapper3 = this.Mapper3 ?? this.ServiceProvider.GetServiceIfAvailable <IDatabaseReaderMapper <TResult3> >(() => new DatabaseReaderMapper <TResult3>(this.Connector, new TableTypeDescriptor(typeof(TResult3)))); this.Mapper4 = this.Mapper4 ?? this.ServiceProvider.GetServiceIfAvailable <IDatabaseReaderMapper <TResult4> >(() => new DatabaseReaderMapper <TResult4>(this.Connector, new TableTypeDescriptor(typeof(TResult4)))); if (this.Mapper1 == null) { throw new OrmException("The first mapper can not be null."); } if (this.Mapper2 == null) { throw new OrmException("The second mapper can not be null."); } if (this.Mapper3 == null) { throw new OrmException("The third mapper can not be null."); } if (this.Mapper4 == null) { throw new OrmException("The fourth mapper can not be null."); } }
/// <summary> /// Initializes a new instance of the ReaderStoredProcedure. /// </summary> /// <param name="serviceProvider">The service provider.</param> /// <param name="connector">The database connector.</param> /// <param name="mapper">The result mapper.</param> public ReaderStoredProcedure( IServiceProvider serviceProvider, IDatabaseConnector connector, IDatabaseReaderMapper <TResult> mapper) : base(serviceProvider, connector) { this.Mapper = mapper; }
/// <summary> /// Initializes a new instance of the <see cref="Query{TResultType}"/> class. /// </summary> /// <param name="connector">The database connector.</param> public Query(IDatabaseConnector connector) { this.Connector = connector; this.Descriptor = DescriptorCache.Instance.GetTableTypeDescriptor(typeof(TResultType)); this.SelectCommandBuilder = connector.GetCommandBuilderFactory().CreateSelectCommandBuilder(this.Descriptor); this.Mapper = new DatabaseReaderMapper <TResultType>(connector, this.Descriptor); }
/// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// </summary> public void Dispose() { this.SelectCommandBuilder?.Dispose(); this.Connector = null; this.Descriptor = null; this.SelectCommandBuilder = null; this.Mapper = null; }
/// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// </summary> public void Dispose() { this.Command?.Dispose(); this.Connector = null; this.Descriptor = null; this.Command = null; this.Mapper = null; }
/// <summary> /// Initializes a new instance of the ReaderStoredProcedure. /// </summary> /// <param name="connector">The database connector.</param> /// <param name="mapper1">The first result mapper.</param> /// <param name="mapper2">The second result mapper.</param> public ReaderStoredProcedure( IDatabaseConnector connector, IDatabaseReaderMapper <TResult1> mapper1, IDatabaseReaderMapper <TResult2> mapper2) : base(connector) { this.Mapper1 = mapper1; this.Mapper2 = mapper2; }
/// <summary> /// Initializes a new instance of the <see cref="CustomQuery{TResultType}"/> class. /// </summary> /// <param name="connector">The database connector.</param> /// <param name="query">The query.</param> /// <param name="descriptor">The custom type descriptor.</param> public CustomQuery(IDatabaseConnector connector, string query, ICustomTypeDescriptor descriptor) { this.Connector = connector; this.Descriptor = descriptor; this.CommandText = query; this.Command = connector.CreateCommand(); this.Command.CommandText = query; this.Mapper = new DatabaseReaderMapper <TResultType>(connector, descriptor); }
/// <summary> /// Executes after the initialization. /// </summary> protected void Initialize() { this.Mapper = this.Mapper ?? this.ServiceProvider.GetServiceIfAvailable <IDatabaseReaderMapper <TResult> >(() => new DatabaseReaderMapper <TResult>(this.Connector)); if (this.Mapper == null) { throw new OrmException("The mapper can not be null."); } }
/// <summary> /// Executes after the initialization. /// </summary> protected override void AfterInitialize() { base.AfterInitialize(); this.Mapper = this.Mapper ?? this.ServiceProvider.GetServiceIfAvailable <IDatabaseReaderMapper <TResult> >(() => new DatabaseReaderMapper <TResult>(this.Connector, new TableTypeDescriptor(typeof(TResult)))); if (this.Mapper == null) { throw new OrmException("The mapper can not be null."); } }
/// <summary> /// Initializes a new instance of the ReaderStoredProcedure. /// </summary> /// <param name="serviceProvider">The service provider.</param> /// <param name="connector">The database connector.</param> /// <param name="mapper1">The first result mapper.</param> /// <param name="mapper2">The second result mapper.</param> /// <param name="mapper3">The third result mapper.</param> public ReaderStoredProcedure( IServiceProvider serviceProvider, IDatabaseConnector connector, IDatabaseReaderMapper <TResult1> mapper1, IDatabaseReaderMapper <TResult2> mapper2, IDatabaseReaderMapper <TResult3> mapper3) : base(serviceProvider, connector) { this.Mapper1 = mapper1; this.Mapper2 = mapper2; this.Mapper3 = mapper3; }
/// <summary> /// Initializes a new instance of the ReaderStoredProcedure. /// </summary> /// <param name="connector">The database connector.</param> /// <param name="mapper1">The first result mapper.</param> /// <param name="mapper2">The second result mapper.</param> /// <param name="mapper3">The third result mapper.</param> /// <param name="mapper4">The fourth result mapper.</param> public ReaderStoredProcedure( IDatabaseConnector connector, IDatabaseReaderMapper <TResult1> mapper1, IDatabaseReaderMapper <TResult2> mapper2, IDatabaseReaderMapper <TResult3> mapper3, IDatabaseReaderMapper <TResult4> mapper4) : base(connector) { this.Mapper1 = mapper1; this.Mapper2 = mapper2; this.Mapper3 = mapper3; this.Mapper4 = mapper4; }
/// <summary> /// Initializes a new instance of the ReaderStoredProcedure. /// </summary> /// <param name="connector">The database connector.</param> /// <param name="mapper1">The first result mapper.</param> /// <param name="mapper2">The second result mapper.</param> /// <param name="mapper3">The third result mapper.</param> /// <param name="mapper4">The fourth result mapper.</param> /// <param name="mapper5">The fifth result mapper.</param> /// <param name="mapper6">The sixth result mapper.</param> /// <param name="mapper7">The seventh result mapper.</param> public ReaderStoredProcedure( IDatabaseConnector connector, IDatabaseReaderMapper <TResult1> mapper1, IDatabaseReaderMapper <TResult2> mapper2, IDatabaseReaderMapper <TResult3> mapper3, IDatabaseReaderMapper <TResult4> mapper4, IDatabaseReaderMapper <TResult5> mapper5, IDatabaseReaderMapper <TResult6> mapper6, IDatabaseReaderMapper <TResult7> mapper7) : base(connector) { this.Mapper1 = mapper1; this.Mapper2 = mapper2; this.Mapper3 = mapper3; this.Mapper4 = mapper4; this.Mapper5 = mapper5; this.Mapper6 = mapper6; this.Mapper7 = mapper7; }
/// <summary> /// Initializes a new instance of the ReaderStoredProcedure. /// </summary> /// <param name="serviceProvider">The service provider.</param> /// <param name="connector">The database connector.</param> /// <param name="mapper1">The first result mapper.</param> /// <param name="mapper2">The second result mapper.</param> /// <param name="mapper3">The third result mapper.</param> /// <param name="mapper4">The fourth result mapper.</param> /// <param name="mapper5">The fifth result mapper.</param> /// <param name="mapper6">The sixth result mapper.</param> /// <param name="mapper7">The seventh result mapper.</param> /// <param name="mapper8">The eighth result mapper.</param> public ReaderStoredProcedure( IServiceProvider serviceProvider, IDatabaseConnector connector, IDatabaseReaderMapper <TResult1> mapper1, IDatabaseReaderMapper <TResult2> mapper2, IDatabaseReaderMapper <TResult3> mapper3, IDatabaseReaderMapper <TResult4> mapper4, IDatabaseReaderMapper <TResult5> mapper5, IDatabaseReaderMapper <TResult6> mapper6, IDatabaseReaderMapper <TResult7> mapper7, IDatabaseReaderMapper <TResult8> mapper8) : base(serviceProvider, connector) { this.Mapper1 = mapper1; this.Mapper2 = mapper2; this.Mapper3 = mapper3; this.Mapper4 = mapper4; this.Mapper5 = mapper5; this.Mapper6 = mapper6; this.Mapper7 = mapper7; this.Mapper8 = mapper8; }
/// <summary> /// Initializes a new instance of the ReaderStoredProcedure. /// </summary> /// <param name="connector">The database connector.</param> /// <param name="mapper">The result mapper.</param> public ReaderStoredProcedure(IDatabaseConnector connector, IDatabaseReaderMapper <TResult> mapper) : base(connector) { this.Mapper = mapper; }