From d5e7564bb8132ee5d1d58597426e3b6aedf76090 Mon Sep 17 00:00:00 2001 From: Alexander Zaytsev Date: Fri, 6 Dec 2013 10:39:47 +1300 Subject: [PATCH 1/3] NH-3431 - Mass replace usage of System.Data classes to System.Data.Common classes --- .../DoubleStringType.cs | 6 +- .../MultiplicityType.cs | 6 +- .../NHSpecific/NullInt32UserType.cs | 8 +- .../NHSpecific/NullableInt32Type.cs | 8 +- .../NHSpecific/NullableTypesType.cs | 6 +- .../Northwind/Entities/User.cs | 6 +- src/NHibernate.Test/Cascade/RefreshFixture.cs | 5 +- .../Loquacious/LambdaConfigurationFixture.cs | 2 +- .../NamedConnectionStringFixture.cs | 8 +- .../ConnectionTest/AggressiveReleaseTest.cs | 6 +- src/NHibernate.Test/DateTimeOffsetUserType.cs | 8 +- .../DebugConnectionProvider.cs | 13 +-- .../DialectTest/DialectFixture.cs | 9 +- .../DriverTest/FirebirdClientDriverFixture.cs | 16 ++-- .../DriverTest/OracleClientDriverFixture.cs | 6 +- .../OracleDataClientDriverFixture.cs | 6 +- .../ExceptionsTest/NullQueryTest.cs | 5 +- .../SQLExceptionConversionTest.cs | 11 +-- .../Insertordering/InsertOrderingFixture.cs | 9 +- .../Join/JoinCompositeKeyTest.cs | 1 - src/NHibernate.Test/Join/JoinTest.cs | 7 +- src/NHibernate.Test/Legacy/FooBarTest.cs | 18 ++-- src/NHibernate.Test/Linq/QueryTimeoutTests.cs | 7 +- .../MappersTests/PropertyMapperTest.cs | 10 +-- .../DataReaderWrapperTest/TheUserType.cs | 5 +- .../NHSpecificTest/EmptyMappingsFixture.cs | 3 +- .../DoubleStringUserType.cs | 5 +- .../ExampleUserType.cs | 7 +- .../NHSpecificTest/GetSetHelperFixture.cs | 4 +- .../NH1355/UserTypeTimestamp.cs | 5 +- .../NHSpecificTest/NH1405/Fixture.cs | 6 +- .../NHSpecificTest/NH1483/Fixture.cs | 4 +- .../SnapshotIsolationUpdateConflictTest.cs | 3 +- .../NH1763/EmptyStringUserType.cs | 6 +- .../NHSpecificTest/NH1907/MyType.cs | 10 +-- .../NHSpecificTest/NH1985/SampleTest.cs | 10 +-- .../NHSpecificTest/NH1989/Fixture.cs | 7 +- .../NHSpecificTest/NH2057/Fixture.cs | 1 - .../NHSpecificTest/NH2069/Fixture.cs | 1 - .../NHSpecificTest/NH2077/Fixture.cs | 1 - .../NHSpecificTest/NH2113/Fixture.cs | 1 - .../NHSpecificTest/NH2204/Fixture.cs | 4 +- .../NHSpecificTest/NH2234/MyType.cs | 6 +- .../InvalidCustomCompositeUserTypeBase.cs | 6 +- .../NH2324/CompositeUserType.cs | 14 +-- .../NH2392/PhoneNumberUserType.cs | 9 +- .../NH2394/EnumStringUserType.cs | 1 - .../NH2394/PhoneNumberUserType.cs | 9 +- .../NHSpecificTest/NH2420/Fixture.cs | 4 +- .../NHSpecificTest/NH2839/FixtureByCode.cs | 10 +-- .../NHSpecificTest/NH3004/Fixture.cs | 1 - .../NH3004/TestSqlClientDriver.cs | 1 - .../NHSpecificTest/NH3202/Fixture.cs | 6 +- .../NHSpecificTest/NH3237/EnumUserType.cs | 8 +- .../NHSpecificTest/NH3874/IntWrapperType.cs | 10 +-- .../NHSpecificTest/NH732/Fixture.cs | 12 ++- .../NHSpecificTest/SetFixture.cs | 12 +-- .../NHSpecificTest/UserTypeFixture.cs | 8 +- .../Pagination/CustomMsSqlDriver.cs | 8 +- .../SecondLevelCacheTest.cs | 10 +-- .../SqlTest/MonetaryAmountUserType.cs | 14 +-- .../SqlTest/NullDateUserType.cs | 8 +- .../TransactionNotificationFixture.cs | 4 +- src/NHibernate.Test/TestCase.cs | 9 +- src/NHibernate.Test/TestDialect.cs | 1 - .../TransactionTest/TransactionFixture.cs | 4 +- .../TransactionNotificationFixture.cs | 4 +- .../TypeParameters/DefaultValueIntegerType.cs | 8 +- .../TypeParameters/TypeParameterTest.cs | 9 +- .../TypesTest/BinaryTypeFixture.cs | 2 +- .../TypesTest/GuidTypeFixture.cs | 3 +- .../VersionTest/Db/MsSQL/BinaryTimestamp.cs | 5 +- src/NHibernate/AdoNet/AbstractBatcher.cs | 85 +++++++++--------- src/NHibernate/AdoNet/ConnectionManager.cs | 19 ++-- src/NHibernate/AdoNet/Expectations.cs | 8 +- src/NHibernate/AdoNet/IExpectation.cs | 5 +- .../AdoNet/MySqlClientBatchingBatcher.cs | 5 +- .../AdoNet/MySqlClientSqlCommandSet.cs | 8 +- src/NHibernate/AdoNet/NonBatchingBatcher.cs | 10 +-- .../AdoNet/OracleDataClientBatchingBatcher.cs | 9 +- src/NHibernate/AdoNet/ResultSetWrapper.cs | 13 +-- .../AdoNet/SqlClientBatchingBatcher.cs | 5 +- .../AdoNet/Util/SqlStatementLogger.cs | 27 +++--- .../AbstractPersistentCollection.cs | 12 +-- .../Generic/PersistentGenericBag.cs | 4 +- .../Generic/PersistentGenericIdentifierBag.cs | 4 +- .../Generic/PersistentGenericList.cs | 4 +- .../Generic/PersistentGenericMap.cs | 4 +- .../Generic/PersistentGenericSet.cs | 4 +- .../Collection/IPersistentCollection.cs | 12 +-- .../Collection/PersistentArrayHolder.cs | 4 +- .../Connection/ConnectionProvider.cs | 22 ++--- .../Connection/DriverConnectionProvider.cs | 21 +++-- .../Connection/IConnectionProvider.cs | 18 ++-- .../UserSuppliedConnectionProvider.cs | 16 ++-- src/NHibernate/Criterion/IProjection.cs | 3 +- .../Dialect/Function/CastFunction.cs | 1 - src/NHibernate/Dialect/GenericDialect.cs | 1 + src/NHibernate/Dialect/InformixDialect1000.cs | 1 - .../Dialect/Lock/SelectLockingStrategy.cs | 5 +- .../Dialect/Lock/UpdateLockingStrategy.cs | 3 +- src/NHibernate/Dialect/MySQL55Dialect.cs | 1 + .../Dialect/Schema/AbstractTableMetadata.cs | 1 - .../Dialect/SybaseSQLAnywhere10Dialect.cs | 2 +- .../Driver/BasicResultSetsCommand.cs | 15 ++-- ...erFactoryDriveConnectionCommandProvider.cs | 5 +- src/NHibernate/Driver/DriverBase.cs | 78 ++++++++-------- src/NHibernate/Driver/FirebirdClientDriver.cs | 11 +-- .../Driver/IDriveConnectionCommandProvider.cs | 6 +- src/NHibernate/Driver/IDriver.cs | 51 +++++------ src/NHibernate/Driver/IResultSetsCommand.cs | 4 +- src/NHibernate/Driver/MySqlDataDriver.cs | 4 +- src/NHibernate/Driver/NDataReader.cs | 34 +++---- src/NHibernate/Driver/NHybridDataReader.cs | 38 ++++---- src/NHibernate/Driver/NpgsqlDriver.cs | 3 +- src/NHibernate/Driver/OdbcDriver.cs | 15 ++-- src/NHibernate/Driver/OleDbDriver.cs | 6 +- src/NHibernate/Driver/OracleClientDriver.cs | 5 +- .../Driver/OracleDataClientDriver.cs | 9 +- .../Driver/OracleLiteDataClientDriver.cs | 3 +- .../Driver/OracleManagedDataClientDriver.cs | 7 +- .../Driver/ReflectionBasedDriver.cs | 7 +- ...eflectionDriveConnectionCommandProvider.cs | 10 +-- src/NHibernate/Driver/SQLite20Driver.cs | 8 +- src/NHibernate/Driver/Sql2008ClientDriver.cs | 5 +- src/NHibernate/Driver/SqlClientDriver.cs | 35 ++++---- src/NHibernate/Driver/SqlServerCeDriver.cs | 15 ++-- src/NHibernate/Driver/SqlStringFormatter.cs | 4 +- src/NHibernate/Engine/IBatcher.cs | 63 ++++++------- .../Engine/ISessionFactoryImplementor.cs | 4 +- src/NHibernate/Engine/ISessionImplementor.cs | 4 +- .../Engine/Loading/CollectionLoadContext.cs | 12 +-- src/NHibernate/Engine/Loading/LoadContexts.cs | 12 +-- .../Engine/Loading/LoadingCollectionEntry.cs | 8 +- .../Engine/Query/NativeSQLQueryPlan.cs | 3 +- src/NHibernate/Engine/RowSelection.cs | 4 +- .../Engine/Transaction/IIsolatedWork.cs | 4 +- src/NHibernate/Engine/Transaction/Isolater.cs | 1 - src/NHibernate/Engine/TransactionHelper.cs | 5 +- .../ANTLR/Exec/AbstractStatementExecutor.cs | 13 +-- .../Hql/Ast/ANTLR/Exec/BasicExecutor.cs | 2 +- .../ANTLR/Exec/MultiTableDeleteExecutor.cs | 2 +- .../ANTLR/Exec/MultiTableUpdateExecutor.cs | 2 +- src/NHibernate/IInterceptor.cs | 4 +- src/NHibernate/ISession.cs | 10 +-- src/NHibernate/ISessionFactory.cs | 8 +- src/NHibernate/IStatelessSession.cs | 3 +- src/NHibernate/ITransaction.cs | 7 +- .../Id/Enhanced/SequenceStructure.cs | 4 +- src/NHibernate/Id/Enhanced/TableGenerator.cs | 23 ++--- src/NHibernate/Id/Enhanced/TableStructure.cs | 11 +-- .../Id/IdentifierGeneratorFactory.cs | 14 +-- src/NHibernate/Id/IdentityGenerator.cs | 9 +- src/NHibernate/Id/IncrementGenerator.cs | 2 +- .../Id/Insert/AbstractReturningDelegate.cs | 9 +- .../Id/Insert/AbstractSelectingDelegate.cs | 10 +-- src/NHibernate/Id/Insert/IBinder.cs | 4 +- .../Id/Insert/OutputParamReturningDelegate.cs | 11 +-- src/NHibernate/Id/NativeGuidGenerator.cs | 5 +- src/NHibernate/Id/SelectGenerator.cs | 6 +- src/NHibernate/Id/SequenceGenerator.cs | 6 +- src/NHibernate/Id/TableGenerator.cs | 12 +-- src/NHibernate/Impl/AbstractSessionImpl.cs | 4 +- src/NHibernate/Impl/EnumerableImpl.cs | 31 ++++--- src/NHibernate/Impl/SessionFactoryImpl.cs | 16 ++-- src/NHibernate/Impl/SessionImpl.cs | 13 +-- src/NHibernate/Impl/StatelessSessionImpl.cs | 5 +- .../Loader/Criteria/CriteriaLoader.cs | 6 +- src/NHibernate/Loader/Custom/CustomLoader.cs | 18 ++-- .../Loader/Entity/AbstractEntityLoader.cs | 4 +- .../Loader/Entity/CollectionElementLoader.cs | 4 +- src/NHibernate/Loader/Hql/QueryLoader.cs | 12 +-- src/NHibernate/Loader/Loader.cs | 89 +++++++++---------- .../AbstractExplicitParameterSpecification.cs | 6 +- ...llectionSelectorParameterSpecifications.cs | 8 +- ...llectionFilterKeyParameterSpecification.cs | 6 +- .../CriteriaNamedParameterSpecification.cs | 6 +- .../DynamicFilterParameterSpecification.cs | 16 ++-- .../Param/IParameterSpecification.cs | 10 +-- .../Param/NamedParameterSpecification.cs | 6 +- .../Param/ParametersBackTrackExtensions.cs | 2 +- .../Param/PositionalParameterSpecification.cs | 6 +- .../Param/QuerySkipParameterSpecification.cs | 6 +- .../Param/QueryTakeParameterSpecification.cs | 6 +- .../VersionTypeSeedParameterSpecification.cs | 6 +- .../Collection/AbstractCollectionPersister.cs | 54 ++++++----- .../Collection/BasicCollectionPersister.cs | 3 +- .../Collection/ICollectionPersister.cs | 18 ++-- .../Collection/OneToManyPersister.cs | 5 +- .../Entity/AbstractEntityPersister.cs | 63 ++++++------- src/NHibernate/Persister/Entity/ILoadable.cs | 4 +- .../SqlCommand/ISqlStringBuilder.cs | 2 +- src/NHibernate/SqlCommand/SqlCommandImpl.cs | 27 +++--- .../SqlTypes/AnsiStringFixedLengthSqlType.cs | 9 +- src/NHibernate/SqlTypes/AnsiStringSqlType.cs | 9 +- src/NHibernate/SqlTypes/BinaryBlobSqlType.cs | 9 +- src/NHibernate/SqlTypes/BinarySqlType.cs | 9 +- src/NHibernate/SqlTypes/SqlType.cs | 3 +- src/NHibernate/SqlTypes/StringClobSqlType.cs | 11 +-- .../SqlTypes/StringFixedLengthSqlType.cs | 9 +- src/NHibernate/SqlTypes/StringSqlType.cs | 9 +- .../Tool/hbm2ddl/DatabaseMetadata.cs | 5 +- .../Tool/hbm2ddl/IConnectionHelper.cs | 1 - .../ManagedProviderConnectionHelper.cs | 3 +- src/NHibernate/Tool/hbm2ddl/SchemaExport.cs | 13 +-- src/NHibernate/Tool/hbm2ddl/SchemaUpdate.cs | 3 +- .../Tool/hbm2ddl/SchemaValidator.cs | 2 +- ...pliedConnectionProviderConnectionHelper.cs | 2 +- .../Transaction/AdoNetTransactionFactory.cs | 4 +- src/NHibernate/Transaction/AdoTransaction.cs | 41 ++++----- src/NHibernate/Type/AbstractBinaryType.cs | 10 +-- src/NHibernate/Type/AbstractCharType.cs | 10 +-- .../Type/AbstractDateTimeSpecificKindType.cs | 8 +- src/NHibernate/Type/AbstractEnumType.cs | 1 - src/NHibernate/Type/AbstractStringType.cs | 10 +-- src/NHibernate/Type/AbstractType.cs | 24 ++--- src/NHibernate/Type/AnyType.cs | 12 +-- src/NHibernate/Type/ArrayType.cs | 4 +- src/NHibernate/Type/BinaryBlobType.cs | 2 +- src/NHibernate/Type/BooleanType.cs | 9 +- src/NHibernate/Type/ByteType.cs | 9 +- src/NHibernate/Type/CharBooleanType.cs | 9 +- src/NHibernate/Type/ClassMetaType.cs | 12 +-- src/NHibernate/Type/CollectionType.cs | 12 +-- src/NHibernate/Type/ComponentType.cs | 12 +-- src/NHibernate/Type/CompositeCustomType.cs | 10 +-- src/NHibernate/Type/CultureInfoType.cs | 7 +- src/NHibernate/Type/CustomType.cs | 10 +-- src/NHibernate/Type/DateTime2Type.cs | 7 +- src/NHibernate/Type/DateTimeOffSetType.cs | 9 +- src/NHibernate/Type/DateTimeType.cs | 11 +-- src/NHibernate/Type/DateType.cs | 9 +- src/NHibernate/Type/DbTimestampType.cs | 4 +- src/NHibernate/Type/DecimalType.cs | 9 +- src/NHibernate/Type/DoubleType.cs | 10 +-- src/NHibernate/Type/EntityType.cs | 12 +-- src/NHibernate/Type/EnumCharType.cs | 10 +-- src/NHibernate/Type/EnumStringType.cs | 17 ++-- src/NHibernate/Type/GuidType.cs | 9 +- src/NHibernate/Type/IType.cs | 16 ++-- src/NHibernate/Type/IType.cs.xmldoc | 34 +++---- src/NHibernate/Type/Int16Type.cs | 11 +-- src/NHibernate/Type/Int32Type.cs | 11 +-- src/NHibernate/Type/Int64Type.cs | 9 +- src/NHibernate/Type/ManyToOneType.cs | 12 +-- src/NHibernate/Type/MetaType.cs | 10 +-- src/NHibernate/Type/NullableType.cs | 72 +++++++-------- src/NHibernate/Type/OneToOneType.cs | 8 +- src/NHibernate/Type/PersistentEnumType.cs | 13 ++- src/NHibernate/Type/SByteType.cs | 9 +- src/NHibernate/Type/SerializableType.cs | 7 +- src/NHibernate/Type/SingleType.cs | 9 +- src/NHibernate/Type/SpecialOneToOneType.cs | 3 +- src/NHibernate/Type/StringClobType.cs | 2 +- src/NHibernate/Type/TicksType.cs | 9 +- src/NHibernate/Type/TimeAsTimeSpanType.cs | 11 +-- src/NHibernate/Type/TimeSpanType.cs | 11 +-- src/NHibernate/Type/TimeType.cs | 9 +- src/NHibernate/Type/TimestampType.cs | 18 ++-- src/NHibernate/Type/TypeType.cs | 29 +++--- src/NHibernate/Type/UInt16Type.cs | 9 +- src/NHibernate/Type/UInt32Type.cs | 9 +- src/NHibernate/Type/UInt64Type.cs | 9 +- src/NHibernate/Type/UriType.cs | 10 +-- src/NHibernate/Type/XDocType.cs | 10 +-- src/NHibernate/Type/XmlDocType.cs | 10 +-- .../UserTypes/ICompositeUserType.cs | 10 +-- src/NHibernate/UserTypes/IUserType.cs | 10 +-- 268 files changed, 1387 insertions(+), 1373 deletions(-) diff --git a/src/NHibernate.DomainModel/DoubleStringType.cs b/src/NHibernate.DomainModel/DoubleStringType.cs index f9a23446d11..4c794cb6f3d 100644 --- a/src/NHibernate.DomainModel/DoubleStringType.cs +++ b/src/NHibernate.DomainModel/DoubleStringType.cs @@ -1,5 +1,5 @@ using System; -using System.Data; +using System.Data.Common; using NHibernate.Engine; using NHibernate.Type; @@ -49,7 +49,7 @@ public bool IsMutable get { return true; } } - public Object NullSafeGet(IDataReader rs, string[] names, ISessionImplementor session, Object owner) + public Object NullSafeGet(DbDataReader rs, string[] names, ISessionImplementor session, Object owner) { string first = (string) NHibernateUtil.String.NullSafeGet(rs, names[0], session, owner); string second = (string) NHibernateUtil.String.NullSafeGet(rs, names[1], session, owner); @@ -58,7 +58,7 @@ public Object NullSafeGet(IDataReader rs, string[] names, ISessionImplementor se } - public void NullSafeSet(IDbCommand st, Object value, int index, bool[] settable, ISessionImplementor session) + public void NullSafeSet(DbCommand st, Object value, int index, bool[] settable, ISessionImplementor session) { string[] strings = (value == null) ? new string[2] : (string[]) value; diff --git a/src/NHibernate.DomainModel/MultiplicityType.cs b/src/NHibernate.DomainModel/MultiplicityType.cs index 6229e119a41..88bb0627ef1 100644 --- a/src/NHibernate.DomainModel/MultiplicityType.cs +++ b/src/NHibernate.DomainModel/MultiplicityType.cs @@ -1,5 +1,5 @@ using System; -using System.Data; +using System.Data.Common; using System.Linq; using NHibernate.Engine; using NHibernate.Type; @@ -74,7 +74,7 @@ public int GetHashCode(object x) } } - public object NullSafeGet(IDataReader rs, String[] names, ISessionImplementor session, Object owner) + public object NullSafeGet(DbDataReader rs, String[] names, ISessionImplementor session, Object owner) { int c = (int) NHibernateUtil.Int32.NullSafeGet(rs, names[0], session, owner); GlarchProxy g = (GlarchProxy) NHibernateUtil.Entity(typeof(Glarch)).NullSafeGet(rs, names[1], session, owner); @@ -84,7 +84,7 @@ public object NullSafeGet(IDataReader rs, String[] names, ISessionImplementor se return m; } - public void NullSafeSet(IDbCommand st, Object value, int index, bool[] settable, ISessionImplementor session) + public void NullSafeSet(DbCommand st, Object value, int index, bool[] settable, ISessionImplementor session) { Multiplicity o = (Multiplicity) value; GlarchProxy g; diff --git a/src/NHibernate.DomainModel/NHSpecific/NullInt32UserType.cs b/src/NHibernate.DomainModel/NHSpecific/NullInt32UserType.cs index f8251a4c259..c78a5b381ff 100644 --- a/src/NHibernate.DomainModel/NHSpecific/NullInt32UserType.cs +++ b/src/NHibernate.DomainModel/NHSpecific/NullInt32UserType.cs @@ -1,5 +1,5 @@ using System; -using System.Data; +using System.Data.Common; using NHibernate.SqlTypes; using NHibernate.Type; @@ -46,11 +46,11 @@ public object DeepCopy(object value) return value; } - public void NullSafeSet(IDbCommand cmd, object value, int index) + public void NullSafeSet(DbCommand cmd, object value, int index) { if (value.Equals(0)) { - ((IDbDataParameter) cmd.Parameters[index]).Value = DBNull.Value; + cmd.Parameters[index].Value = DBNull.Value; } else { @@ -63,7 +63,7 @@ public System.Type ReturnedType get { return typeof(Int32); } } - public object NullSafeGet(IDataReader rs, string[] names, object owner) + public object NullSafeGet(DbDataReader rs, string[] names, object owner) { return _int32Type.NullSafeGet(rs, names); } diff --git a/src/NHibernate.DomainModel/NHSpecific/NullableInt32Type.cs b/src/NHibernate.DomainModel/NHSpecific/NullableInt32Type.cs index 6dd32abbdf2..472178a2615 100644 --- a/src/NHibernate.DomainModel/NHSpecific/NullableInt32Type.cs +++ b/src/NHibernate.DomainModel/NHSpecific/NullableInt32Type.cs @@ -1,5 +1,5 @@ using System; -using System.Data; +using System.Data.Common; using NHibernate.SqlTypes; using NHibernate.Type; @@ -26,14 +26,14 @@ public override System.Type ReturnedClass get { return typeof(NullableInt32); } } - public override object Get(IDataReader rs, int index) + public override object Get(DbDataReader rs, int index) { return new NullableInt32(Convert.ToInt32(rs[index])); } - public override void Set(IDbCommand cmd, object value, int index) + public override void Set(DbCommand cmd, object value, int index) { - IDataParameter parameter = (IDataParameter) cmd.Parameters[index]; + var parameter = cmd.Parameters[index]; NullableInt32 nullableValue = (NullableInt32) value; if (nullableValue.HasValue) diff --git a/src/NHibernate.DomainModel/NHSpecific/NullableTypesType.cs b/src/NHibernate.DomainModel/NHSpecific/NullableTypesType.cs index 67083b6e763..34a2ac14542 100644 --- a/src/NHibernate.DomainModel/NHSpecific/NullableTypesType.cs +++ b/src/NHibernate.DomainModel/NHSpecific/NullableTypesType.cs @@ -1,5 +1,5 @@ using System; -using System.Data; +using System.Data.Common; using NHibernate.SqlTypes; using NHibernate.Type; @@ -17,7 +17,7 @@ public NullableTypesType(SqlType type) : base(type) { } - public override object NullSafeGet(IDataReader rs, string name) + public override object NullSafeGet(DbDataReader rs, string name) { object value = base.NullSafeGet(rs, name); if (value == null) @@ -30,7 +30,7 @@ public override object NullSafeGet(IDataReader rs, string name) } } - public override object Get(IDataReader rs, string name) + public override object Get(DbDataReader rs, string name) { return Get(rs, rs.GetOrdinal(name)); } diff --git a/src/NHibernate.DomainModel/Northwind/Entities/User.cs b/src/NHibernate.DomainModel/Northwind/Entities/User.cs index 295b3b4d98a..c8354f208ed 100644 --- a/src/NHibernate.DomainModel/Northwind/Entities/User.cs +++ b/src/NHibernate.DomainModel/Northwind/Entities/User.cs @@ -1,5 +1,5 @@ using System; -using System.Data; +using System.Data.Common; using NHibernate.Type; namespace NHibernate.DomainModel.Northwind.Entities @@ -71,7 +71,7 @@ public class EnumStoredAsStringType : EnumStringType public EnumStoredAsStringType() : base(typeof(EnumStoredAsString), 12) { } - public override void Set(IDbCommand cmd, object value, int index) + public override void Set(DbCommand cmd, object value, int index) { if (value is EnumStoredAsString && (EnumStoredAsString)value == EnumStoredAsString.Unspecified) base.Set(cmd, null, index); @@ -79,7 +79,7 @@ public override void Set(IDbCommand cmd, object value, int index) base.Set(cmd, value, index); } - public override object Get(IDataReader rs, int index) + public override object Get(DbDataReader rs, int index) { object obj = base.Get(rs, index); if (obj == null) return EnumStoredAsString.Unspecified; diff --git a/src/NHibernate.Test/Cascade/RefreshFixture.cs b/src/NHibernate.Test/Cascade/RefreshFixture.cs index edf869a128b..32f6dddba9d 100644 --- a/src/NHibernate.Test/Cascade/RefreshFixture.cs +++ b/src/NHibernate.Test/Cascade/RefreshFixture.cs @@ -1,6 +1,7 @@ using System; using System.Collections; using System.Data; +using System.Data.Common; using NUnit.Framework; namespace NHibernate.Test.Cascade @@ -51,8 +52,8 @@ public void RefreshCascade() private void UpdateStatuses(ISession session) { - IDbConnection conn = session.Connection; - IDbCommand cmd = conn.CreateCommand(); + var conn = session.Connection; + var cmd = conn.CreateCommand(); cmd.CommandText = "UPDATE T_JOB SET JOB_STATUS = 1"; cmd.CommandType = CommandType.Text; session.Transaction.Enlist(cmd); diff --git a/src/NHibernate.Test/CfgTest/Loquacious/LambdaConfigurationFixture.cs b/src/NHibernate.Test/CfgTest/Loquacious/LambdaConfigurationFixture.cs index 8d13ea6e7c8..cc464aafafa 100644 --- a/src/NHibernate.Test/CfgTest/Loquacious/LambdaConfigurationFixture.cs +++ b/src/NHibernate.Test/CfgTest/Loquacious/LambdaConfigurationFixture.cs @@ -1,3 +1,4 @@ +using System.Data; using NHibernate.AdoNet; using NHibernate.Bytecode; using NHibernate.Cache; @@ -8,7 +9,6 @@ using NHibernate.Linq.Functions; using NHibernate.Type; using NUnit.Framework; -using System.Data; using NHibernate.Exceptions; namespace NHibernate.Test.CfgTest.Loquacious diff --git a/src/NHibernate.Test/ConnectionStringTest/NamedConnectionStringFixture.cs b/src/NHibernate.Test/ConnectionStringTest/NamedConnectionStringFixture.cs index d67e41cb89b..2cd8ceee292 100644 --- a/src/NHibernate.Test/ConnectionStringTest/NamedConnectionStringFixture.cs +++ b/src/NHibernate.Test/ConnectionStringTest/NamedConnectionStringFixture.cs @@ -1,6 +1,6 @@ using System; using System.Collections.Generic; -using System.Data; +using System.Data.Common; using NHibernate.Connection; using NUnit.Framework; using Environment=NHibernate.Cfg.Environment; @@ -56,10 +56,10 @@ public string PublicConnectionString } /// - /// Get an open . + /// Get an open . /// - /// An open . - public override IDbConnection GetConnection() + /// An open . + public override DbConnection GetConnection() { throw new NotImplementedException(); } diff --git a/src/NHibernate.Test/ConnectionTest/AggressiveReleaseTest.cs b/src/NHibernate.Test/ConnectionTest/AggressiveReleaseTest.cs index 8aa9d2497d4..1fb7735f136 100644 --- a/src/NHibernate.Test/ConnectionTest/AggressiveReleaseTest.cs +++ b/src/NHibernate.Test/ConnectionTest/AggressiveReleaseTest.cs @@ -1,7 +1,7 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Data; +using System.Data.Common; using NHibernate.Cfg; using NHibernate.Util; using NUnit.Framework; @@ -176,7 +176,7 @@ public void SuppliedConnection() { Prepare(); - IDbConnection originalConnection = sessions.ConnectionProvider.GetConnection(); + DbConnection originalConnection = sessions.ConnectionProvider.GetConnection(); ISession session = sessions.OpenSession(originalConnection); Silly silly = new Silly("silly"); @@ -203,7 +203,7 @@ public void SuppliedConnection() // Prepare(); // ISession s = GetSessionUnderTest(); - // IDbConnection conn = s.Connection; + // DbConnection conn = s.Connection; // Assert.IsTrue(((SessionImpl) s).ConnectionManager.HasBorrowedConnection); // conn.Close(); // Assert.IsFalse(((SessionImpl) s).ConnectionManager.HasBorrowedConnection); diff --git a/src/NHibernate.Test/DateTimeOffsetUserType.cs b/src/NHibernate.Test/DateTimeOffsetUserType.cs index 4508ebde979..712e0f0976e 100644 --- a/src/NHibernate.Test/DateTimeOffsetUserType.cs +++ b/src/NHibernate.Test/DateTimeOffsetUserType.cs @@ -1,5 +1,6 @@ using System; using System.Data; +using System.Data.Common; using NHibernate.SqlTypes; using NHibernate.UserTypes; @@ -28,7 +29,7 @@ public SqlType[] SqlTypes get { return new[] { new SqlType(DbType.DateTime) }; } } - public object NullSafeGet(IDataReader dr, string[] names, object owner) + public object NullSafeGet(DbDataReader dr, string[] names, object owner) { var name = names[0]; int index = dr.GetOrdinal(name); @@ -61,7 +62,7 @@ public object NullSafeGet(IDataReader dr, string[] names, object owner) } } - public void NullSafeSet(IDbCommand cmd, object value, int index) + public void NullSafeSet(DbCommand cmd, object value, int index) { if (value == null) { @@ -72,8 +73,7 @@ public void NullSafeSet(IDbCommand cmd, object value, int index) DateTimeOffset dateTimeOffset = (DateTimeOffset)value; DateTime paramVal = dateTimeOffset.ToOffset(Offset).DateTime; - IDataParameter parameter = (IDataParameter)cmd.Parameters[index]; - parameter.Value = paramVal; + cmd.Parameters[index].Value = paramVal; } } diff --git a/src/NHibernate.Test/DebugConnectionProvider.cs b/src/NHibernate.Test/DebugConnectionProvider.cs index c23b71f9655..f84be723860 100644 --- a/src/NHibernate.Test/DebugConnectionProvider.cs +++ b/src/NHibernate.Test/DebugConnectionProvider.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Concurrent; using System.Data; +using System.Data.Common; using System.Linq; using NHibernate.Connection; @@ -12,13 +13,13 @@ namespace NHibernate.Test /// public class DebugConnectionProvider : DriverConnectionProvider { - private ConcurrentDictionary connections = new ConcurrentDictionary(); + private ConcurrentDictionary connections = new ConcurrentDictionary(); - public override IDbConnection GetConnection() + public override DbConnection GetConnection() { try { - IDbConnection connection = base.GetConnection(); + var connection = base.GetConnection(); connections.TryAdd(connection, 0); return connection; } @@ -28,7 +29,7 @@ public override IDbConnection GetConnection() } } - public override void CloseConnection(IDbConnection conn) + public override void CloseConnection(DbConnection conn) { base.CloseConnection(conn); byte _; @@ -40,8 +41,8 @@ public bool HasOpenConnections get { // Disposing of an ISession does not call CloseConnection (should it???) - // so a Diposed of ISession will leave an IDbConnection in the list but - // the IDbConnection will be closed (atleast with MsSql it works this way). + // so a Diposed of ISession will leave an DbConnection in the list but + // the DbConnection will be closed (atleast with MsSql it works this way). return connections.Keys.Any(conn => conn.State != ConnectionState.Closed); } } diff --git a/src/NHibernate.Test/DialectTest/DialectFixture.cs b/src/NHibernate.Test/DialectTest/DialectFixture.cs index 7a4814b3d52..50a9aa12661 100644 --- a/src/NHibernate.Test/DialectTest/DialectFixture.cs +++ b/src/NHibernate.Test/DialectTest/DialectFixture.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Data; +using System.Data.Common; using NHibernate.Dialect; using NHibernate.Driver; using NHibernate.Engine; @@ -159,18 +160,16 @@ public void CurrentTimestampSelection() sessions.ConnectionProvider.Configure(conf.Properties); IDriver driver = sessions.ConnectionProvider.Driver; - using (IDbConnection connection = sessions.ConnectionProvider.GetConnection()) + using (var connection = sessions.ConnectionProvider.GetConnection()) { - IDbCommand statement = driver.GenerateCommand(CommandType.Text, new SqlString(dialect.CurrentTimestampSelectString), - new SqlType[0]); + var statement = driver.GenerateCommand(CommandType.Text, new SqlString(dialect.CurrentTimestampSelectString), new SqlType[0]); statement.Connection = connection; - using (IDataReader reader = statement.ExecuteReader()) + using (var reader = statement.ExecuteReader()) { Assert.That(reader.Read(), "should return one record"); Assert.That(reader[0], Is.InstanceOf()); } } } - } } \ No newline at end of file diff --git a/src/NHibernate.Test/DriverTest/FirebirdClientDriverFixture.cs b/src/NHibernate.Test/DriverTest/FirebirdClientDriverFixture.cs index 4d389aec612..82509dd5b39 100644 --- a/src/NHibernate.Test/DriverTest/FirebirdClientDriverFixture.cs +++ b/src/NHibernate.Test/DriverTest/FirebirdClientDriverFixture.cs @@ -1,4 +1,5 @@ using System.Data; +using System.Data.Common; using NHibernate.Driver; using NHibernate.SqlCommand; using NHibernate.SqlTypes; @@ -155,7 +156,7 @@ private void MakeDriver() _connectionString = cfg.GetProperty("connection.connection_string"); } - private IDbConnection MakeConnection() + private DbConnection MakeConnection() { var result = _driver.CreateConnection(); result.ConnectionString = _connectionString; @@ -182,7 +183,7 @@ private int GetEstablishedConnections() } } - private IDbCommand BuildSelectCaseCommand(SqlType paramType) + private DbCommand BuildSelectCaseCommand(SqlType paramType) { var sqlString = new SqlStringBuilder() .Add("select (case when col = ") @@ -197,7 +198,7 @@ private IDbCommand BuildSelectCaseCommand(SqlType paramType) return _driver.GenerateCommand(CommandType.Text, sqlString, new[] { paramType, paramType, paramType }); } - private IDbCommand BuildSelectConcatCommand(SqlType paramType) + private DbCommand BuildSelectConcatCommand(SqlType paramType) { var sqlString = new SqlStringBuilder() .Add("select col || ") @@ -210,7 +211,7 @@ private IDbCommand BuildSelectConcatCommand(SqlType paramType) return _driver.GenerateCommand(CommandType.Text, sqlString, new[] { paramType }); } - private IDbCommand BuildSelectAddCommand(SqlType paramType) + private DbCommand BuildSelectAddCommand(SqlType paramType) { var sqlString = new SqlStringBuilder() .Add("select col + ") @@ -221,7 +222,7 @@ private IDbCommand BuildSelectAddCommand(SqlType paramType) return _driver.GenerateCommand(CommandType.Text, sqlString, new[] { paramType }); } - private IDbCommand BuildInsertWithParamsInSelectCommand(SqlType paramType) + private DbCommand BuildInsertWithParamsInSelectCommand(SqlType paramType) { var sqlString = new SqlStringBuilder() .Add("insert into table1 (col1, col2) ") @@ -232,8 +233,7 @@ private IDbCommand BuildInsertWithParamsInSelectCommand(SqlType paramType) return _driver.GenerateCommand(CommandType.Text, sqlString, new[] { paramType }); } - - private IDbCommand BuildInsertWithParamsInSelectCommandWithSelectInColumnName(SqlType paramType) + private DbCommand BuildInsertWithParamsInSelectCommandWithSelectInColumnName(SqlType paramType) { var sqlString = new SqlStringBuilder() .Add("insert into table1 (col1_select_aaa) ") @@ -245,7 +245,7 @@ private IDbCommand BuildInsertWithParamsInSelectCommandWithSelectInColumnName(Sq return _driver.GenerateCommand(CommandType.Text, sqlString, new[] { paramType }); } - private IDbCommand BuildInsertWithParamsInSelectCommandWithWhereInColumnName(SqlType paramType) + private DbCommand BuildInsertWithParamsInSelectCommandWithWhereInColumnName(SqlType paramType) { var sqlString = new SqlStringBuilder() .Add("insert into table1 (col1_where_aaa) ") diff --git a/src/NHibernate.Test/DriverTest/OracleClientDriverFixture.cs b/src/NHibernate.Test/DriverTest/OracleClientDriverFixture.cs index e62351eba06..7306e106840 100644 --- a/src/NHibernate.Test/DriverTest/OracleClientDriverFixture.cs +++ b/src/NHibernate.Test/DriverTest/OracleClientDriverFixture.cs @@ -1,5 +1,5 @@ using System; -using System.Data; +using System.Data.Common; using NHibernate.Driver; using NUnit.Framework; @@ -18,7 +18,7 @@ public class OracleClientDriverFixture public void ConnectionClassName() { IDriver driver = new OracleClientDriver(); - IDbConnection conn = driver.CreateConnection(); + DbConnection conn = driver.CreateConnection(); Assert.AreEqual("System.Data.OracleClient.OracleConnection", conn.GetType().FullName); } @@ -30,7 +30,7 @@ public void ConnectionClassName() public void CommandClassName() { OracleClientDriver driver = new OracleClientDriver(); - IDbCommand cmd = driver.CreateCommand(); + DbCommand cmd = driver.CreateCommand(); Assert.AreEqual("System.Data.OracleClient.OracleCommand", cmd.GetType().FullName); } diff --git a/src/NHibernate.Test/DriverTest/OracleDataClientDriverFixture.cs b/src/NHibernate.Test/DriverTest/OracleDataClientDriverFixture.cs index d48fceb1a7a..69262bc70b6 100644 --- a/src/NHibernate.Test/DriverTest/OracleDataClientDriverFixture.cs +++ b/src/NHibernate.Test/DriverTest/OracleDataClientDriverFixture.cs @@ -1,5 +1,6 @@ using System; using System.Data; +using System.Data.Common; using NHibernate.Driver; using NHibernate.SqlCommand; using NHibernate.SqlTypes; @@ -25,10 +26,9 @@ public void NoBooleanParameters() builder.Add("select * from table1 where col1="); builder.Add(Parameter.Placeholder); - IDbCommand cmd = - driver.GenerateCommand(CommandType.Text, builder.ToSqlString(), new SqlType[] {SqlTypeFactory.Boolean}); + var cmd = driver.GenerateCommand(CommandType.Text, builder.ToSqlString(), new SqlType[] {SqlTypeFactory.Boolean}); - IDbDataParameter param = cmd.Parameters[0] as IDbDataParameter; + var param = cmd.Parameters[0]; Assert.AreEqual("col1", param.ParameterName, "kept same param name"); Assert.IsFalse(param.DbType == DbType.Boolean, "should not still be a DbType.Boolean"); diff --git a/src/NHibernate.Test/ExceptionsTest/NullQueryTest.cs b/src/NHibernate.Test/ExceptionsTest/NullQueryTest.cs index 1c5e91837f7..3f4ca4e5180 100644 --- a/src/NHibernate.Test/ExceptionsTest/NullQueryTest.cs +++ b/src/NHibernate.Test/ExceptionsTest/NullQueryTest.cs @@ -1,6 +1,7 @@ using System; using System.Collections; using System.Data; +using System.Data.Common; using NHibernate.Exceptions; using NUnit.Framework; @@ -24,10 +25,10 @@ protected override IList Mappings public void BadGrammar() { ISession session = OpenSession(); - IDbConnection connection = session.Connection; + var connection = session.Connection; try { - IDbCommand ps = connection.CreateCommand(); + var ps = connection.CreateCommand(); ps.CommandType = CommandType.Text; ps.CommandText = "whatever"; ps.ExecuteNonQuery(); diff --git a/src/NHibernate.Test/ExceptionsTest/SQLExceptionConversionTest.cs b/src/NHibernate.Test/ExceptionsTest/SQLExceptionConversionTest.cs index d5074071176..dba4199c22e 100644 --- a/src/NHibernate.Test/ExceptionsTest/SQLExceptionConversionTest.cs +++ b/src/NHibernate.Test/ExceptionsTest/SQLExceptionConversionTest.cs @@ -1,6 +1,7 @@ using System; using System.Collections; using System.Data; +using System.Data.Common; using NHibernate.Dialect; using NHibernate.Driver; using NHibernate.Engine; @@ -74,17 +75,17 @@ public void IntegrityViolation() ISession session = OpenSession(); session.BeginTransaction(); - IDbConnection connection = session.Connection; + var connection = session.Connection; // Attempt to insert some bad values into the T_MEMBERSHIP table that should // result in a constraint violation - IDbCommand ps = null; + DbCommand ps = null; try { ps = connection.CreateCommand(); ps.CommandType = CommandType.Text; ps.CommandText = "INSERT INTO T_MEMBERSHIP (user_id, group_id) VALUES (@p1, @p2)"; - IDbDataParameter pr = ps.CreateParameter(); + var pr = ps.CreateParameter(); pr.ParameterName = "p1"; pr.DbType = DbType.Int64; pr.Value = 52134241L; // Non-existent user_id @@ -136,10 +137,10 @@ public void BadGrammar() ISQLExceptionConverter converter = sessions.Settings.SqlExceptionConverter; ISession session = OpenSession(); - IDbConnection connection = session.Connection; + var connection = session.Connection; // prepare/execute a query against a non-existent table - IDbCommand ps = null; + DbCommand ps = null; try { ps = connection.CreateCommand(); diff --git a/src/NHibernate.Test/Insertordering/InsertOrderingFixture.cs b/src/NHibernate.Test/Insertordering/InsertOrderingFixture.cs index 631a068309d..e392bc07a90 100644 --- a/src/NHibernate.Test/Insertordering/InsertOrderingFixture.cs +++ b/src/NHibernate.Test/Insertordering/InsertOrderingFixture.cs @@ -2,10 +2,9 @@ using System.Collections; using System.Collections.Generic; using System.Data; +using System.Data.Common; using NHibernate.AdoNet; using NHibernate.Cfg; -using NHibernate.Cfg.Loquacious; -using NHibernate.Connection; using NHibernate.Engine; using NHibernate.SqlCommand; using NHibernate.SqlTypes; @@ -99,9 +98,9 @@ public static void Reset() batchSQL = null; } - public override IDbCommand PrepareBatchCommand(CommandType type, SqlString sql, SqlType[] parameterTypes) + public override DbCommand PrepareBatchCommand(CommandType type, SqlString sql, SqlType[] parameterTypes) { - IDbCommand result = base.PrepareBatchCommand(type, sql, parameterTypes); + var result = base.PrepareBatchCommand(type, sql, parameterTypes); string sqlstring = sql.ToString(); if (batchSQL == null || !sqlstring.Equals(batchSQL)) { @@ -121,7 +120,7 @@ public override void AddToBatch(IExpectation expectation) base.AddToBatch(expectation); } - protected override void DoExecuteBatch(IDbCommand ps) + protected override void DoExecuteBatch(DbCommand ps) { Console.WriteLine("executing batch [" + batchSQL + "]"); Console.WriteLine("--------------------------------------------------------"); diff --git a/src/NHibernate.Test/Join/JoinCompositeKeyTest.cs b/src/NHibernate.Test/Join/JoinCompositeKeyTest.cs index 8c68d3c188b..428512aba2a 100644 --- a/src/NHibernate.Test/Join/JoinCompositeKeyTest.cs +++ b/src/NHibernate.Test/Join/JoinCompositeKeyTest.cs @@ -2,7 +2,6 @@ using NUnit.Framework; using System; using System.Collections; -using System.Data; namespace NHibernate.Test.Join { diff --git a/src/NHibernate.Test/Join/JoinTest.cs b/src/NHibernate.Test/Join/JoinTest.cs index 56d1f5ab384..e0186e2b8d1 100644 --- a/src/NHibernate.Test/Join/JoinTest.cs +++ b/src/NHibernate.Test/Join/JoinTest.cs @@ -5,6 +5,7 @@ using System; using System.Collections; using System.Data; +using System.Data.Common; namespace NHibernate.Test.Join { @@ -160,7 +161,7 @@ public void TestOptional() s.Flush(); s.Clear(); - IDbCommand cmd = s.Connection.CreateCommand(); + var cmd = s.Connection.CreateCommand(); tx.Enlist(cmd); cmd.CommandText = "select count(*) from phone where phone_id = " + p.Id.ToString(); cmd.CommandType = CommandType.Text; @@ -268,7 +269,7 @@ public void TestInverseJoinNotDeleted() long personId = p.Id; s.Delete(p); - IDbCommand cmd = s.Connection.CreateCommand(); + var cmd = s.Connection.CreateCommand(); tx.Enlist(cmd); cmd.CommandText = string.Format( "select count(stuff_id) from inversed_stuff where stuff_id = {0}", @@ -277,7 +278,7 @@ public void TestInverseJoinNotDeleted() Int64 count = Convert.ToInt64(cmd.ExecuteScalar()); Assert.AreEqual(1, count, "Row from an inverse was deleted."); - IDbCommand cmd2 = s.Connection.CreateCommand(); + var cmd2 = s.Connection.CreateCommand(); tx.Enlist(cmd2); cmd2.CommandText = string.Format( "select StuffName from inversed_stuff where stuff_id = {0}", diff --git a/src/NHibernate.Test/Legacy/FooBarTest.cs b/src/NHibernate.Test/Legacy/FooBarTest.cs index e60062b0085..5ade062814e 100644 --- a/src/NHibernate.Test/Legacy/FooBarTest.cs +++ b/src/NHibernate.Test/Legacy/FooBarTest.cs @@ -2,6 +2,7 @@ using System.Collections; using System.Collections.Generic; using System.Data; +using System.Data.Common; using System.Diagnostics; using System.Globalization; using System.IO; @@ -14,7 +15,6 @@ using NHibernate.DomainModel; using NHibernate.Criterion; using NHibernate.Proxy; -using NHibernate.Test.NHSpecificTest.NH1914; using NHibernate.Type; using NHibernate.Util; using NUnit.Framework; @@ -2165,7 +2165,7 @@ public void CollectionWhere() s.Delete("from Foo foo"); s.Delete(baz); - IDbCommand deleteCmd = s.Connection.CreateCommand(); + var deleteCmd = s.Connection.CreateCommand(); deleteCmd.CommandText = "delete from FooArray where id_='" + baz.Code + "' and i>=8"; deleteCmd.CommandType = CommandType.Text; int rows = deleteCmd.ExecuteNonQuery(); @@ -2839,7 +2839,7 @@ public void PersistCollections() s.Delete(baz.TopGlarchez['G']); s.Delete(baz.TopGlarchez['H']); - IDbCommand cmd = s.Connection.CreateCommand(); + var cmd = s.Connection.CreateCommand(); s.Transaction.Enlist(cmd); cmd.CommandText = "update " + Dialect.QuoteForTableName("glarchez") + " set baz_map_id=null where baz_map_index='a'"; int rows = cmd.ExecuteNonQuery(); @@ -3880,7 +3880,7 @@ public void RecursiveLoad() // Not ported - testScrollableIterator - ScrollableResults are not supported by NH, // since they rely on the underlying ResultSet to support scrolling, and ADO.NET - // IDataReaders do not support it. + // DbDataReaders do not support it. private bool DialectSupportsCountDistinct { @@ -4723,8 +4723,8 @@ public void Cache() // refuses to delete immutable objects. using (ISession s = OpenSession()) { - IDbConnection connection = s.Connection; - using (IDbCommand command = connection.CreateCommand()) + var connection = s.Connection; + using (var command = connection.CreateCommand()) { command.CommandText = "delete from immut"; command.ExecuteNonQuery(); @@ -4765,7 +4765,7 @@ public void Refresh() s.Save(foo); s.Flush(); - IDbCommand cmd = s.Connection.CreateCommand(); + var cmd = s.Connection.CreateCommand(); cmd.CommandText = "update " + Dialect.QuoteForTableName("foos") + " set long_ = -3"; cmd.ExecuteNonQuery(); @@ -4792,7 +4792,7 @@ Commented to have same behavior of H3.2 (test named FooBarTest.testRefresh()) s = OpenSession(); btw using close and open a new session more than Transient the entity will be detached. */ - IDbCommand cmd = s.Connection.CreateCommand(); + var cmd = s.Connection.CreateCommand(); cmd.CommandText = "update " + Dialect.QuoteForTableName("foos") + " set long_ = -3"; cmd.ExecuteNonQuery(); s.Refresh(foo); @@ -4983,7 +4983,7 @@ public void UserProvidedConnection() s.CreateQuery("from foo in class NHibernate.DomainModel.Fo").List(); tx.Commit(); - IDbConnection c = s.Disconnect(); + var c = s.Disconnect(); Assert.IsNotNull(c); s.Reconnect(c); diff --git a/src/NHibernate.Test/Linq/QueryTimeoutTests.cs b/src/NHibernate.Test/Linq/QueryTimeoutTests.cs index 1994dce8818..d9816f1e5b6 100644 --- a/src/NHibernate.Test/Linq/QueryTimeoutTests.cs +++ b/src/NHibernate.Test/Linq/QueryTimeoutTests.cs @@ -1,4 +1,5 @@ -using System.Linq; +using System.Data.Common; +using System.Linq; using NHibernate.AdoNet; using NHibernate.Cfg; using NHibernate.Engine; @@ -71,7 +72,7 @@ into g public class TimeoutCatchingNonBatchingBatcher : NonBatchingBatcher { - // Is there an easier way to inspect the IDbCommand instead of + // Is there an easier way to inspect the DbCommand instead of // creating a custom batcher? @@ -82,7 +83,7 @@ public TimeoutCatchingNonBatchingBatcher(ConnectionManager connectionManager, II { } - public override System.Data.IDataReader ExecuteReader(System.Data.IDbCommand cmd) + public override DbDataReader ExecuteReader(DbCommand cmd) { LastCommandTimeout = cmd.CommandTimeout; return base.ExecuteReader(cmd); diff --git a/src/NHibernate.Test/MappingByCode/MappersTests/PropertyMapperTest.cs b/src/NHibernate.Test/MappingByCode/MappersTests/PropertyMapperTest.cs index d22044b64b3..778528ba1e8 100644 --- a/src/NHibernate.Test/MappingByCode/MappersTests/PropertyMapperTest.cs +++ b/src/NHibernate.Test/MappingByCode/MappersTests/PropertyMapperTest.cs @@ -1,6 +1,6 @@ using System; using System.Linq; -using System.Data; +using System.Data.Common; using NHibernate.Cfg.MappingSchema; using NHibernate.Engine; using NHibernate.Mapping.ByCode; @@ -334,12 +334,12 @@ public int GetHashCode(object x) throw new NotImplementedException(); } - public object NullSafeGet(IDataReader rs, string[] names, object owner) + public object NullSafeGet(DbDataReader rs, string[] names, object owner) { throw new NotImplementedException(); } - public void NullSafeSet(IDbCommand cmd, object value, int index) + public void NullSafeSet(DbCommand cmd, object value, int index) { throw new NotImplementedException(); } @@ -404,12 +404,12 @@ public int GetHashCode(object x) throw new NotImplementedException(); } - public object NullSafeGet(IDataReader dr, string[] names, ISessionImplementor session, object owner) + public object NullSafeGet(DbDataReader dr, string[] names, ISessionImplementor session, object owner) { throw new NotImplementedException(); } - public void NullSafeSet(IDbCommand cmd, object value, int index, bool[] settable, ISessionImplementor session) + public void NullSafeSet(DbCommand cmd, object value, int index, bool[] settable, ISessionImplementor session) { throw new NotImplementedException(); } diff --git a/src/NHibernate.Test/NHSpecificTest/DataReaderWrapperTest/TheUserType.cs b/src/NHibernate.Test/NHSpecificTest/DataReaderWrapperTest/TheUserType.cs index d23db7aeec0..c969c8fa7a6 100644 --- a/src/NHibernate.Test/NHSpecificTest/DataReaderWrapperTest/TheUserType.cs +++ b/src/NHibernate.Test/NHSpecificTest/DataReaderWrapperTest/TheUserType.cs @@ -1,5 +1,6 @@ using System; using System.Data; +using System.Data.Common; using NHibernate.SqlTypes; using NHibernate.UserTypes; @@ -27,12 +28,12 @@ public int GetHashCode(object x) return x.GetHashCode(); } - public object NullSafeGet(IDataReader rs, string[] names, object owner) + public object NullSafeGet(DbDataReader rs, string[] names, object owner) { return rs.GetValue(rs.GetOrdinal(names[0])); } - public void NullSafeSet(IDbCommand cmd, object value, int index) + public void NullSafeSet(DbCommand cmd, object value, int index) { NHibernateUtil.String.NullSafeSet(cmd, value, index); } diff --git a/src/NHibernate.Test/NHSpecificTest/EmptyMappingsFixture.cs b/src/NHibernate.Test/NHSpecificTest/EmptyMappingsFixture.cs index 787ba6beabe..746500b6d04 100644 --- a/src/NHibernate.Test/NHSpecificTest/EmptyMappingsFixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/EmptyMappingsFixture.cs @@ -1,6 +1,7 @@ using System; using System.Collections; using System.Data; +using System.Data.Common; using NHibernate.Transaction; using NUnit.Framework; @@ -66,7 +67,7 @@ public void NullInterceptor() [Test] public void DisconnectShouldNotCloseUserSuppliedConnection() { - IDbConnection conn = sessions.ConnectionProvider.GetConnection(); + var conn = sessions.ConnectionProvider.GetConnection(); try { using (ISession s = OpenSession()) diff --git a/src/NHibernate.Test/NHSpecificTest/EntityWithUserTypeCanHaveLinqGenerators/DoubleStringUserType.cs b/src/NHibernate.Test/NHSpecificTest/EntityWithUserTypeCanHaveLinqGenerators/DoubleStringUserType.cs index 2b3b7c26dbd..c30b9849df5 100644 --- a/src/NHibernate.Test/NHSpecificTest/EntityWithUserTypeCanHaveLinqGenerators/DoubleStringUserType.cs +++ b/src/NHibernate.Test/NHSpecificTest/EntityWithUserTypeCanHaveLinqGenerators/DoubleStringUserType.cs @@ -1,5 +1,6 @@ using System; using System.Data; +using System.Data.Common; using NHibernate.SqlTypes; using NHibernate.UserTypes; @@ -31,7 +32,7 @@ public int GetHashCode(object x) return x.GetHashCode(); } - public object NullSafeGet(IDataReader rs, string[] names, object owner) + public object NullSafeGet(DbDataReader rs, string[] names, object owner) { object obj = NHibernateUtil.String.NullSafeGet(rs, names[0]); if (obj == null) @@ -41,7 +42,7 @@ public object NullSafeGet(IDataReader rs, string[] names, object owner) return Convert.ToDouble((string)obj); } - public void NullSafeSet(IDbCommand cmd, object value, int index) + public void NullSafeSet(DbCommand cmd, object value, int index) { if (value == null) { diff --git a/src/NHibernate.Test/NHSpecificTest/EntityWithUserTypeCanHaveLinqGenerators/ExampleUserType.cs b/src/NHibernate.Test/NHSpecificTest/EntityWithUserTypeCanHaveLinqGenerators/ExampleUserType.cs index e630559604f..c8a579a4db3 100644 --- a/src/NHibernate.Test/NHSpecificTest/EntityWithUserTypeCanHaveLinqGenerators/ExampleUserType.cs +++ b/src/NHibernate.Test/NHSpecificTest/EntityWithUserTypeCanHaveLinqGenerators/ExampleUserType.cs @@ -1,5 +1,6 @@ using System; using System.Data; +using System.Data.Common; using NHibernate.SqlTypes; using NHibernate.UserTypes; @@ -57,9 +58,9 @@ public object Disassemble(object value) public System.Type ReturnedType { get { return typeof(IExample); } } public bool IsMutable { get { return true; } } - public void NullSafeSet(IDbCommand cmd, object value, int index) + public void NullSafeSet(DbCommand cmd, object value, int index) { - var dataParameter = (IDataParameter)cmd.Parameters[index]; + var dataParameter = cmd.Parameters[index]; var example = (IExample)value; dataParameter.DbType = DbType.String; if (value == null || example.Value == null) @@ -72,7 +73,7 @@ public void NullSafeSet(IDbCommand cmd, object value, int index) } } - public object NullSafeGet(IDataReader rs, string[] names, object owner) + public object NullSafeGet(DbDataReader rs, string[] names, object owner) { var index = rs.GetOrdinal(names[0]); if (rs.IsDBNull(index)) diff --git a/src/NHibernate.Test/NHSpecificTest/GetSetHelperFixture.cs b/src/NHibernate.Test/NHSpecificTest/GetSetHelperFixture.cs index cfa03ef84e8..ca8188711e8 100644 --- a/src/NHibernate.Test/NHSpecificTest/GetSetHelperFixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/GetSetHelperFixture.cs @@ -1,6 +1,6 @@ using System; using System.Collections; -using System.Data; +using System.Data.Common; using NHibernate.DomainModel.NHSpecific; using NUnit.Framework; @@ -23,7 +23,7 @@ public void TestDefaultValue() { using (ISession s1 = OpenSession()) { - IDbCommand cmd = s1.Connection.CreateCommand(); + var cmd = s1.Connection.CreateCommand(); cmd.CommandText = "insert into GetSetHelper(ID) values(1)"; cmd.ExecuteNonQuery(); diff --git a/src/NHibernate.Test/NHSpecificTest/NH1355/UserTypeTimestamp.cs b/src/NHibernate.Test/NHSpecificTest/NH1355/UserTypeTimestamp.cs index c16e3846e4f..c25d50e0241 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH1355/UserTypeTimestamp.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH1355/UserTypeTimestamp.cs @@ -1,4 +1,5 @@ using System.Data; +using System.Data.Common; using NHibernate.Engine; using NHibernate.SqlTypes; using NHibernate.UserTypes; @@ -48,12 +49,12 @@ public bool IsMutable get { return false; } } - public object NullSafeGet(IDataReader rs, string[] names, object owner) + public object NullSafeGet(DbDataReader rs, string[] names, object owner) { return rs.GetValue(rs.GetOrdinal(names[0])); } - public void NullSafeSet(IDbCommand cmd, object value, int index) + public void NullSafeSet(DbCommand cmd, object value, int index) { NHibernateUtil.Binary.NullSafeSet(cmd, value, index); } diff --git a/src/NHibernate.Test/NHSpecificTest/NH1405/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH1405/Fixture.cs index 23301107d59..199b32cf68c 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH1405/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH1405/Fixture.cs @@ -1,5 +1,5 @@ using System.Collections.Generic; -using System.Data; +using System.Data.Common; using NUnit.Framework; namespace NHibernate.Test.NHSpecificTest.NH1405 { @@ -21,7 +21,7 @@ public void Bug() { foreach (string sql in populate) { - IDbCommand cmd = session.Connection.CreateCommand(); + var cmd = session.Connection.CreateCommand(); cmd.CommandText = sql; tx.Enlist(cmd); cmd.ExecuteNonQuery(); @@ -47,7 +47,7 @@ public void Bug() using (ISession session = OpenSession()) using (ITransaction tx = session.BeginTransaction()) { - IDbCommand cmd = session.Connection.CreateCommand(); + var cmd = session.Connection.CreateCommand(); cmd.CommandText = "DELETE FROM PPDM_COLUMN"; tx.Enlist(cmd); cmd.ExecuteNonQuery(); diff --git a/src/NHibernate.Test/NHSpecificTest/NH1483/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH1483/Fixture.cs index f3574114fb3..0957559492a 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH1483/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH1483/Fixture.cs @@ -1,5 +1,5 @@ using System; -using System.Data; +using System.Data.Common; using NUnit.Framework; namespace NHibernate.Test.NHSpecificTest.NH1483 @@ -81,7 +81,7 @@ private void DeleteAll(bool inNHibernateScope) else { //delete directly from the db - using (IDbCommand cmd = session.Connection.CreateCommand()) + using (var cmd = session.Connection.CreateCommand()) { cmd.CommandText = "DELETE FROM BaseClass"; cmd.ExecuteNonQuery(); diff --git a/src/NHibernate.Test/NHSpecificTest/NH1553/MsSQL/SnapshotIsolationUpdateConflictTest.cs b/src/NHibernate.Test/NHSpecificTest/NH1553/MsSQL/SnapshotIsolationUpdateConflictTest.cs index 2d9d63e77cc..4bab3574d95 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH1553/MsSQL/SnapshotIsolationUpdateConflictTest.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH1553/MsSQL/SnapshotIsolationUpdateConflictTest.cs @@ -1,4 +1,5 @@ using System.Data; +using System.Data.Common; using NHibernate.Cfg; using NHibernate.Dialect; using NUnit.Framework; @@ -134,7 +135,7 @@ private void SetAllowSnapshotIsolation(bool on) { using (ISession session = OpenSession()) { - IDbCommand command = session.Connection.CreateCommand(); + var command = session.Connection.CreateCommand(); command.CommandText = "ALTER DATABASE " + session.Connection.Database + " set allow_snapshot_isolation " + (on ? "on" : "off"); command.ExecuteNonQuery(); diff --git a/src/NHibernate.Test/NHSpecificTest/NH1763/EmptyStringUserType.cs b/src/NHibernate.Test/NHSpecificTest/NH1763/EmptyStringUserType.cs index c6fb9760ec0..5f54c25f31a 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH1763/EmptyStringUserType.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH1763/EmptyStringUserType.cs @@ -1,5 +1,5 @@ using System; -using System.Data; +using System.Data.Common; using NHibernate.Engine; using NHibernate.UserTypes; @@ -58,12 +58,12 @@ public Object DeepCopy(Object a) return (x == y) || (x != null && y != null && (x.Equals(y))); } - public object NullSafeGet(System.Data.IDataReader rs, String[] names, NHibernate.Engine.ISessionImplementor session, Object owner) + public object NullSafeGet(DbDataReader rs, String[] names, NHibernate.Engine.ISessionImplementor session, Object owner) { return NHibernateUtil.String.NullSafeGet(rs, names[0], session, owner); } - public void NullSafeSet(System.Data.IDbCommand st, Object value, int index, bool[] settable, NHibernate.Engine.ISessionImplementor session) + public void NullSafeSet(DbCommand st, Object value, int index, bool[] settable, NHibernate.Engine.ISessionImplementor session) { if (settable[0]) { diff --git a/src/NHibernate.Test/NHSpecificTest/NH1907/MyType.cs b/src/NHibernate.Test/NHSpecificTest/NH1907/MyType.cs index c8994ae43e0..eab917b8cfe 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH1907/MyType.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH1907/MyType.cs @@ -1,5 +1,5 @@ using System; -using System.Data; +using System.Data.Common; using NHibernate.SqlTypes; using NHibernate.UserTypes; @@ -61,15 +61,15 @@ public object DeepCopy(object value) return value; } - public void NullSafeSet(IDbCommand cmd, object value, int index) + public void NullSafeSet(DbCommand cmd, object value, int index) { if (value == null) { - ((IDbDataParameter)cmd.Parameters[index]).Value = DBNull.Value; + cmd.Parameters[index].Value = DBNull.Value; } else { - ((IDbDataParameter)cmd.Parameters[index]).Value = ((MyType)value).ToPersist; + cmd.Parameters[index].Value = ((MyType)value).ToPersist; } } @@ -78,7 +78,7 @@ public System.Type ReturnedType get { return typeof(Int32); } } - public object NullSafeGet(IDataReader rs, string[] names, object owner) + public object NullSafeGet(DbDataReader rs, string[] names, object owner) { int index0 = rs.GetOrdinal(names[0]); if (rs.IsDBNull(index0)) diff --git a/src/NHibernate.Test/NHSpecificTest/NH1985/SampleTest.cs b/src/NHibernate.Test/NHSpecificTest/NH1985/SampleTest.cs index 2ae2f260d35..18c66fd6dcb 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH1985/SampleTest.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH1985/SampleTest.cs @@ -1,5 +1,5 @@ using System; -using System.Data; +using System.Data.Common; using NHibernate.Connection; using NUnit.Framework; @@ -45,11 +45,11 @@ public void AttemptToDeleteImmutableObjectShouldThrow() using (IConnectionProvider prov = ConnectionProviderFactory.NewConnectionProvider(cfg.Properties)) { - IDbConnection conn = prov.GetConnection(); + var conn = prov.GetConnection(); try { - using (IDbCommand comm = conn.CreateCommand()) + using (var comm = conn.CreateCommand()) { comm.CommandText = "SELECT Id FROM DomainClass WHERE Id=1 AND Label='TEST record'"; object result = comm.ExecuteScalar(); @@ -83,11 +83,11 @@ public void AllowDeletionOfImmutableObject() using (IConnectionProvider prov = ConnectionProviderFactory.NewConnectionProvider(cfg.Properties)) { - IDbConnection conn = prov.GetConnection(); + var conn = prov.GetConnection(); try { - using (IDbCommand comm = conn.CreateCommand()) + using (var comm = conn.CreateCommand()) { comm.CommandText = "SELECT Id FROM DomainClass WHERE Id=1 AND Label='TEST record'"; object result = comm.ExecuteScalar(); diff --git a/src/NHibernate.Test/NHSpecificTest/NH1989/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH1989/Fixture.cs index 3ecc0da67fd..69f6c070200 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH1989/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH1989/Fixture.cs @@ -1,4 +1,4 @@ -using System.Data; +using System.Data.Common; using NUnit.Framework; @@ -7,9 +7,6 @@ using NHibernate.Criterion; using NHibernate.Engine; -using System.Collections.Generic; -using System.Linq; - namespace NHibernate.Test.NHSpecificTest.NH1989 { [TestFixture] @@ -39,7 +36,7 @@ protected override void OnTearDown() private static void DeleteObjectsOutsideCache(ISession s) { - using (IDbCommand cmd = s.Connection.CreateCommand()) + using (var cmd = s.Connection.CreateCommand()) { cmd.CommandText = "DELETE FROM UserTable"; cmd.ExecuteNonQuery(); diff --git a/src/NHibernate.Test/NHSpecificTest/NH2057/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2057/Fixture.cs index 9339f28a508..048e949556f 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2057/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2057/Fixture.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Data; using System.Transactions; using NHibernate.Impl; using NUnit.Framework; diff --git a/src/NHibernate.Test/NHSpecificTest/NH2069/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2069/Fixture.cs index 0d598849a76..95073c1bc15 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2069/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2069/Fixture.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Data; using System.Transactions; using NHibernate; using NHibernate.Impl; diff --git a/src/NHibernate.Test/NHSpecificTest/NH2077/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2077/Fixture.cs index f8836c558dc..386d16c650e 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2077/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2077/Fixture.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Data; using System.Transactions; using NHibernate.Dialect; using NHibernate.Impl; diff --git a/src/NHibernate.Test/NHSpecificTest/NH2113/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2113/Fixture.cs index 769f6d1748f..63038658bfc 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2113/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2113/Fixture.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Data; using System.Transactions; using NHibernate.Dialect; using NHibernate.Impl; diff --git a/src/NHibernate.Test/NHSpecificTest/NH2204/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2204/Fixture.cs index 5e864032db2..1ffccc8e7ab 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2204/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2204/Fixture.cs @@ -1,3 +1 @@ -using System; using System.Data; using NUnit.Framework; using NHibernate.Dialect; namespace NHibernate.Test.NHSpecificTest.NH2204 { [TestFixture] public class Fixture : BugTestCase { public override string BugNumber { get { return "NH2204"; } } protected override bool AppliesTo(Dialect.Dialect dialect) { return dialect is PostgreSQL81Dialect; } // create the trigger protected override void OnSetUp() { using (ISession s = OpenSession()) { IDbCommand command = s.Connection.CreateCommand(); command.CommandText = "CREATE OR REPLACE FUNCTION audit_parent() RETURNS trigger AS $audit_parent$" + Environment.NewLine + "BEGIN" + Environment.NewLine + - "INSERT INTO parent_history SELECT nextval('parent_history_histid_seq'), now(), NEW.*;" + Environment.NewLine + "RETURN NEW;" + Environment.NewLine + "END" + Environment.NewLine + " $audit_parent$ LANGUAGE 'plpgsql';"; command.ExecuteNonQuery(); command.CommandText = "CREATE TRIGGER parent_audit" + Environment.NewLine + "AFTER INSERT OR UPDATE ON parent" + Environment.NewLine + "FOR EACH ROW EXECUTE PROCEDURE audit_parent();"; command.ExecuteNonQuery(); } } // remove trigger and remove data from tables protected override void OnTearDown() { using (ISession s = OpenSession()) { IDbCommand command = s.Connection.CreateCommand(); command.CommandText = "DROP FUNCTION audit_parent() CASCADE;"; command.ExecuteNonQuery(); - command.CommandText = "DELETE from parent_history;"; command.ExecuteNonQuery(); command.CommandText = "DELETE from parent;"; command.ExecuteNonQuery(); } } [Test] public void KnownFailure_Correct_Id_Returned_When_Using_Trigger() { Assert.Throws(() => RunTest(), "We expected this test to fail - if the problem has been fixed, clean-up the test."); } private void RunTest() { var entity1 = new Parent {Name = "Parent1_0"}; // when saved this entity should have the id of 1 var entity2 = new Parent {Name = "Parent2_0"}; // when saved this entity should have the id of 2 var entity3 = new Parent {Name = "Parent3_0"}; // when saved this entity should have the id of 3 using (ISession s = OpenSession()) { // save first entity s.Save(entity1); s.Flush(); Assert.AreEqual(1, entity1.Id); // save second entity s.Save(entity2); s.Flush(); Assert.AreEqual(2, entity2.Id); // update this entity 10 times - adds entries to the audit table // causing the sequences for the parent and history table to no longer be aligned for (int i = 1; i < 11; i++) { entity2.Name = string.Format("Parent2_{0}", i); s.Update(entity2); s.Flush(); } // save third entity s.Save(entity3); s.Flush(); Assert.AreEqual( 3, entity3.Id, "oh uh - it would appear that lastval() is not our friend when a trigger updates other sequences."); // now would be a good time to look at the data in the tables and see that they have the IDs as expected // which are not the same as those returned by nhibernate } } } } +using System; using System.Data.Common; using NUnit.Framework; using NHibernate.Dialect; namespace NHibernate.Test.NHSpecificTest.NH2204 { [TestFixture] public class Fixture : BugTestCase { public override string BugNumber { get { return "NH2204"; } } protected override bool AppliesTo(Dialect.Dialect dialect) { return dialect is PostgreSQL81Dialect; } // create the trigger protected override void OnSetUp() { using (ISession s = OpenSession()) { var command = s.Connection.CreateCommand(); command.CommandText = "CREATE OR REPLACE FUNCTION audit_parent() RETURNS trigger AS $audit_parent$" + Environment.NewLine + "BEGIN" + Environment.NewLine + "INSERT INTO parent_history SELECT nextval('parent_history_histid_seq'), now(), NEW.*;" + Environment.NewLine + "RETURN NEW;" + Environment.NewLine + "END" + Environment.NewLine + " $audit_parent$ LANGUAGE 'plpgsql';"; command.ExecuteNonQuery(); command.CommandText = "CREATE TRIGGER parent_audit" + Environment.NewLine + "AFTER INSERT OR UPDATE ON parent" + Environment.NewLine + "FOR EACH ROW EXECUTE PROCEDURE audit_parent();"; command.ExecuteNonQuery(); } } // remove trigger and remove data from tables protected override void OnTearDown() { using (ISession s = OpenSession()) { var command = s.Connection.CreateCommand(); command.CommandText = "DROP FUNCTION audit_parent() CASCADE;"; command.ExecuteNonQuery(); command.CommandText = "DELETE from parent_history;"; command.ExecuteNonQuery(); command.CommandText = "DELETE from parent;"; command.ExecuteNonQuery(); } } [Test] public void KnownFailure_Correct_Id_Returned_When_Using_Trigger() { Assert.Throws(() => RunTest(), "We expected this test to fail - if the problem has been fixed, clean-up the test."); } private void RunTest() { var entity1 = new Parent {Name = "Parent1_0"}; // when saved this entity should have the id of 1 var entity2 = new Parent {Name = "Parent2_0"}; // when saved this entity should have the id of 2 var entity3 = new Parent {Name = "Parent3_0"}; // when saved this entity should have the id of 3 using (ISession s = OpenSession()) { // save first entity s.Save(entity1); s.Flush(); Assert.AreEqual(1, entity1.Id); // save second entity s.Save(entity2); s.Flush(); Assert.AreEqual(2, entity2.Id); // update this entity 10 times - adds entries to the audit table // causing the sequences for the parent and history table to no longer be aligned for (int i = 1; i < 11; i++) { entity2.Name = string.Format("Parent2_{0}", i); s.Update(entity2); s.Flush(); } // save third entity s.Save(entity3); s.Flush(); Assert.AreEqual( 3, entity3.Id, "oh uh - it would appear that lastval() is not our friend when a trigger updates other sequences."); // now would be a good time to look at the data in the tables and see that they have the IDs as expected // which are not the same as those returned by nhibernate } } } } \ No newline at end of file diff --git a/src/NHibernate.Test/NHSpecificTest/NH2234/MyType.cs b/src/NHibernate.Test/NHSpecificTest/NH2234/MyType.cs index 0a21a11fa29..243b1929ac8 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2234/MyType.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2234/MyType.cs @@ -1,5 +1,5 @@ using System.Collections.Generic; -using System.Data; +using System.Data.Common; using NHibernate.SqlTypes; using NHibernate.UserTypes; @@ -87,7 +87,7 @@ public object DeepCopy(object value) return value; } - public void NullSafeSet(IDbCommand cmd, object value, int index) + public void NullSafeSet(DbCommand cmd, object value, int index) { if (value == null) NHibernateUtil.Int32.NullSafeSet(cmd, null, index, null); @@ -100,7 +100,7 @@ public System.Type ReturnedType get { return typeof(MyUsertype); } } - public object NullSafeGet(IDataReader rs, string[] names, object owner) + public object NullSafeGet(DbDataReader rs, string[] names, object owner) { int value = (int)NHibernateUtil.Int32.NullSafeGet(rs, names[0], null, owner); return MyUserTypes.Find(value); diff --git a/src/NHibernate.Test/NHSpecificTest/NH2297/InvalidCustomCompositeUserTypeBase.cs b/src/NHibernate.Test/NHSpecificTest/NH2297/InvalidCustomCompositeUserTypeBase.cs index ba4809878e3..b0906c684d8 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2297/InvalidCustomCompositeUserTypeBase.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2297/InvalidCustomCompositeUserTypeBase.cs @@ -1,5 +1,5 @@ using System; -using System.Data; +using System.Data.Common; using NHibernate.Engine; using NHibernate.Type; using NHibernate.UserTypes; @@ -72,13 +72,13 @@ public Object DeepCopy(Object a) return (x == y) || (x != null && y != null && (x.Equals(y))); } - public object NullSafeGet(System.Data.IDataReader rs, String[] names, NHibernate.Engine.ISessionImplementor session, + public object NullSafeGet(DbDataReader rs, String[] names, NHibernate.Engine.ISessionImplementor session, Object owner) { return NHibernateUtil.String.NullSafeGet(rs, names[0], session, owner); } - public void NullSafeSet(System.Data.IDbCommand st, Object value, int index, + public void NullSafeSet(DbCommand st, Object value, int index, bool[] settable, NHibernate.Engine.ISessionImplementor session) { throw new NotImplementedException(); diff --git a/src/NHibernate.Test/NHSpecificTest/NH2324/CompositeUserType.cs b/src/NHibernate.Test/NHSpecificTest/NH2324/CompositeUserType.cs index 31c92fa9507..041e32a1449 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2324/CompositeUserType.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2324/CompositeUserType.cs @@ -1,5 +1,5 @@ using System; -using System.Data; +using System.Data.Common; using NHibernate.Engine; using NHibernate.Type; using NHibernate.UserTypes; @@ -111,15 +111,15 @@ public int GetHashCode(object x) } /// - /// Retrieve an instance of the mapped class from a IDataReader. Implementors + /// Retrieve an instance of the mapped class from a DbDataReader. Implementors /// should handle possibility of null values. /// - /// IDataReader + /// DbDataReader /// the column names /// /// the containing entity /// - public object NullSafeGet(IDataReader dr, string[] names, ISessionImplementor session, object owner) + public object NullSafeGet(DbDataReader dr, string[] names, ISessionImplementor session, object owner) { var data = new CompositeData(); data.DataA = (DateTime) NHibernateUtil.DateTime.NullSafeGet(dr, new[] {names[0]}, session, owner); @@ -138,12 +138,12 @@ public object NullSafeGet(IDataReader dr, string[] names, ISessionImplementor se /// /// /// - public void NullSafeSet(IDbCommand cmd, object value, int index, bool[] settable, ISessionImplementor session) + public void NullSafeSet(DbCommand cmd, object value, int index, bool[] settable, ISessionImplementor session) { if (value == null) { - if (settable[0]) ((IDataParameter) cmd.Parameters[index++]).Value = DBNull.Value; - if (settable[1]) ((IDataParameter) cmd.Parameters[index]).Value = DBNull.Value; + if (settable[0]) cmd.Parameters[index++].Value = DBNull.Value; + if (settable[1]) cmd.Parameters[index].Value = DBNull.Value; } else { diff --git a/src/NHibernate.Test/NHSpecificTest/NH2392/PhoneNumberUserType.cs b/src/NHibernate.Test/NHSpecificTest/NH2392/PhoneNumberUserType.cs index 7be218a892b..6a4fc26edae 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2392/PhoneNumberUserType.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2392/PhoneNumberUserType.cs @@ -1,8 +1,5 @@ using System; -using System.Collections.Generic; -using System.Data; -using System.Linq; -using System.Text; +using System.Data.Common; using NHibernate.Engine; using NHibernate.Type; using NHibernate.UserTypes; @@ -59,7 +56,7 @@ public int GetHashCode(object x) return x.GetHashCode(); } - public object NullSafeGet(IDataReader dr, string[] names, ISessionImplementor session, object owner) + public object NullSafeGet(DbDataReader dr, string[] names, ISessionImplementor session, object owner) { if (dr.IsDBNull(dr.GetOrdinal(names[0]))) return null; @@ -69,7 +66,7 @@ public object NullSafeGet(IDataReader dr, string[] names, ISessionImplementor se (string)NHibernateUtil.String.NullSafeGet(dr, names[1], session, owner)); } - public void NullSafeSet(IDbCommand cmd, object value, int index, bool[] settable, ISessionImplementor session) + public void NullSafeSet(DbCommand cmd, object value, int index, bool[] settable, ISessionImplementor session) { object countryCode = value == null ? null : (int?)((PhoneNumber)value).CountryCode; object number = value == null ? null : ((PhoneNumber)value).Number; diff --git a/src/NHibernate.Test/NHSpecificTest/NH2394/EnumStringUserType.cs b/src/NHibernate.Test/NHSpecificTest/NH2394/EnumStringUserType.cs index 7f5de4f7c84..c0bf81ac9ed 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2394/EnumStringUserType.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2394/EnumStringUserType.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Data; using System.Linq; using System.Text; using NHibernate.SqlTypes; diff --git a/src/NHibernate.Test/NHSpecificTest/NH2394/PhoneNumberUserType.cs b/src/NHibernate.Test/NHSpecificTest/NH2394/PhoneNumberUserType.cs index d6440f12f48..eeb6da30bfe 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2394/PhoneNumberUserType.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2394/PhoneNumberUserType.cs @@ -1,8 +1,5 @@ using System; -using System.Collections.Generic; -using System.Data; -using System.Linq; -using System.Text; +using System.Data.Common; using NHibernate.Engine; using NHibernate.Type; using NHibernate.UserTypes; @@ -59,7 +56,7 @@ public int GetHashCode(object x) return x.GetHashCode(); } - public object NullSafeGet(IDataReader dr, string[] names, ISessionImplementor session, object owner) + public object NullSafeGet(DbDataReader dr, string[] names, ISessionImplementor session, object owner) { if (dr.IsDBNull(dr.GetOrdinal(names[0]))) return null; @@ -69,7 +66,7 @@ public object NullSafeGet(IDataReader dr, string[] names, ISessionImplementor se (string)NHibernateUtil.String.NullSafeGet(dr, names[1], session, owner)); } - public void NullSafeSet(IDbCommand cmd, object value, int index, bool[] settable, ISessionImplementor session) + public void NullSafeSet(DbCommand cmd, object value, int index, bool[] settable, ISessionImplementor session) { object countryCode = value == null ? null : (int?)((PhoneNumber)value).CountryCode; object number = value == null ? null : ((PhoneNumber)value).Number; diff --git a/src/NHibernate.Test/NHSpecificTest/NH2420/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2420/Fixture.cs index f42ec01ce93..fe575df876b 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2420/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2420/Fixture.cs @@ -1,5 +1,5 @@ using System; -using System.Data; +using System.Data.Common; using System.Data.Odbc; using System.Data.SqlClient; using System.Configuration; @@ -64,7 +64,7 @@ public void ShouldBeAbleToReleaseSuppliedConnectionAfterDistributedTransaction() new DummyEnlistment(), EnlistmentOptions.None); - IDbConnection connection; + DbConnection connection; if (sessions.ConnectionProvider.Driver.GetType() == typeof(OdbcDriver)) connection = new OdbcConnection(connectionString); else diff --git a/src/NHibernate.Test/NHSpecificTest/NH2839/FixtureByCode.cs b/src/NHibernate.Test/NHSpecificTest/NH2839/FixtureByCode.cs index a8ea682d55a..cff42209736 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2839/FixtureByCode.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2839/FixtureByCode.cs @@ -1,5 +1,5 @@ using System; -using System.Data; +using System.Data.Common; using System.Linq; using NHibernate.Cfg.MappingSchema; using NHibernate.Linq; @@ -43,7 +43,7 @@ public int GetHashCode(object x) return x.GetHashCode(); } - public object NullSafeGet(IDataReader rs, string[] names, object owner) + public object NullSafeGet(DbDataReader rs, string[] names, object owner) { var ordinal = rs.GetOrdinal(names[0]); if (rs.IsDBNull(ordinal)) @@ -51,9 +51,9 @@ public object NullSafeGet(IDataReader rs, string[] names, object owner) return rs.GetInt32(ordinal) == 1; } - public void NullSafeSet(IDbCommand cmd, object value, int index) + public void NullSafeSet(DbCommand cmd, object value, int index) { - ((IDbDataParameter) cmd.Parameters[index]).Value = ((bool) value) ? 1 : -1; + cmd.Parameters[index].Value = ((bool) value) ? 1 : -1; } public object DeepCopy(object value) @@ -154,4 +154,4 @@ where e.IsActive } } } -} \ No newline at end of file +} diff --git a/src/NHibernate.Test/NHSpecificTest/NH3004/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH3004/Fixture.cs index 58c87d2b95f..706eb379177 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH3004/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH3004/Fixture.cs @@ -1,7 +1,6 @@ using System.Collections; using NHibernate.SqlCommand; using NUnit.Framework; -using System.Data; namespace NHibernate.Test.NHSpecificTest.NH3004 { diff --git a/src/NHibernate.Test/NHSpecificTest/NH3004/TestSqlClientDriver.cs b/src/NHibernate.Test/NHSpecificTest/NH3004/TestSqlClientDriver.cs index c62cee5bd06..24297856ff0 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH3004/TestSqlClientDriver.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH3004/TestSqlClientDriver.cs @@ -1,4 +1,3 @@ -using System.Data; using System.Data.SqlClient; using NHibernate.AdoNet; using NHibernate.Dialect; diff --git a/src/NHibernate.Test/NHSpecificTest/NH3202/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH3202/Fixture.cs index b3e31542ce1..65297a02e07 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH3202/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH3202/Fixture.cs @@ -1,4 +1,4 @@ -using System.Data; +using System.Data.Common; using System.Text.RegularExpressions; using NHibernate.Cfg; using NHibernate.Dialect; @@ -111,7 +111,7 @@ public class OffsetTestDriver : SqlClientDriver public int? OffsetParameterValueFromCommand { get; private set; } - protected override void OnBeforePrepare(IDbCommand command) + protected override void OnBeforePrepare(DbCommand command) { base.OnBeforePrepare(command); OffsetParameterValueFromCommand = null; @@ -120,7 +120,7 @@ protected override void OnBeforePrepare(IDbCommand command) if (!hasLimit) return; - OffsetParameterValueFromCommand = (int)((IDataParameter)command.Parameters[_offsetParameterIndex]).Value; + OffsetParameterValueFromCommand = (int)command.Parameters[_offsetParameterIndex].Value; } } } diff --git a/src/NHibernate.Test/NHSpecificTest/NH3237/EnumUserType.cs b/src/NHibernate.Test/NHSpecificTest/NH3237/EnumUserType.cs index 0134893f4ec..2f548a77c09 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH3237/EnumUserType.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH3237/EnumUserType.cs @@ -1,6 +1,7 @@ using System.Linq; using System; using System.Data; +using System.Data.Common; using NHibernate.SqlTypes; using NHibernate.UserTypes; using NHibernate.Type; @@ -19,7 +20,7 @@ public SqlType[] SqlTypes get { return new[] { new SqlType(DbType.Int32) }; } } - public object NullSafeGet(IDataReader dr, string[] names, object owner) + public object NullSafeGet(DbDataReader dr, string[] names, object owner) { var name = names[0]; int index = dr.GetOrdinal(name); @@ -42,7 +43,7 @@ public object NullSafeGet(IDataReader dr, string[] names, object owner) } } - public void NullSafeSet(IDbCommand cmd, object value, int index) + public void NullSafeSet(DbCommand cmd, object value, int index) { if (value == null) { @@ -52,8 +53,7 @@ public void NullSafeSet(IDbCommand cmd, object value, int index) { var paramVal = (int)value; - IDataParameter parameter = (IDataParameter)cmd.Parameters[index]; - parameter.Value = paramVal; + cmd.Parameters[index].Value = paramVal; } } diff --git a/src/NHibernate.Test/NHSpecificTest/NH3874/IntWrapperType.cs b/src/NHibernate.Test/NHSpecificTest/NH3874/IntWrapperType.cs index 3d018818b27..1689fa024fa 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH3874/IntWrapperType.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH3874/IntWrapperType.cs @@ -1,5 +1,5 @@ using System; -using System.Data; +using System.Data.Common; using NHibernate.SqlTypes; using NHibernate.Type; using NHibernate.UserTypes; @@ -31,23 +31,23 @@ protected NullableType NHNullableType get { return NHibernateUtil.Int32; } } - public object NullSafeGet(IDataReader dr, string[] names, object owner) + public object NullSafeGet(DbDataReader dr, string[] names, object owner) { object obj = NHNullableType.NullSafeGet(dr, names[0]); if (obj == null) return null; return new IntWrapper((int)obj); } - public void NullSafeSet(IDbCommand cmd, object obj, int index) + public void NullSafeSet(DbCommand cmd, object obj, int index) { if (obj == null) { - ((IDataParameter)cmd.Parameters[index]).Value = DBNull.Value; + cmd.Parameters[index].Value = DBNull.Value; } else { IntWrapper id = (IntWrapper)obj; - ((IDataParameter)cmd.Parameters[index]).Value = id.Id; + cmd.Parameters[index].Value = id.Id; } } diff --git a/src/NHibernate.Test/NHSpecificTest/NH732/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH732/Fixture.cs index 45f5efe28f6..1c88666e8b3 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH732/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH732/Fixture.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; -using System.Data; -using NHibernate; +using System.Data.Common; using NHibernate.Dialect; using NHibernate.SqlTypes; using NHibernate.UserTypes; @@ -79,7 +78,7 @@ public int GetHashCode(object x) return StringComparer.InvariantCultureIgnoreCase.GetHashCode((string)x); } - public object NullSafeGet(IDataReader rs, string[] names, object owner) + public object NullSafeGet(DbDataReader rs, string[] names, object owner) { int ordinal = rs.GetOrdinal(names[0]); string s = rs.GetString(ordinal); @@ -91,11 +90,10 @@ public object NullSafeGet(IDataReader rs, string[] names, object owner) */ } - public void NullSafeSet(IDbCommand cmd, object value, int index) + public void NullSafeSet(DbCommand cmd, object value, int index) { - IDbDataParameter parameter = (IDbDataParameter)cmd.Parameters[index]; - parameter.Value = - value == null ? DBNull.Value : value; + var parameter = cmd.Parameters[index]; + parameter.Value = value ?? DBNull.Value; } public object DeepCopy(object value) diff --git a/src/NHibernate.Test/NHSpecificTest/SetFixture.cs b/src/NHibernate.Test/NHSpecificTest/SetFixture.cs index 576d27db8bc..e8b40dd1052 100644 --- a/src/NHibernate.Test/NHSpecificTest/SetFixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/SetFixture.cs @@ -1,6 +1,6 @@ using System; using System.Collections; -using System.Data; +using System.Data.Common; using NHibernate.Cache; using NHibernate.Cache.Entry; using NHibernate.Collection; @@ -151,7 +151,7 @@ public void DeleteRows(IPersistentCollection collection, object key, ISessionImp // TODO: Add CollectionPersisterStub.DeleteRows implementation } - public void WriteElement(IDbCommand st, object elt, bool writeOrder, ISessionImplementor session) + public void WriteElement(DbCommand st, object elt, bool writeOrder, ISessionImplementor session) { // TODO: Add CollectionPersisterStub.WriteElement implementation } @@ -183,7 +183,7 @@ public void Remove(object id, ISessionImplementor session) // TODO: Add CollectionPersisterStub.Remove implementation } - public object ReadElement(IDataReader rs, object owner, string[] aliases, ISessionImplementor session) + public object ReadElement(DbDataReader rs, object owner, string[] aliases, ISessionImplementor session) { // TODO: Add CollectionPersisterStub.ReadElement implementation return null; @@ -212,7 +212,7 @@ public bool CascadeDeleteEnabled get { throw new NotImplementedException(); } } - public object ReadIndex(IDataReader rs, string[] aliases, ISessionImplementor session) + public object ReadIndex(DbDataReader rs, string[] aliases, ISessionImplementor session) { // TODO: Add CollectionPersisterStub.ReadIndex implementation return null; @@ -223,7 +223,7 @@ public void Initialize(object key, ISessionImplementor session) // TODO: Add CollectionPersisterStub.Initialize implementation } - public object ReadKey(IDataReader rs, string[] aliases, ISessionImplementor session) + public object ReadKey(DbDataReader rs, string[] aliases, ISessionImplementor session) { // TODO: Add CollectionPersisterStub.ReadKey implementation return null; @@ -275,7 +275,7 @@ public bool IsPrimitiveArray } } - public object ReadIdentifier(IDataReader rs, string alias, ISessionImplementor session) + public object ReadIdentifier(DbDataReader rs, string alias, ISessionImplementor session) { // TODO: Add CollectionPersisterStub.ReadIdentifier implementation return null; diff --git a/src/NHibernate.Test/NHSpecificTest/UserTypeFixture.cs b/src/NHibernate.Test/NHSpecificTest/UserTypeFixture.cs index 1b92a888614..4e378a5d717 100644 --- a/src/NHibernate.Test/NHSpecificTest/UserTypeFixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/UserTypeFixture.cs @@ -1,6 +1,6 @@ using System; using System.Collections; -using System.Data; +using System.Data.Common; using NHibernate.Connection; using NHibernate.DomainModel.NHSpecific; using NUnit.Framework; @@ -38,12 +38,12 @@ public void InsertNull() // manually read from the db IConnectionProvider provider = ConnectionProviderFactory.NewConnectionProvider(cfg.Properties); - IDbConnection conn = provider.GetConnection(); - IDbCommand cmd = conn.CreateCommand(); + var conn = provider.GetConnection(); + var cmd = conn.CreateCommand(); cmd.Connection = conn; cmd.CommandText = "select * from usertype"; - IDataReader reader = cmd.ExecuteReader(); + var reader = cmd.ExecuteReader(); while (reader.Read()) { diff --git a/src/NHibernate.Test/Pagination/CustomMsSqlDriver.cs b/src/NHibernate.Test/Pagination/CustomMsSqlDriver.cs index 86a1764653c..3ba118a3d7f 100644 --- a/src/NHibernate.Test/Pagination/CustomMsSqlDriver.cs +++ b/src/NHibernate.Test/Pagination/CustomMsSqlDriver.cs @@ -1,4 +1,4 @@ -using System.Data; +using System.Data.Common; using System.Text.RegularExpressions; using NHibernate.Driver; using NUnit.Framework; @@ -13,15 +13,15 @@ public class CustomMsSqlDriver : SqlClientDriver { public CustomMsSqlDialect CustomMsSqlDialect; - protected override void OnBeforePrepare(IDbCommand command) + protected override void OnBeforePrepare(DbCommand command) { // We will probably remove all stuff regarding BindParameterFirst, last, in the middle, in inverse-order and so on, then this part of the test is unneeded. //bool hasLimit = new Regex(@"select\s+top").IsMatch(command.CommandText.ToLower()); //if (hasLimit && CustomMsSqlDialect.ForcedSupportsVariableLimit && CustomMsSqlDialect.ForcedBindLimitParameterFirst) //{ - // int offset = (int)((IDataParameter)command.Parameters[0]).Value; - // int limit = (int)((IDataParameter)command.Parameters[1]).Value; + // int offset = (int)((DbParameter)command.Parameters[0]).Value; + // int limit = (int)((DbParameter)command.Parameters[1]).Value; // Assert.That(command.CommandText.ToLower().Contains("top (@p0)"), // "Expected string containing 'top (@p0)', but got " + command.CommandText); diff --git a/src/NHibernate.Test/SecondLevelCacheTest/SecondLevelCacheTest.cs b/src/NHibernate.Test/SecondLevelCacheTest/SecondLevelCacheTest.cs index a6aceee747f..4ed7f056d06 100644 --- a/src/NHibernate.Test/SecondLevelCacheTest/SecondLevelCacheTest.cs +++ b/src/NHibernate.Test/SecondLevelCacheTest/SecondLevelCacheTest.cs @@ -1,3 +1,4 @@ +using System.Data.Common; using System.Collections; using NHibernate.Cache; using NHibernate.Cfg; @@ -6,7 +7,6 @@ namespace NHibernate.Test.SecondLevelCacheTests { - using System.Data; using Criterion; [TestFixture] @@ -156,7 +156,7 @@ public void SecondLevelCacheWithCriteriaQueries() .List(); Assert.AreEqual(3, list.Count); - using (IDbCommand cmd = session.Connection.CreateCommand()) + using (var cmd = session.Connection.CreateCommand()) { cmd.CommandText = "DELETE FROM AnotherItem"; cmd.ExecuteNonQuery(); @@ -185,7 +185,7 @@ public void SecondLevelCacheWithCriteriaQueriesForItemWithCollections() .List(); Assert.AreEqual(3, list.Count); - using (IDbCommand cmd = session.Connection.CreateCommand()) + using (var cmd = session.Connection.CreateCommand()) { cmd.CommandText = "DELETE FROM Item"; cmd.ExecuteNonQuery(); @@ -213,7 +213,7 @@ public void SecondLevelCacheWithHqlQueriesForItemWithCollections() .List(); Assert.AreEqual(3, list.Count); - using (IDbCommand cmd = session.Connection.CreateCommand()) + using (var cmd = session.Connection.CreateCommand()) { cmd.CommandText = "DELETE FROM Item"; cmd.ExecuteNonQuery(); @@ -240,7 +240,7 @@ public void SecondLevelCacheWithHqlQueries() .List(); Assert.AreEqual(3, list.Count); - using (IDbCommand cmd = session.Connection.CreateCommand()) + using (var cmd = session.Connection.CreateCommand()) { cmd.CommandText = "DELETE FROM AnotherItem"; cmd.ExecuteNonQuery(); diff --git a/src/NHibernate.Test/SqlTest/MonetaryAmountUserType.cs b/src/NHibernate.Test/SqlTest/MonetaryAmountUserType.cs index e840e91af73..2e204aaa9ce 100644 --- a/src/NHibernate.Test/SqlTest/MonetaryAmountUserType.cs +++ b/src/NHibernate.Test/SqlTest/MonetaryAmountUserType.cs @@ -1,5 +1,5 @@ using System; -using System.Data; +using System.Data.Common; using NHibernate.SqlTypes; using NHibernate.UserTypes; @@ -35,7 +35,7 @@ public object DeepCopy(object value) return object.Equals(x, y); } - public object NullSafeGet(IDataReader resultSet, + public object NullSafeGet(DbDataReader resultSet, string[] names, object owner) { @@ -50,20 +50,20 @@ public object NullSafeGet(IDataReader resultSet, return new MonetaryAmount(value, cur); } - public void NullSafeSet(IDbCommand statement, + public void NullSafeSet(DbCommand statement, object value, int index) { if (value == null) { - ((IDbDataParameter) statement.Parameters[index]).Value = DBNull.Value; - ((IDbDataParameter) statement.Parameters[index + 1]).Value = DBNull.Value; + statement.Parameters[index].Value = DBNull.Value; + statement.Parameters[index + 1].Value = DBNull.Value; } else { MonetaryAmount currency = (MonetaryAmount) value; - ((IDbDataParameter) statement.Parameters[index]).Value = currency.Value; - ((IDbDataParameter) statement.Parameters[index + 1]).Value = currency.Currency; + statement.Parameters[index].Value = currency.Value; + statement.Parameters[index + 1].Value = currency.Currency; } } diff --git a/src/NHibernate.Test/SqlTest/NullDateUserType.cs b/src/NHibernate.Test/SqlTest/NullDateUserType.cs index 0acbaeb12e3..69636b90025 100644 --- a/src/NHibernate.Test/SqlTest/NullDateUserType.cs +++ b/src/NHibernate.Test/SqlTest/NullDateUserType.cs @@ -1,5 +1,5 @@ using System; -using System.Data; +using System.Data.Common; using NHibernate.SqlTypes; using NHibernate.UserTypes; @@ -29,7 +29,7 @@ public int GetHashCode(object x) return x.GetHashCode(); } - public object NullSafeGet(IDataReader rs, string[] names, object owner) + public object NullSafeGet(DbDataReader rs, string[] names, object owner) { int ordinal = rs.GetOrdinal(names[0]); if (rs.IsDBNull(ordinal)) @@ -42,10 +42,10 @@ public object NullSafeGet(IDataReader rs, string[] names, object owner) } } - public void NullSafeSet(IDbCommand cmd, object value, int index) + public void NullSafeSet(DbCommand cmd, object value, int index) { object valueToSet = ((DateTime) value == DateTime.MinValue) ? DBNull.Value : value; - ((IDbDataParameter) cmd.Parameters[index]).Value = valueToSet; + cmd.Parameters[index].Value = valueToSet; } public object DeepCopy(object value) diff --git a/src/NHibernate.Test/SystemTransactions/TransactionNotificationFixture.cs b/src/NHibernate.Test/SystemTransactions/TransactionNotificationFixture.cs index 92371d09257..d3702e74b9c 100644 --- a/src/NHibernate.Test/SystemTransactions/TransactionNotificationFixture.cs +++ b/src/NHibernate.Test/SystemTransactions/TransactionNotificationFixture.cs @@ -1,6 +1,6 @@ using System; using System.Collections; -using System.Data; +using System.Data.Common; using System.Threading; using System.Transactions; using NUnit.Framework; @@ -161,7 +161,7 @@ public void ShouldNotifyAfterDistributedTransactionWithOwnConnection(bool doComm using (var tx = new TransactionScope()) { - IDbConnection ownConnection1 = sessions.ConnectionProvider.GetConnection(); + var ownConnection1 = sessions.ConnectionProvider.GetConnection(); try { diff --git a/src/NHibernate.Test/TestCase.cs b/src/NHibernate.Test/TestCase.cs index 96232442a57..3850e59c551 100644 --- a/src/NHibernate.Test/TestCase.cs +++ b/src/NHibernate.Test/TestCase.cs @@ -1,6 +1,7 @@ using System; using System.Collections; using System.Data; +using System.Data.Common; using System.Reflection; using log4net; using log4net.Config; @@ -275,12 +276,12 @@ public int ExecuteStatement(string sql) using (IConnectionProvider prov = ConnectionProviderFactory.NewConnectionProvider(cfg.Properties)) { - IDbConnection conn = prov.GetConnection(); + var conn = prov.GetConnection(); try { - using (IDbTransaction tran = conn.BeginTransaction()) - using (IDbCommand comm = conn.CreateCommand()) + using (var tran = conn.BeginTransaction()) + using (var comm = conn.CreateCommand()) { comm.CommandText = sql; comm.Transaction = tran; @@ -299,7 +300,7 @@ public int ExecuteStatement(string sql) public int ExecuteStatement(ISession session, ITransaction transaction, string sql) { - using (IDbCommand cmd = session.Connection.CreateCommand()) + using (var cmd = session.Connection.CreateCommand()) { cmd.CommandText = sql; if (transaction != null) diff --git a/src/NHibernate.Test/TestDialect.cs b/src/NHibernate.Test/TestDialect.cs index bd9c2c15bbe..f3416ca1b6b 100644 --- a/src/NHibernate.Test/TestDialect.cs +++ b/src/NHibernate.Test/TestDialect.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Data; using System.Linq; using System.Text; using NHibernate.SqlTypes; diff --git a/src/NHibernate.Test/TransactionTest/TransactionFixture.cs b/src/NHibernate.Test/TransactionTest/TransactionFixture.cs index 07a01e484d7..52b7a619c11 100644 --- a/src/NHibernate.Test/TransactionTest/TransactionFixture.cs +++ b/src/NHibernate.Test/TransactionTest/TransactionFixture.cs @@ -1,6 +1,6 @@ using System; using System.Collections; -using System.Data; +using System.Data.Common; using NUnit.Framework; namespace NHibernate.Test.TransactionTest @@ -61,7 +61,7 @@ public void EnlistAfterDisposeDoesNotThrowException() { ITransaction t = s.BeginTransaction(); - using (IDbCommand cmd = s.Connection.CreateCommand()) + using (var cmd = s.Connection.CreateCommand()) { t.Dispose(); t.Enlist(cmd); diff --git a/src/NHibernate.Test/TransactionTest/TransactionNotificationFixture.cs b/src/NHibernate.Test/TransactionTest/TransactionNotificationFixture.cs index cc6965dcc1c..89b1756b116 100644 --- a/src/NHibernate.Test/TransactionTest/TransactionNotificationFixture.cs +++ b/src/NHibernate.Test/TransactionTest/TransactionNotificationFixture.cs @@ -1,5 +1,5 @@ using System.Collections; -using System.Data; +using System.Data.Common; using NUnit.Framework; namespace NHibernate.Test.TransactionTest @@ -96,7 +96,7 @@ public void ShouldNotifyAfterTransactionWithOwnConnection(bool usePrematureClose var interceptor = new RecordingInterceptor(); ISession s; - using (IDbConnection ownConnection = sessions.ConnectionProvider.GetConnection()) + using (var ownConnection = sessions.ConnectionProvider.GetConnection()) { using (s = sessions.OpenSession(ownConnection, interceptor)) using (s.BeginTransaction()) diff --git a/src/NHibernate.Test/TypeParameters/DefaultValueIntegerType.cs b/src/NHibernate.Test/TypeParameters/DefaultValueIntegerType.cs index a731cd3582d..5d1eace2645 100644 --- a/src/NHibernate.Test/TypeParameters/DefaultValueIntegerType.cs +++ b/src/NHibernate.Test/TypeParameters/DefaultValueIntegerType.cs @@ -1,5 +1,5 @@ using System; -using System.Data; +using System.Data.Common; using NHibernate.SqlTypes; using NHibernate.Type; using NHibernate.UserTypes; @@ -44,11 +44,11 @@ public object DeepCopy(object value) return value; } - public void NullSafeSet(IDbCommand cmd, object value, int index) + public void NullSafeSet(DbCommand cmd, object value, int index) { if (value.Equals(defaultValue)) { - ((IDbDataParameter) cmd.Parameters[index]).Value = DBNull.Value; + cmd.Parameters[index].Value = DBNull.Value; } else { @@ -61,7 +61,7 @@ public System.Type ReturnedType get { return typeof(Int32); } } - public object NullSafeGet(IDataReader rs, string[] names, object owner) + public object NullSafeGet(DbDataReader rs, string[] names, object owner) { object value = _int32Type.NullSafeGet(rs, names); if (value == null) diff --git a/src/NHibernate.Test/TypeParameters/TypeParameterTest.cs b/src/NHibernate.Test/TypeParameters/TypeParameterTest.cs index 25ad89f2bdd..a64abc914e1 100644 --- a/src/NHibernate.Test/TypeParameters/TypeParameterTest.cs +++ b/src/NHibernate.Test/TypeParameters/TypeParameterTest.cs @@ -1,6 +1,7 @@ using System; using System.Collections; using System.Data; +using System.Data.Common; using NHibernate.Driver; using NHibernate.SqlCommand; @@ -55,15 +56,15 @@ public void Save() IDriver driver = sessions.ConnectionProvider.Driver; - IDbConnection connection = s.Connection; - IDbCommand statement = driver.GenerateCommand( + var connection = s.Connection; + var statement = driver.GenerateCommand( CommandType.Text, SqlString.Parse("SELECT * FROM STRANGE_TYPED_OBJECT WHERE ID=?"), new SqlType[] {SqlTypeFactory.Int32}); statement.Connection = connection; t.Enlist(statement); - ((IDataParameter) statement.Parameters[0]).Value = id; - IDataReader reader = statement.ExecuteReader(); + statement.Parameters[0].Value = id; + var reader = statement.ExecuteReader(); Assert.IsTrue(reader.Read(), "A row should have been returned"); Assert.IsTrue(reader.GetValue(reader.GetOrdinal("VALUE_ONE")) == DBNull.Value, diff --git a/src/NHibernate.Test/TypesTest/BinaryTypeFixture.cs b/src/NHibernate.Test/TypesTest/BinaryTypeFixture.cs index 6792f16aa19..e0ec802bee1 100644 --- a/src/NHibernate.Test/TypesTest/BinaryTypeFixture.cs +++ b/src/NHibernate.Test/TypesTest/BinaryTypeFixture.cs @@ -110,7 +110,7 @@ public void InsertZeroLength() /// /// Test the setting of values in Parameters and the reading of the - /// values out of the IDataReader. + /// values out of the DbDataReader. /// [Test] public void ReadWrite() diff --git a/src/NHibernate.Test/TypesTest/GuidTypeFixture.cs b/src/NHibernate.Test/TypesTest/GuidTypeFixture.cs index 5e9b89b8327..61620762521 100644 --- a/src/NHibernate.Test/TypesTest/GuidTypeFixture.cs +++ b/src/NHibernate.Test/TypesTest/GuidTypeFixture.cs @@ -1,5 +1,6 @@ using System; using System.Data; +using System.Data.Common; using NHibernate.Criterion; using NHibernate.Type; using NUnit.Framework; @@ -102,7 +103,7 @@ public void GetGuidWorksWhenUnderlyingTypeIsRepresentedByString() row["guid"] = value; row["varchar"] = value.ToString(); data.Rows.Add(row); - IDataReader reader = data.CreateDataReader(); + var reader = data.CreateDataReader(); reader.Read(); Assert.AreEqual(value, type.Get(reader, "guid")); diff --git a/src/NHibernate.Test/VersionTest/Db/MsSQL/BinaryTimestamp.cs b/src/NHibernate.Test/VersionTest/Db/MsSQL/BinaryTimestamp.cs index 589cf05d908..7d51985aa87 100644 --- a/src/NHibernate.Test/VersionTest/Db/MsSQL/BinaryTimestamp.cs +++ b/src/NHibernate.Test/VersionTest/Db/MsSQL/BinaryTimestamp.cs @@ -1,4 +1,5 @@ using System.Data; +using System.Data.Common; using NHibernate.Engine; using NHibernate.SqlTypes; using NHibernate.UserTypes; @@ -44,12 +45,12 @@ public bool IsMutable get { return false; } } - public object NullSafeGet(IDataReader rs, string[] names, object owner) + public object NullSafeGet(DbDataReader rs, string[] names, object owner) { return rs.GetValue(rs.GetOrdinal(names[0])); } - public void NullSafeSet(IDbCommand cmd, object value, int index) + public void NullSafeSet(DbCommand cmd, object value, int index) { NHibernateUtil.Binary.NullSafeSet(cmd, value, index); } diff --git a/src/NHibernate/AdoNet/AbstractBatcher.cs b/src/NHibernate/AdoNet/AbstractBatcher.cs index f8b1b9662bb..851f6cf3e12 100644 --- a/src/NHibernate/AdoNet/AbstractBatcher.cs +++ b/src/NHibernate/AdoNet/AbstractBatcher.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Data; +using System.Data.Common; using System.Diagnostics; using System.Threading; @@ -31,13 +32,13 @@ public abstract class AbstractBatcher : IBatcher // batchCommand used to be called batchUpdate - that name to me implied that updates // were being sent - however this could be just INSERT/DELETE/SELECT SQL statement not // just update. However I haven't seen this being used with read statements... - private IDbCommand _batchCommand; + private DbCommand _batchCommand; private SqlString _batchCommandSql; private SqlType[] _batchCommandParameterTypes; - private readonly HashSet _commandsToClose = new HashSet(); - private readonly HashSet _readersToClose = new HashSet(); - private readonly IDictionary _readersDuration = new Dictionary(); - private IDbCommand _lastQuery; + private readonly HashSet _commandsToClose = new HashSet(); + private readonly HashSet _readersToClose = new HashSet(); + private readonly IDictionary _readersDuration = new Dictionary(); + private DbCommand _lastQuery; private bool _releasing; /// @@ -58,41 +59,41 @@ protected IDriver Driver } /// - /// Gets the current that is contained for this Batch + /// Gets the current that is contained for this Batch /// - /// The current . - protected IDbCommand CurrentCommand + /// The current . + protected DbCommand CurrentCommand { get { return _batchCommand; } } - public IDbCommand Generate(CommandType type, SqlString sqlString, SqlType[] parameterTypes) + public DbCommand Generate(CommandType type, SqlString sqlString, SqlType[] parameterTypes) { SqlString sql = GetSQL(sqlString); - IDbCommand cmd = _factory.ConnectionProvider.Driver.GenerateCommand(type, sql, parameterTypes); + var cmd = _factory.ConnectionProvider.Driver.GenerateCommand(type, sql, parameterTypes); LogOpenPreparedCommand(); if (Log.IsDebugEnabled) { - Log.Debug("Building an IDbCommand object for the SqlString: " + sql); + Log.Debug("Building an DbCommand object for the SqlString: " + sql); } _commandsToClose.Add(cmd); return cmd; } /// - /// Prepares the for execution in the database. + /// Prepares the for execution in the database. /// /// - /// This takes care of hooking the up to an - /// and if one exists. It will call Prepare if the Driver + /// This takes care of hooking the up to an + /// and if one exists. It will call Prepare if the Driver /// supports preparing commands. /// - protected void Prepare(IDbCommand cmd) + protected void Prepare(DbCommand cmd) { try { - IDbConnection sessionConnection = _connectionManager.GetConnection(); + var sessionConnection = _connectionManager.GetConnection(); if (cmd.Connection != null) { @@ -117,7 +118,7 @@ protected void Prepare(IDbCommand cmd) } } - public virtual IDbCommand PrepareBatchCommand(CommandType type, SqlString sql, SqlType[] parameterTypes) + public virtual DbCommand PrepareBatchCommand(CommandType type, SqlString sql, SqlType[] parameterTypes) { if (sql.Equals(_batchCommandSql) && ArrayHelper.ArrayEquals(parameterTypes, _batchCommandParameterTypes)) { @@ -136,7 +137,7 @@ public virtual IDbCommand PrepareBatchCommand(CommandType type, SqlString sql, S return _batchCommand; } - public IDbCommand PrepareCommand(CommandType type, SqlString sql, SqlType[] parameterTypes) + public DbCommand PrepareCommand(CommandType type, SqlString sql, SqlType[] parameterTypes) { OnPreparedCommand(); @@ -149,25 +150,25 @@ public IDbCommand PrepareCommand(CommandType type, SqlString sql, SqlType[] para protected virtual void OnPreparedCommand() { - // a new IDbCommand is being prepared and a new (potential) batch + // a new DbCommand is being prepared and a new (potential) batch // started - so execute the current batch of commands. ExecuteBatch(); } - public IDbCommand PrepareQueryCommand(CommandType type, SqlString sql, SqlType[] parameterTypes) + public DbCommand PrepareQueryCommand(CommandType type, SqlString sql, SqlType[] parameterTypes) { // do not actually prepare the Command here - instead just generate it because // if the command is associated with an ADO.NET Transaction/Connection while // another open one Command is doing something then an exception will be // thrown. - IDbCommand command = Generate(type, sql, parameterTypes); + var command = Generate(type, sql, parameterTypes); _lastQuery = command; return command; } public void AbortBatch(Exception e) { - IDbCommand cmd = _batchCommand; + var cmd = _batchCommand; InvalidateBatchCommand(); // close the statement closeStatement(cmd) if (cmd != null) @@ -183,7 +184,7 @@ private void InvalidateBatchCommand() _batchCommandParameterTypes = null; } - public int ExecuteNonQuery(IDbCommand cmd) + public int ExecuteNonQuery(DbCommand cmd) { CheckReaders(); LogCommand(cmd); @@ -208,7 +209,7 @@ public int ExecuteNonQuery(IDbCommand cmd) } } - public virtual IDataReader ExecuteReader(IDbCommand cmd) + public virtual DbDataReader ExecuteReader(DbCommand cmd) { CheckReaders(); LogCommand(cmd); @@ -216,7 +217,7 @@ public virtual IDataReader ExecuteReader(IDbCommand cmd) Stopwatch duration = null; if (Log.IsDebugEnabled) duration = Stopwatch.StartNew(); - IDataReader reader = null; + DbDataReader reader = null; try { reader = cmd.ExecuteReader(); @@ -251,7 +252,7 @@ public virtual IDataReader ExecuteReader(IDbCommand cmd) /// protected void CheckReaders() { - // early exit because we don't need to move an open IDataReader into memory + // early exit because we don't need to move an open DbDataReader into memory // since the Driver supports mult open readers. if (_factory.ConnectionProvider.Driver.SupportsMultipleOpenReaders) { @@ -269,7 +270,7 @@ public void CloseCommands() _releasing = true; try { - foreach (IDataReader reader in new HashSet(_readersToClose)) + foreach (var reader in new HashSet(_readersToClose)) { try { @@ -277,11 +278,11 @@ public void CloseCommands() } catch (Exception e) { - Log.Warn("Could not close IDataReader", e); + Log.Warn("Could not close DbDataReader", e); } } - foreach (IDbCommand cmd in _commandsToClose) + foreach (var cmd in _commandsToClose) { try { @@ -301,7 +302,7 @@ public void CloseCommands() } } - private void CloseCommand(IDbCommand cmd) + private void CloseCommand(DbCommand cmd) { try { @@ -328,7 +329,7 @@ private void CloseCommand(IDbCommand cmd) } } - public void CloseCommand(IDbCommand st, IDataReader reader) + public void CloseCommand(DbCommand st, DbDataReader reader) { _commandsToClose.Remove(st); try @@ -341,7 +342,7 @@ public void CloseCommand(IDbCommand st, IDataReader reader) } } - public void CloseReader(IDataReader reader) + public void CloseReader(DbDataReader reader) { /* This method was added because PrepareCommand don't really prepare the command * with its connection. @@ -349,12 +350,12 @@ public void CloseReader(IDataReader reader) * To do it we need to use the Batcher.ExecuteReader and then we need something * to close the opened reader. */ - // TODO NH: Study a way to use directly IDbCommand.ExecuteReader() outsite the batcher + // TODO NH: Study a way to use directly DbCommand.ExecuteReader() outsite the batcher // An example of it's use is the management of generated ID. if (reader == null) return; - ResultSetWrapper rsw = reader as ResultSetWrapper; + var rsw = reader as ResultSetWrapper; var actualReader = rsw == null ? reader : rsw.Target; _readersToClose.Remove(actualReader); @@ -389,7 +390,7 @@ public void ExecuteBatch() // being built for then execute it if (_batchCommand != null) { - IDbCommand ps = _batchCommand; + var ps = _batchCommand; InvalidateBatchCommand(); try { @@ -402,7 +403,7 @@ public void ExecuteBatch() } } - protected void ExecuteBatchWithTiming(IDbCommand ps) + protected void ExecuteBatchWithTiming(DbCommand ps) { Stopwatch duration = null; if (Log.IsDebugEnabled) @@ -415,7 +416,7 @@ protected void ExecuteBatchWithTiming(IDbCommand ps) duration.ElapsedMilliseconds); } - protected abstract void DoExecuteBatch(IDbCommand ps); + protected abstract void DoExecuteBatch(DbCommand ps); protected abstract int CountOfStatementsInCurrentBatch { get; } @@ -461,7 +462,7 @@ protected ConnectionManager ConnectionManager get { return _connectionManager; } } - protected void LogCommand(IDbCommand command) + protected void LogCommand(DbCommand command) { _factory.Settings.SqlStatementLogger.LogCommand(command, FormatStyle.Basic); } @@ -471,7 +472,7 @@ private void LogOpenPreparedCommand() if (Log.IsDebugEnabled) { int currentOpenCommandCount = Interlocked.Increment(ref _openCommandCount); - Log.Debug("Opened new IDbCommand, open IDbCommands: " + currentOpenCommandCount); + Log.Debug("Opened new DbCommand, open DbCommands: " + currentOpenCommandCount); } if (_factory.Statistics.IsStatisticsEnabled) @@ -485,7 +486,7 @@ private void LogClosePreparedCommand() if (Log.IsDebugEnabled) { int currentOpenCommandCount = Interlocked.Decrement(ref _openCommandCount); - Log.Debug("Closed IDbCommand, open IDbCommands: " + currentOpenCommandCount); + Log.Debug("Closed DbCommand, open DbCommands: " + currentOpenCommandCount); } if (_factory.Statistics.IsStatisticsEnabled) @@ -499,7 +500,7 @@ private static void LogOpenReader() if (Log.IsDebugEnabled) { int currentOpenReaderCount = Interlocked.Increment(ref _openReaderCount); - Log.Debug("Opened IDataReader, open IDataReaders: " + currentOpenReaderCount); + Log.Debug("Opened DbDataReader, open DbDataReaders: " + currentOpenReaderCount); } } @@ -508,7 +509,7 @@ private static void LogCloseReader() if (Log.IsDebugEnabled) { int currentOpenReaderCount = Interlocked.Decrement(ref _openReaderCount); - Log.Debug("Closed IDataReader, open IDataReaders :" + currentOpenReaderCount); + Log.Debug("Closed DbDataReader, open DbDataReaders :" + currentOpenReaderCount); } } diff --git a/src/NHibernate/AdoNet/ConnectionManager.cs b/src/NHibernate/AdoNet/ConnectionManager.cs index c111132b47b..5ace6b15a2f 100644 --- a/src/NHibernate/AdoNet/ConnectionManager.cs +++ b/src/NHibernate/AdoNet/ConnectionManager.cs @@ -1,5 +1,6 @@ using System; using System.Data; +using System.Data.Common; using System.Runtime.Serialization; using System.Security; using System.Security.Permissions; @@ -28,7 +29,7 @@ public interface Callback } [NonSerialized] - private IDbConnection connection; + private DbConnection connection; // Whether we own the connection, i.e. connect and disconnect automatically. private bool ownConnection; @@ -49,7 +50,7 @@ public interface Callback public ConnectionManager( ISessionImplementor session, - IDbConnection suppliedConnection, + DbConnection suppliedConnection, ConnectionReleaseMode connectionReleaseMode, IInterceptor interceptor) { @@ -88,7 +89,7 @@ public void Reconnect() ownConnection = true; } - public void Reconnect(IDbConnection suppliedConnection) + public void Reconnect(DbConnection suppliedConnection) { if (IsConnected) { @@ -100,7 +101,7 @@ public void Reconnect(IDbConnection suppliedConnection) ownConnection = false; } - public IDbConnection Close() + public DbConnection Close() { if (batcher != null) { @@ -126,14 +127,14 @@ public IDbConnection Close() } } - private IDbConnection DisconnectSuppliedConnection() + private DbConnection DisconnectSuppliedConnection() { if (connection == null) { throw new HibernateException("Session already disconnected"); } - IDbConnection c = connection; + var c = connection; connection = null; return c; } @@ -154,7 +155,7 @@ private void DisconnectOwnConnection() CloseConnection(); } - public IDbConnection Disconnect() + public DbConnection Disconnect() { if (IsInActiveTransaction) throw new InvalidOperationException("Disconnect cannot be called while a transaction is in progress."); @@ -177,7 +178,7 @@ private void CloseConnection() connection = null; } - public IDbConnection GetConnection() + public DbConnection GetConnection() { if (connection == null) { @@ -403,7 +404,7 @@ public void Dispose() } } - public IDbCommand CreateCommand() + public DbCommand CreateCommand() { var result = GetConnection().CreateCommand(); Transaction.Enlist(result); diff --git a/src/NHibernate/AdoNet/Expectations.cs b/src/NHibernate/AdoNet/Expectations.cs index 815afb75401..ce5c28e025b 100644 --- a/src/NHibernate/AdoNet/Expectations.cs +++ b/src/NHibernate/AdoNet/Expectations.cs @@ -1,5 +1,5 @@ using System; -using System.Data; +using System.Data.Common; using NHibernate.Engine; namespace NHibernate.AdoNet @@ -21,7 +21,7 @@ public BasicExpectation(int expectedRowCount) } } - public void VerifyOutcomeNonBatched(int rowCount, IDbCommand statement) + public void VerifyOutcomeNonBatched(int rowCount, DbCommand statement) { rowCount = DetermineRowCount(rowCount, statement); if (expectedRowCount > rowCount) @@ -47,7 +47,7 @@ public virtual int ExpectedRowCount get { return expectedRowCount; } } - protected virtual int DetermineRowCount(int reportedRowCount, IDbCommand statement) + protected virtual int DetermineRowCount(int reportedRowCount, DbCommand statement) { return reportedRowCount; } @@ -55,7 +55,7 @@ protected virtual int DetermineRowCount(int reportedRowCount, IDbCommand stateme public class NoneExpectation : IExpectation { - public void VerifyOutcomeNonBatched(int rowCount, IDbCommand statement) + public void VerifyOutcomeNonBatched(int rowCount, DbCommand statement) { // explicitly perform no checking... } diff --git a/src/NHibernate/AdoNet/IExpectation.cs b/src/NHibernate/AdoNet/IExpectation.cs index e8c9d0b0ece..fba1b7fdf86 100644 --- a/src/NHibernate/AdoNet/IExpectation.cs +++ b/src/NHibernate/AdoNet/IExpectation.cs @@ -1,11 +1,10 @@ -using System; -using System.Data; +using System.Data.Common; namespace NHibernate.AdoNet { public interface IExpectation { - void VerifyOutcomeNonBatched(int rowCount, IDbCommand statement); + void VerifyOutcomeNonBatched(int rowCount, DbCommand statement); bool CanBeBatched { get; } /// diff --git a/src/NHibernate/AdoNet/MySqlClientBatchingBatcher.cs b/src/NHibernate/AdoNet/MySqlClientBatchingBatcher.cs index 3dd2d9466fc..d265137fd53 100644 --- a/src/NHibernate/AdoNet/MySqlClientBatchingBatcher.cs +++ b/src/NHibernate/AdoNet/MySqlClientBatchingBatcher.cs @@ -1,4 +1,3 @@ -using System.Data; using System.Data.Common; using System.Text; using NHibernate.AdoNet.Util; @@ -40,7 +39,7 @@ protected override int CountOfStatementsInCurrentBatch public override void AddToBatch(IExpectation expectation) { totalExpectedRowsAffected += expectation.ExpectedRowCount; - IDbCommand batchUpdate = CurrentCommand; + var batchUpdate = CurrentCommand; Prepare(batchUpdate); Driver.AdjustCommand(batchUpdate); string lineWithParameters = null; @@ -67,7 +66,7 @@ public override void AddToBatch(IExpectation expectation) } } - protected override void DoExecuteBatch(IDbCommand ps) + protected override void DoExecuteBatch(DbCommand ps) { Log.DebugFormat("Executing batch"); CheckReaders(); diff --git a/src/NHibernate/AdoNet/MySqlClientSqlCommandSet.cs b/src/NHibernate/AdoNet/MySqlClientSqlCommandSet.cs index 0847369d433..af87b6aae5c 100644 --- a/src/NHibernate/AdoNet/MySqlClientSqlCommandSet.cs +++ b/src/NHibernate/AdoNet/MySqlClientSqlCommandSet.cs @@ -1,5 +1,5 @@ using System; -using System.Data; +using System.Data.Common; using System.Diagnostics; using System.Reflection; using NHibernate.Util; @@ -11,7 +11,7 @@ public class MySqlClientSqlCommandSet : IDisposable private static readonly System.Type adapterType; private static readonly Action doInitialise; private static readonly Action batchSizeSetter; - private static readonly Action doAppend; + private static readonly Action doAppend; private static readonly Func doExecuteNonQuery; private static readonly Action doDispose; @@ -26,7 +26,7 @@ static MySqlClientSqlCommandSet() doInitialise = DelegateHelper.BuildAction(adapterType, "InitializeBatching"); batchSizeSetter = DelegateHelper.BuildPropertySetter(adapterType, "UpdateBatchSize"); - doAppend = DelegateHelper.BuildAction(adapterType, "AddToBatch"); + doAppend = DelegateHelper.BuildAction(adapterType, "AddToBatch"); doExecuteNonQuery = DelegateHelper.BuildFunc(adapterType, "ExecuteBatch"); doDispose = DelegateHelper.BuildAction(adapterType, "Dispose"); } @@ -38,7 +38,7 @@ public MySqlClientSqlCommandSet(int batchSize) batchSizeSetter(instance, batchSize); } - public void Append(IDbCommand command) + public void Append(DbCommand command) { doAppend(instance, command); countOfCommands++; diff --git a/src/NHibernate/AdoNet/NonBatchingBatcher.cs b/src/NHibernate/AdoNet/NonBatchingBatcher.cs index 2fb3a7ad37a..be0241e101f 100644 --- a/src/NHibernate/AdoNet/NonBatchingBatcher.cs +++ b/src/NHibernate/AdoNet/NonBatchingBatcher.cs @@ -1,5 +1,5 @@ using System; -using System.Data; +using System.Data.Common; using NHibernate.AdoNet; using NHibernate.Engine; @@ -22,7 +22,7 @@ public NonBatchingBatcher(ConnectionManager connectionManager, IInterceptor inte } /// - /// Executes the current and compares the row Count + /// Executes the current and compares the row Count /// to the expectedRowCount. /// /// @@ -35,7 +35,7 @@ public NonBatchingBatcher(ConnectionManager connectionManager, IInterceptor inte /// public override void AddToBatch(IExpectation expectation) { - IDbCommand cmd = CurrentCommand; + var cmd = CurrentCommand; Driver.AdjustCommand(cmd); int rowCount = ExecuteNonQuery(cmd); expectation.VerifyOutcomeNonBatched(rowCount, cmd); @@ -43,11 +43,11 @@ public override void AddToBatch(IExpectation expectation) /// /// This Batcher implementation does not support batching so this is a no-op call. The - /// actual execution of the is run in the AddToBatch + /// actual execution of the is run in the AddToBatch /// method. /// /// - protected override void DoExecuteBatch(IDbCommand ps) + protected override void DoExecuteBatch(DbCommand ps) { } diff --git a/src/NHibernate/AdoNet/OracleDataClientBatchingBatcher.cs b/src/NHibernate/AdoNet/OracleDataClientBatchingBatcher.cs index 96d0661d1c0..0398dcb08cd 100644 --- a/src/NHibernate/AdoNet/OracleDataClientBatchingBatcher.cs +++ b/src/NHibernate/AdoNet/OracleDataClientBatchingBatcher.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Data; using System.Data.Common; using System.Text; using NHibernate.AdoNet.Util; @@ -17,7 +16,7 @@ public class OracleDataClientBatchingBatcher : AbstractBatcher private int _batchSize; private int _countOfCommands; private int _totalExpectedRowsAffected; - private IDbCommand _currentBatch; + private DbCommand _currentBatch; private IDictionary> _parameterValueListHashTable; private IDictionary _parameterIsAllNullsHashTable; private StringBuilder _currentBatchCommandsLog; @@ -68,7 +67,7 @@ public override void AddToBatch(IExpectation expectation) firstOnBatch = false; } - foreach (IDataParameter currentParameter in CurrentCommand.Parameters) + foreach (DbParameter currentParameter in CurrentCommand.Parameters) { List parameterValueList; if (firstOnBatch) @@ -97,7 +96,7 @@ public override void AddToBatch(IExpectation expectation) } } - protected override void DoExecuteBatch(IDbCommand ps) + protected override void DoExecuteBatch(DbCommand ps) { if (_currentBatch != null) { @@ -114,7 +113,7 @@ protected override void DoExecuteBatch(IDbCommand ps) _currentBatchCommandsLog = new StringBuilder().AppendLine("Batch commands:"); } - foreach (IDataParameter currentParameter in _currentBatch.Parameters) + foreach (DbParameter currentParameter in _currentBatch.Parameters) { List parameterValueArray = _parameterValueListHashTable[currentParameter.ParameterName]; currentParameter.Value = parameterValueArray.ToArray(); diff --git a/src/NHibernate/AdoNet/ResultSetWrapper.cs b/src/NHibernate/AdoNet/ResultSetWrapper.cs index 48dc20f4e57..f3a291e971e 100644 --- a/src/NHibernate/AdoNet/ResultSetWrapper.cs +++ b/src/NHibernate/AdoNet/ResultSetWrapper.cs @@ -1,5 +1,6 @@ using System; using System.Data; +using System.Data.Common; namespace NHibernate.AdoNet { @@ -9,23 +10,23 @@ namespace NHibernate.AdoNet /// and Postgres). /// /// - public class ResultSetWrapper : IDataReader + public class ResultSetWrapper : DbDataReader { - private readonly IDataReader rs; + private readonly DbDataReader rs; private readonly ColumnNameCache columnNameCache; - public ResultSetWrapper(IDataReader resultSet, ColumnNameCache columnNameCache) + public ResultSetWrapper(DbDataReader resultSet, ColumnNameCache columnNameCache) { rs = resultSet; this.columnNameCache = columnNameCache; } - internal IDataReader Target + internal DbDataReader Target { get { return rs; } } - #region IDataReader Members + #region DbDataReader Members public void Close() { @@ -198,7 +199,7 @@ public DateTime GetDateTime(int i) return rs.GetDateTime(i); } - public IDataReader GetData(int i) + public DbDataReader GetData(int i) { return rs.GetData(i); } diff --git a/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs b/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs index be1a690a102..2fbff365c61 100644 --- a/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs +++ b/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs @@ -1,5 +1,4 @@ using System; -using System.Data; using System.Data.Common; using System.Text; using NHibernate.AdoNet.Util; @@ -44,7 +43,7 @@ protected override int CountOfStatementsInCurrentBatch public override void AddToBatch(IExpectation expectation) { _totalExpectedRowsAffected += expectation.ExpectedRowCount; - IDbCommand batchUpdate = CurrentCommand; + var batchUpdate = CurrentCommand; Driver.AdjustCommand(batchUpdate); string lineWithParameters = null; var sqlStatementLogger = Factory.Settings.SqlStatementLogger; @@ -70,7 +69,7 @@ public override void AddToBatch(IExpectation expectation) } } - protected override void DoExecuteBatch(IDbCommand ps) + protected override void DoExecuteBatch(DbCommand ps) { Log.DebugFormat("Executing batch"); CheckReaders(); diff --git a/src/NHibernate/AdoNet/Util/SqlStatementLogger.cs b/src/NHibernate/AdoNet/Util/SqlStatementLogger.cs index 4504248d1e3..494a6ea6a05 100644 --- a/src/NHibernate/AdoNet/Util/SqlStatementLogger.cs +++ b/src/NHibernate/AdoNet/Util/SqlStatementLogger.cs @@ -1,8 +1,8 @@ using System; using System.Data; +using System.Data.Common; using System.Text; - namespace NHibernate.AdoNet.Util { /// Centralize logging handling for SQL statements. @@ -33,11 +33,11 @@ public bool IsDebugEnabled get { return Logger.IsDebugEnabled; } } - /// Log a IDbCommand. + /// Log a DbCommand. /// Title /// The SQL statement. /// The requested formatting style. - public virtual void LogCommand(string message, IDbCommand command, FormatStyle style) + public virtual void LogCommand(string message, DbCommand command, FormatStyle style) { if (!Logger.IsDebugEnabled && !LogToStdout || string.IsNullOrEmpty(command.CommandText)) { @@ -62,15 +62,15 @@ public virtual void LogCommand(string message, IDbCommand command, FormatStyle s } } - /// Log a IDbCommand. + /// Log a DbCommand. /// The SQL statement. /// The requested formatting style. - public virtual void LogCommand(IDbCommand command, FormatStyle style) + public virtual void LogCommand(DbCommand command, FormatStyle style) { LogCommand(null, command, style); } - public string GetCommandLineWithParameters(IDbCommand command) + public string GetCommandLineWithParameters(DbCommand command) { string outputText; @@ -84,7 +84,6 @@ public string GetCommandLineWithParameters(IDbCommand command) output.Append(command.CommandText.TrimEnd(' ', ';', '\n')); output.Append(";"); - IDataParameter p; int count = command.Parameters.Count; bool appendComma = false; for (int i = 0; i < count; i++) @@ -94,25 +93,25 @@ public string GetCommandLineWithParameters(IDbCommand command) output.Append(", "); } appendComma = true; - p = (IDataParameter) command.Parameters[i]; - output.Append( - string.Format("{0} = {1} [Type: {2}]", p.ParameterName, GetParameterLoggableValue(p), GetParameterLoggableType(p))); + var p = command.Parameters[i]; + output.AppendFormat( + "{0} = {1} [Type: {2}]", p.ParameterName, GetParameterLoggableValue(p), GetParameterLoggableType(p)); } outputText = output.ToString(); } return outputText; } - private static string GetParameterLoggableType(IDataParameter dataParameter) + private static string GetParameterLoggableType(DbParameter dataParameter) { + //TODO: Fix me after 4.6.2 update. Size and Precision has been added to DbParameter var p = dataParameter as IDbDataParameter; if (p != null) return p.DbType + " (" + p.Size + ":" + p.Scale + ":" + p.Precision + ")"; return dataParameter.DbType.ToString(); } - - public string GetParameterLoggableValue(IDataParameter parameter) + public string GetParameterLoggableValue(DbParameter parameter) { const int maxLoggableStringLength = 1000; @@ -144,7 +143,7 @@ public string GetParameterLoggableValue(IDataParameter parameter) [Obsolete("Use GetParameterLoggableValue(parameter) instead.")] - public string GetParameterLogableValue(IDataParameter parameter) + public string GetParameterLogableValue(DbParameter parameter) { return GetParameterLoggableValue(parameter); } diff --git a/src/NHibernate/Collection/AbstractPersistentCollection.cs b/src/NHibernate/Collection/AbstractPersistentCollection.cs index 76e9f5923b9..241a240c06b 100644 --- a/src/NHibernate/Collection/AbstractPersistentCollection.cs +++ b/src/NHibernate/Collection/AbstractPersistentCollection.cs @@ -1,7 +1,7 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Data; +using System.Data.Common; using NHibernate.Collection.Generic; using NHibernate.Engine; using NHibernate.Impl; @@ -410,7 +410,7 @@ public virtual void PostAction() } /// - /// Called just before reading any rows from the + /// Called just before reading any rows from the /// public virtual void BeginRead() { @@ -419,7 +419,7 @@ public virtual void BeginRead() } /// - /// Called after reading all rows from the + /// Called after reading all rows from the /// /// /// This should be overridden by sub collections that use temporary collections @@ -821,14 +821,14 @@ public virtual object GetIdentifier(object entry, int i) public abstract bool NeedsUpdating(object entry, int i, IType elemType); /// - /// Reads the row from the . + /// Reads the row from the . /// - /// The IDataReader that contains the value of the Identifier + /// The DbDataReader that contains the value of the Identifier /// The persister for this Collection. /// The descriptor providing result set column names /// The owner of this Collection. /// The object that was contained in the row. - public abstract object ReadFrom(IDataReader reader, ICollectionPersister role, ICollectionAliases descriptor, + public abstract object ReadFrom(DbDataReader reader, ICollectionPersister role, ICollectionAliases descriptor, object owner); public abstract object GetSnapshotElement(object entry, int i); diff --git a/src/NHibernate/Collection/Generic/PersistentGenericBag.cs b/src/NHibernate/Collection/Generic/PersistentGenericBag.cs index 515e3e557d2..2c5ff104a72 100644 --- a/src/NHibernate/Collection/Generic/PersistentGenericBag.cs +++ b/src/NHibernate/Collection/Generic/PersistentGenericBag.cs @@ -1,7 +1,7 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Data; +using System.Data.Common; using System.Diagnostics; using NHibernate.DebugHelpers; using NHibernate.Engine; @@ -489,7 +489,7 @@ public override bool NeedsUpdating(object entry, int i, IType elemType) return false; } - public override object ReadFrom(IDataReader reader, ICollectionPersister role, ICollectionAliases descriptor, object owner) + public override object ReadFrom(DbDataReader reader, ICollectionPersister role, ICollectionAliases descriptor, object owner) { // note that if we load this collection from a cartesian product // the multiplicity would be broken ... so use an idbag instead diff --git a/src/NHibernate/Collection/Generic/PersistentGenericIdentifierBag.cs b/src/NHibernate/Collection/Generic/PersistentGenericIdentifierBag.cs index 93330e8a044..21147b24f56 100644 --- a/src/NHibernate/Collection/Generic/PersistentGenericIdentifierBag.cs +++ b/src/NHibernate/Collection/Generic/PersistentGenericIdentifierBag.cs @@ -1,7 +1,7 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Data; +using System.Data.Common; using System.Diagnostics; using System.Linq; using NHibernate.DebugHelpers; @@ -212,7 +212,7 @@ public override bool NeedsUpdating(object entry, int i, IType elemType) return old != null && elemType.IsDirty(old, entry, Session); } - public override object ReadFrom(IDataReader reader, ICollectionPersister persister, ICollectionAliases descriptor, object owner) + public override object ReadFrom(DbDataReader reader, ICollectionPersister persister, ICollectionAliases descriptor, object owner) { object element = persister.ReadElement(reader, owner, descriptor.SuffixedElementAliases, Session); object id = persister.ReadIdentifier(reader, descriptor.SuffixedIdentifierAlias, Session); diff --git a/src/NHibernate/Collection/Generic/PersistentGenericList.cs b/src/NHibernate/Collection/Generic/PersistentGenericList.cs index d091f51d077..089c912d26b 100644 --- a/src/NHibernate/Collection/Generic/PersistentGenericList.cs +++ b/src/NHibernate/Collection/Generic/PersistentGenericList.cs @@ -1,7 +1,7 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Data; +using System.Data.Common; using System.Diagnostics; using NHibernate.DebugHelpers; using NHibernate.Engine; @@ -115,7 +115,7 @@ public override string ToString() return StringHelper.CollectionToString(WrappedList); } - public override object ReadFrom(IDataReader rs, ICollectionPersister role, ICollectionAliases descriptor, object owner) + public override object ReadFrom(DbDataReader rs, ICollectionPersister role, ICollectionAliases descriptor, object owner) { var element = (T)role.ReadElement(rs, owner, descriptor.SuffixedElementAliases, Session); int index = (int)role.ReadIndex(rs, descriptor.SuffixedIndexAliases, Session); diff --git a/src/NHibernate/Collection/Generic/PersistentGenericMap.cs b/src/NHibernate/Collection/Generic/PersistentGenericMap.cs index 6ef14fe89cb..ad175aaff79 100644 --- a/src/NHibernate/Collection/Generic/PersistentGenericMap.cs +++ b/src/NHibernate/Collection/Generic/PersistentGenericMap.cs @@ -1,7 +1,7 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Data; +using System.Data.Common; using System.Diagnostics; using NHibernate.DebugHelpers; using NHibernate.Engine; @@ -107,7 +107,7 @@ public override string ToString() return StringHelper.CollectionToString(WrappedMap); } - public override object ReadFrom(IDataReader rs, ICollectionPersister role, ICollectionAliases descriptor, object owner) + public override object ReadFrom(DbDataReader rs, ICollectionPersister role, ICollectionAliases descriptor, object owner) { object element = role.ReadElement(rs, owner, descriptor.SuffixedElementAliases, Session); object index = role.ReadIndex(rs, descriptor.SuffixedIndexAliases, Session); diff --git a/src/NHibernate/Collection/Generic/PersistentGenericSet.cs b/src/NHibernate/Collection/Generic/PersistentGenericSet.cs index 19aa4297d9c..b334ad1a8a7 100644 --- a/src/NHibernate/Collection/Generic/PersistentGenericSet.cs +++ b/src/NHibernate/Collection/Generic/PersistentGenericSet.cs @@ -1,7 +1,7 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Data; +using System.Data.Common; using System.Diagnostics; using System.Linq; using NHibernate.Collection.Generic.SetHelpers; @@ -163,7 +163,7 @@ public override string ToString() return StringHelper.CollectionToString(WrappedSet); } - public override object ReadFrom(IDataReader rs, ICollectionPersister role, ICollectionAliases descriptor, object owner) + public override object ReadFrom(DbDataReader rs, ICollectionPersister role, ICollectionAliases descriptor, object owner) { var element = role.ReadElement(rs, owner, descriptor.SuffixedElementAliases, Session); if (element != null) diff --git a/src/NHibernate/Collection/IPersistentCollection.cs b/src/NHibernate/Collection/IPersistentCollection.cs index 6bb0a85f097..92a296428ac 100644 --- a/src/NHibernate/Collection/IPersistentCollection.cs +++ b/src/NHibernate/Collection/IPersistentCollection.cs @@ -1,5 +1,5 @@ using System.Collections; -using System.Data; +using System.Data.Common; using NHibernate.Collection.Generic; using NHibernate.Engine; using NHibernate.Loader; @@ -102,12 +102,12 @@ public interface IPersistentCollection void PostAction(); /// - /// Called just before reading any rows from the + /// Called just before reading any rows from the /// void BeginRead(); /// - /// Called after reading all rows from the + /// Called after reading all rows from the /// /// /// This should be overridden by sub collections that use temporary collections @@ -174,17 +174,17 @@ public interface IPersistentCollection IEnumerable Entries(ICollectionPersister persister); /// - /// Reads the row from the . + /// Reads the row from the . /// /// /// This method should be prepared to handle duplicate elements caused by fetching multiple collections. /// - /// The IDataReader that contains the value of the Identifier + /// The DbDataReader that contains the value of the Identifier /// The persister for this Collection. /// The descriptor providing result set column names /// The owner of this Collection. /// The object that was contained in the row. - object ReadFrom(IDataReader reader, ICollectionPersister role, ICollectionAliases descriptor, object owner); + object ReadFrom(DbDataReader reader, ICollectionPersister role, ICollectionAliases descriptor, object owner); /// /// Get the identifier of the given collection entry diff --git a/src/NHibernate/Collection/PersistentArrayHolder.cs b/src/NHibernate/Collection/PersistentArrayHolder.cs index 4e1216dbbbb..c274ce7f419 100644 --- a/src/NHibernate/Collection/PersistentArrayHolder.cs +++ b/src/NHibernate/Collection/PersistentArrayHolder.cs @@ -1,7 +1,7 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Data; +using System.Data.Common; using System.Diagnostics; using NHibernate.DebugHelpers; @@ -142,7 +142,7 @@ public override bool Empty get { return false; } } - public override object ReadFrom(IDataReader rs, ICollectionPersister role, ICollectionAliases descriptor, object owner) + public override object ReadFrom(DbDataReader rs, ICollectionPersister role, ICollectionAliases descriptor, object owner) { object element = role.ReadElement(rs, owner, descriptor.SuffixedElementAliases, Session); int index = (int) role.ReadIndex(rs, descriptor.SuffixedIndexAliases, Session); diff --git a/src/NHibernate/Connection/ConnectionProvider.cs b/src/NHibernate/Connection/ConnectionProvider.cs index 5f9a816f00c..8be053981e8 100644 --- a/src/NHibernate/Connection/ConnectionProvider.cs +++ b/src/NHibernate/Connection/ConnectionProvider.cs @@ -1,7 +1,7 @@ using System; using System.Collections; using System.Configuration; -using System.Data; +using System.Data.Common; using NHibernate.Driver; using NHibernate.Util; @@ -20,10 +20,10 @@ public abstract class ConnectionProvider : IConnectionProvider private IDriver driver; /// - /// Closes the . + /// Closes the . /// - /// The to clean up. - public virtual void CloseConnection(IDbConnection conn) + /// The to clean up. + public virtual void CloseConnection(DbConnection conn) { log.Debug("Closing connection"); try @@ -116,11 +116,11 @@ protected virtual void ConfigureDriver(IDictionary settings) } /// - /// Gets the for the + /// Gets the for the /// to connect to the database. /// /// - /// The for the + /// The for the /// to connect to the database. /// protected virtual string ConnectionString @@ -129,10 +129,10 @@ protected virtual string ConnectionString } /// - /// Gets the that can create the object. + /// Gets the that can create the object. /// /// - /// The that can create the . + /// The that can create the . /// public IDriver Driver { @@ -140,10 +140,10 @@ public IDriver Driver } /// - /// Get an open . + /// Get an open . /// - /// An open . - public abstract IDbConnection GetConnection(); + /// An open . + public abstract DbConnection GetConnection(); #region IDisposable Members diff --git a/src/NHibernate/Connection/DriverConnectionProvider.cs b/src/NHibernate/Connection/DriverConnectionProvider.cs index 3e62f136724..dd7eaa7861f 100644 --- a/src/NHibernate/Connection/DriverConnectionProvider.cs +++ b/src/NHibernate/Connection/DriverConnectionProvider.cs @@ -1,6 +1,5 @@ using System; -using System.Data; - +using System.Data.Common; namespace NHibernate.Connection { @@ -12,29 +11,29 @@ public class DriverConnectionProvider : ConnectionProvider private static readonly IInternalLogger log = LoggerProvider.LoggerFor(typeof(DriverConnectionProvider)); /// - /// Closes and Disposes of the . + /// Closes and Disposes of the . /// - /// The to clean up. - public override void CloseConnection(IDbConnection conn) + /// The to clean up. + public override void CloseConnection(DbConnection conn) { base.CloseConnection(conn); conn.Dispose(); } /// - /// Gets a new open through + /// Gets a new open through /// the . /// /// - /// An Open . + /// An Open . /// /// - /// If there is any problem creating or opening the . + /// If there is any problem creating or opening the . /// - public override IDbConnection GetConnection() + public override DbConnection GetConnection() { - log.Debug("Obtaining IDbConnection from Driver"); - IDbConnection conn = Driver.CreateConnection(); + log.Debug("Obtaining DbConnection from Driver"); + var conn = Driver.CreateConnection(); try { conn.ConnectionString = ConnectionString; diff --git a/src/NHibernate/Connection/IConnectionProvider.cs b/src/NHibernate/Connection/IConnectionProvider.cs index 49cb4d27844..a2f740f0229 100644 --- a/src/NHibernate/Connection/IConnectionProvider.cs +++ b/src/NHibernate/Connection/IConnectionProvider.cs @@ -1,16 +1,16 @@ using System; using System.Collections.Generic; -using System.Data; +using System.Data.Common; using NHibernate.Driver; namespace NHibernate.Connection { /// - /// A strategy for obtaining ADO.NET . + /// A strategy for obtaining ADO.NET . /// /// /// The IConnectionProvider interface is not intended to be exposed to the application. - /// Instead it is used internally by NHibernate to obtain . + /// Instead it is used internally by NHibernate to obtain . /// Implementors should provide a public default constructor. /// public interface IConnectionProvider : IDisposable @@ -22,10 +22,10 @@ public interface IConnectionProvider : IDisposable void Configure(IDictionary settings); /// - /// Dispose of a used + /// Dispose of a used /// - /// The to clean up. - void CloseConnection(IDbConnection conn); + /// The to clean up. + void CloseConnection(DbConnection conn); /// /// Gets the this ConnectionProvider should use to @@ -37,9 +37,9 @@ public interface IConnectionProvider : IDisposable IDriver Driver { get; } /// - /// Get an open . + /// Get an open . /// - /// An open . - IDbConnection GetConnection(); + /// An open . + DbConnection GetConnection(); } } \ No newline at end of file diff --git a/src/NHibernate/Connection/UserSuppliedConnectionProvider.cs b/src/NHibernate/Connection/UserSuppliedConnectionProvider.cs index 19e2918bf91..56faf6681e4 100644 --- a/src/NHibernate/Connection/UserSuppliedConnectionProvider.cs +++ b/src/NHibernate/Connection/UserSuppliedConnectionProvider.cs @@ -1,6 +1,6 @@ using System; using System.Collections.Generic; -using System.Data; +using System.Data.Common; namespace NHibernate.Connection @@ -18,30 +18,30 @@ public class UserSuppliedConnectionProvider : ConnectionProvider /// /// Throws an if this method is called - /// because the user is responsible for closing s. + /// because the user is responsible for closing s. /// - /// The to clean up. + /// The to clean up. /// /// Thrown when this method is called. User is responsible for closing - /// s. + /// s. /// - public override void CloseConnection(IDbConnection conn) + public override void CloseConnection(DbConnection conn) { throw new InvalidOperationException("The User is responsible for closing ADO.NET connection - not NHibernate."); } /// /// Throws an if this method is called - /// because the user is responsible for creating s. + /// because the user is responsible for creating s. /// /// /// No value is returned because an is thrown. /// /// /// Thrown when this method is called. User is responsible for creating - /// s. + /// s. /// - public override IDbConnection GetConnection() + public override DbConnection GetConnection() { throw new InvalidOperationException("The user must provide an ADO.NET connection - NHibernate is not creating it."); } diff --git a/src/NHibernate/Criterion/IProjection.cs b/src/NHibernate/Criterion/IProjection.cs index b3b2ed1be74..389f9625348 100644 --- a/src/NHibernate/Criterion/IProjection.cs +++ b/src/NHibernate/Criterion/IProjection.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Data.Common; using NHibernate.SqlCommand; using NHibernate.Engine; using NHibernate.Loader.Criteria; @@ -75,7 +76,7 @@ SqlString ToGroupSqlString(ICriteria criteria, /// /// Get the SQL column aliases used by this projection for the columns it writes for inclusion into the /// SELECT clause . NHibernate always uses column aliases - /// to extract data from the , so it is important that these be implemented + /// to extract data from the , so it is important that these be implemented /// correctly in order for NHibernate to be able to extract these values correctly. /// /// Just as in , represents the number of columns rendered prior to this projection. diff --git a/src/NHibernate/Dialect/Function/CastFunction.cs b/src/NHibernate/Dialect/Function/CastFunction.cs index 1d5548b44f8..cd1325014c3 100644 --- a/src/NHibernate/Dialect/Function/CastFunction.cs +++ b/src/NHibernate/Dialect/Function/CastFunction.cs @@ -1,6 +1,5 @@ using System; using System.Collections; -using System.Data; using System.Xml; using NHibernate.Engine; using NHibernate.SqlCommand; diff --git a/src/NHibernate/Dialect/GenericDialect.cs b/src/NHibernate/Dialect/GenericDialect.cs index af5fab9f238..545981b6249 100644 --- a/src/NHibernate/Dialect/GenericDialect.cs +++ b/src/NHibernate/Dialect/GenericDialect.cs @@ -1,3 +1,4 @@ + using System.Data; namespace NHibernate.Dialect diff --git a/src/NHibernate/Dialect/InformixDialect1000.cs b/src/NHibernate/Dialect/InformixDialect1000.cs index 11becd76f1d..db4c9781591 100644 --- a/src/NHibernate/Dialect/InformixDialect1000.cs +++ b/src/NHibernate/Dialect/InformixDialect1000.cs @@ -1,4 +1,3 @@ -using System.Data; using NHibernate.Cfg; using NHibernate.Dialect.Function; using NHibernate.SqlCommand; diff --git a/src/NHibernate/Dialect/Lock/SelectLockingStrategy.cs b/src/NHibernate/Dialect/Lock/SelectLockingStrategy.cs index 4fd139a25ad..4bf763d451d 100644 --- a/src/NHibernate/Dialect/Lock/SelectLockingStrategy.cs +++ b/src/NHibernate/Dialect/Lock/SelectLockingStrategy.cs @@ -1,5 +1,6 @@ using System; using System.Data; +using System.Data.Common; using NHibernate.Engine; using NHibernate.Persister.Entity; using NHibernate.SqlCommand; @@ -56,8 +57,8 @@ public void Lock(object id, object version, object obj, ISessionImplementor sess ISessionFactoryImplementor factory = session.Factory; try { - IDbCommand st = session.Batcher.PrepareCommand(CommandType.Text, sql, lockable.IdAndVersionSqlTypes); - IDataReader rs = null; + var st = session.Batcher.PrepareCommand(CommandType.Text, sql, lockable.IdAndVersionSqlTypes); + DbDataReader rs = null; try { lockable.IdentifierType.NullSafeSet(st, id, 0, session); diff --git a/src/NHibernate/Dialect/Lock/UpdateLockingStrategy.cs b/src/NHibernate/Dialect/Lock/UpdateLockingStrategy.cs index b6f3812133c..b2d0f677249 100644 --- a/src/NHibernate/Dialect/Lock/UpdateLockingStrategy.cs +++ b/src/NHibernate/Dialect/Lock/UpdateLockingStrategy.cs @@ -1,5 +1,6 @@ using System; using System.Data; +using System.Data.Common; using NHibernate.Engine; using NHibernate.Exceptions; @@ -74,7 +75,7 @@ public void Lock(object id, object version, object obj, ISessionImplementor sess ISessionFactoryImplementor factory = session.Factory; try { - IDbCommand st = session.Batcher.PrepareCommand(CommandType.Text, sql, lockable.IdAndVersionSqlTypes); + var st = session.Batcher.PrepareCommand(CommandType.Text, sql, lockable.IdAndVersionSqlTypes); try { lockable.VersionType.NullSafeSet(st, version, 1, session); diff --git a/src/NHibernate/Dialect/MySQL55Dialect.cs b/src/NHibernate/Dialect/MySQL55Dialect.cs index 8b951a088bd..fb5de2aa78b 100644 --- a/src/NHibernate/Dialect/MySQL55Dialect.cs +++ b/src/NHibernate/Dialect/MySQL55Dialect.cs @@ -1,3 +1,4 @@ + using System.Data; namespace NHibernate.Dialect diff --git a/src/NHibernate/Dialect/Schema/AbstractTableMetadata.cs b/src/NHibernate/Dialect/Schema/AbstractTableMetadata.cs index c0f250017f8..f550b6bee92 100644 --- a/src/NHibernate/Dialect/Schema/AbstractTableMetadata.cs +++ b/src/NHibernate/Dialect/Schema/AbstractTableMetadata.cs @@ -1,6 +1,5 @@ using System.Collections.Generic; using System.Data; - using NHibernate.Util; namespace NHibernate.Dialect.Schema diff --git a/src/NHibernate/Dialect/SybaseSQLAnywhere10Dialect.cs b/src/NHibernate/Dialect/SybaseSQLAnywhere10Dialect.cs index a6f9efcc3fd..49bae34a48c 100644 --- a/src/NHibernate/Dialect/SybaseSQLAnywhere10Dialect.cs +++ b/src/NHibernate/Dialect/SybaseSQLAnywhere10Dialect.cs @@ -792,7 +792,7 @@ public override int RegisterResultSetOutParameter(DbCommand statement, int posit public override DbDataReader GetResultSet(DbCommand statement) { - DbDataReader rdr = statement.ExecuteReader(); + var rdr = statement.ExecuteReader(); return rdr; } diff --git a/src/NHibernate/Driver/BasicResultSetsCommand.cs b/src/NHibernate/Driver/BasicResultSetsCommand.cs index 047024a9e06..a67bee32280 100644 --- a/src/NHibernate/Driver/BasicResultSetsCommand.cs +++ b/src/NHibernate/Driver/BasicResultSetsCommand.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Data; +using System.Data.Common; using System.Linq; using NHibernate.Engine; using NHibernate.SqlCommand; @@ -39,7 +40,7 @@ public virtual SqlString Sql get { return sqlString; } } - public virtual IDataReader GetReader(int? commandTimeout) + public virtual DbDataReader GetReader(int? commandTimeout) { var batcher = Session.Batcher; SqlType[] sqlTypes = Commands.SelectMany(c => c.ParameterTypes).ToArray(); @@ -54,7 +55,7 @@ public virtual IDataReader GetReader(int? commandTimeout) return new BatcherDataReaderWrapper(batcher, command); } - protected virtual void BindParameters(IDbCommand command) + protected virtual void BindParameters(DbCommand command) { var wholeQueryParametersList = Sql.GetParameters().ToList(); ForEachSqlCommand((sqlLoaderCommand, offset) => sqlLoaderCommand.Bind(command, wholeQueryParametersList, offset, Session)); @@ -78,13 +79,13 @@ protected void ForEachSqlCommand(Action actionToDo) /// /// Datareader wrapper with the same life cycle of its command (through the batcher) /// - public class BatcherDataReaderWrapper: IDataReader + public class BatcherDataReaderWrapper: DbDataReader { private readonly IBatcher batcher; - private readonly IDbCommand command; - private readonly IDataReader reader; + private readonly DbCommand command; + private readonly DbDataReader reader; - public BatcherDataReaderWrapper(IBatcher batcher, IDbCommand command) + public BatcherDataReaderWrapper(IBatcher batcher, DbCommand command) { if (batcher == null) { @@ -206,7 +207,7 @@ public DateTime GetDateTime(int i) return reader.GetDateTime(i); } - public IDataReader GetData(int i) + public DbDataReader GetData(int i) { return reader.GetData(i); } diff --git a/src/NHibernate/Driver/DbProviderFactoryDriveConnectionCommandProvider.cs b/src/NHibernate/Driver/DbProviderFactoryDriveConnectionCommandProvider.cs index 3542dda111a..3c3a36db553 100644 --- a/src/NHibernate/Driver/DbProviderFactoryDriveConnectionCommandProvider.cs +++ b/src/NHibernate/Driver/DbProviderFactoryDriveConnectionCommandProvider.cs @@ -1,5 +1,4 @@ using System; -using System.Data; using System.Data.Common; namespace NHibernate.Driver @@ -17,12 +16,12 @@ public DbProviderFactoryDriveConnectionCommandProvider(DbProviderFactory dbProvi this.dbProviderFactory = dbProviderFactory; } - public IDbConnection CreateConnection() + public DbConnection CreateConnection() { return dbProviderFactory.CreateConnection(); } - public IDbCommand CreateCommand() + public DbCommand CreateCommand() { return dbProviderFactory.CreateCommand(); } diff --git a/src/NHibernate/Driver/DriverBase.cs b/src/NHibernate/Driver/DriverBase.cs index 3301906dd2c..c61008b4c2e 100644 --- a/src/NHibernate/Driver/DriverBase.cs +++ b/src/NHibernate/Driver/DriverBase.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Data; +using System.Data.Common; using System.Linq; using NHibernate.Engine; using NHibernate.SqlCommand; @@ -42,8 +43,8 @@ protected bool IsPrepareSqlEnabled get { return prepareSql; } } - public abstract IDbConnection CreateConnection(); - public abstract IDbCommand CreateCommand(); + public abstract DbConnection CreateConnection(); + public abstract DbCommand CreateCommand(); /// /// Does this Driver require the use of a Named Prefix in the SQL statement. @@ -62,9 +63,9 @@ protected bool IsPrepareSqlEnabled /// /// This is really only useful when the UseNamedPrefixInSql == true. When this is true the /// code will look like: - /// IDbParameter param = cmd.Parameters["@paramName"] + /// DbParameter param = cmd.Parameters["@paramName"] /// if this is false the code will be - /// IDbParameter param = cmd.Parameters["paramName"]. + /// DbParameter param = cmd.Parameters["paramName"]. /// public abstract bool UseNamedPrefixInParameter { get; } @@ -77,25 +78,25 @@ protected bool IsPrepareSqlEnabled public abstract string NamedPrefix { get; } /// - /// Change the parameterName into the correct format IDbCommand.CommandText + /// Change the parameterName into the correct format DbCommand.CommandText /// for the ConnectionProvider /// /// The unformatted name of the parameter - /// A parameter formatted for an IDbCommand.CommandText + /// A parameter formatted for an DbCommand.CommandText public string FormatNameForSql(string parameterName) { return UseNamedPrefixInSql ? (NamedPrefix + parameterName) : StringHelper.SqlParameter; } /// - /// Changes the parameterName into the correct format for an IDbParameter + /// Changes the parameterName into the correct format for an DbParameter /// for the Driver. /// /// /// For SqlServerConnectionProvider it will change id to @id /// /// The unformatted name of the parameter - /// A parameter formatted for an IDbParameter. + /// A parameter formatted for an DbParameter. public string FormatNameForParameter(string parameterName) { return UseNamedPrefixInParameter ? (NamedPrefix + parameterName) : parameterName; @@ -107,16 +108,16 @@ public virtual bool SupportsMultipleOpenReaders } /// - /// Does this Driver support IDbCommand.Prepare(). + /// Does this Driver support DbCommand.Prepare(). /// /// /// /// A value of indicates that an exception would be thrown or the /// company that produces the Driver we are wrapping does not recommend using - /// IDbCommand.Prepare(). + /// DbCommand.Prepare(). /// /// - /// A value of indicates that calling IDbCommand.Prepare() will function + /// A value of indicates that calling DbCommand.Prepare() will function /// fine on this Driver. /// /// @@ -125,9 +126,9 @@ protected virtual bool SupportsPreparingCommands get { return true; } } - public virtual IDbCommand GenerateCommand(CommandType type, SqlString sqlString, SqlType[] parameterTypes) + public virtual DbCommand GenerateCommand(CommandType type, SqlString sqlString, SqlType[] parameterTypes) { - IDbCommand cmd = CreateCommand(); + var cmd = CreateCommand(); cmd.CommandType = type; SetCommandTimeout(cmd); @@ -137,7 +138,7 @@ public virtual IDbCommand GenerateCommand(CommandType type, SqlString sqlString, return cmd; } - protected virtual void SetCommandTimeout(IDbCommand cmd) + protected virtual void SetCommandTimeout(DbCommand cmd) { if (commandTimeout >= 0) { @@ -165,7 +166,7 @@ string ISqlParameterFormatter.GetParameterName(int index) return FormatNameForSql(ToParameterName(index)); } - private void SetCommandText(IDbCommand cmd, SqlString sqlString) + private void SetCommandText(DbCommand cmd, SqlString sqlString) { SqlStringFormatter formatter = GetSqlStringFormatter(); formatter.Format(sqlString); @@ -177,17 +178,17 @@ protected virtual SqlStringFormatter GetSqlStringFormatter() return new SqlStringFormatter(this, ";"); } - private void SetCommandParameters(IDbCommand cmd, SqlType[] sqlTypes) + private void SetCommandParameters(DbCommand cmd, SqlType[] sqlTypes) { for (int i = 0; i < sqlTypes.Length; i++) { string paramName = ToParameterName(i); - IDbDataParameter dbParam = GenerateParameter(cmd, paramName, sqlTypes[i]); + var dbParam = GenerateParameter(cmd, paramName, sqlTypes[i]); cmd.Parameters.Add(dbParam); } } - protected virtual void InitializeParameter(IDbDataParameter dbParam, string name, SqlType sqlType) + protected virtual void InitializeParameter(DbParameter dbParam, string name, SqlType sqlType) { if (sqlType == null) { @@ -199,22 +200,21 @@ protected virtual void InitializeParameter(IDbDataParameter dbParam, string name } /// - /// Generates an IDbDataParameter for the IDbCommand. It does not add the IDbDataParameter to the IDbCommand's + /// Generates an DbParameter for the DbCommand. It does not add the DbParameter to the DbCommand's /// Parameter collection. /// - /// The IDbCommand to use to create the IDbDataParameter. - /// The name to set for IDbDataParameter.Name - /// The SqlType to set for IDbDataParameter. - /// An IDbDataParameter ready to be added to an IDbCommand. - public IDbDataParameter GenerateParameter(IDbCommand command, string name, SqlType sqlType) + /// The DbCommand to use to create the DbParameter. + /// The name to set for DbParameter.Name + /// The SqlType to set for DbParameter. + /// An DbParameter ready to be added to an DbCommand. + public DbParameter GenerateParameter(DbCommand command, string name, SqlType sqlType) { - IDbDataParameter dbParam = command.CreateParameter(); + var dbParam = command.CreateParameter(); InitializeParameter(dbParam, name, sqlType); - return dbParam; } - public void RemoveUnusedCommandParameters(IDbCommand cmd, SqlString sqlString) + public void RemoveUnusedCommandParameters(DbCommand cmd, SqlString sqlString) { if (!UseNamedPrefixInSql) return; // Applicable only to named parameters @@ -224,25 +224,25 @@ public void RemoveUnusedCommandParameters(IDbCommand cmd, SqlString sqlString) var assignedParameterNames = new HashSet(formatter.AssignedParameterNames); cmd.Parameters - .Cast() + .Cast() .Select(p => p.ParameterName) .Where(p => !assignedParameterNames.Contains(UseNamedPrefixInParameter ? p : FormatNameForSql(p))) .ToList() .ForEach(unusedParameterName => cmd.Parameters.RemoveAt(unusedParameterName)); } - public virtual void ExpandQueryParameters(IDbCommand cmd, SqlString sqlString) + public virtual void ExpandQueryParameters(DbCommand cmd, SqlString sqlString) { if (UseNamedPrefixInSql) return; // named parameters are ok - var expandedParameters = new List(); + var expandedParameters = new List(); foreach (object part in sqlString) { var parameter = part as Parameter; if (parameter != null) { - var originalParameter = (IDbDataParameter)cmd.Parameters[parameter.ParameterPosition.Value]; + var originalParameter = cmd.Parameters[parameter.ParameterPosition.Value]; expandedParameters.Add(CloneParameter(cmd, originalParameter)); } } @@ -262,7 +262,7 @@ public virtual bool SupportsMultipleQueries get { return false; } } - protected virtual IDbDataParameter CloneParameter(IDbCommand cmd, IDbDataParameter originalParameter) + protected virtual DbParameter CloneParameter(DbCommand cmd, DbParameter originalParameter) { var clone = cmd.CreateParameter(); clone.DbType = originalParameter.DbType; @@ -271,7 +271,7 @@ protected virtual IDbDataParameter CloneParameter(IDbCommand cmd, IDbDataParamet return clone; } - public void PrepareCommand(IDbCommand command) + public void PrepareCommand(DbCommand command) { AdjustCommand(command); OnBeforePrepare(command); @@ -283,16 +283,16 @@ public void PrepareCommand(IDbCommand command) } /// - /// Override to make any adjustments to the IDbCommand object. (e.g., Oracle custom OUT parameter) + /// Override to make any adjustments to the DbCommand object. (e.g., Oracle custom OUT parameter) /// Parameters have been bound by this point, so their order can be adjusted too. /// This is analogous to the RegisterResultSetOutParameter() function in Hibernate. /// - protected virtual void OnBeforePrepare(IDbCommand command) + protected virtual void OnBeforePrepare(DbCommand command) { } /// - /// Override to make any adjustments to each IDbCommand object before it added to the batcher. + /// Override to make any adjustments to each DbCommand object before it added to the batcher. /// /// The command. /// @@ -300,13 +300,13 @@ protected virtual void OnBeforePrepare(IDbCommand command) /// is executed before add each single command to the batcher and before . /// If you have to adjust parameters values/type (when the command is full filled) this is a good place where do it. /// - public virtual void AdjustCommand(IDbCommand command) + public virtual void AdjustCommand(DbCommand command) { } - public IDbDataParameter GenerateOutputParameter(IDbCommand command) + public DbParameter GenerateOutputParameter(DbCommand command) { - IDbDataParameter param = GenerateParameter(command, "ReturnValue", SqlTypeFactory.Int32); + var param = GenerateParameter(command, "ReturnValue", SqlTypeFactory.Int32); param.Direction = ParameterDirection.Output; return param; } diff --git a/src/NHibernate/Driver/FirebirdClientDriver.cs b/src/NHibernate/Driver/FirebirdClientDriver.cs index 2f97565a6d4..7f3806ae08c 100644 --- a/src/NHibernate/Driver/FirebirdClientDriver.cs +++ b/src/NHibernate/Driver/FirebirdClientDriver.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.Data; +using System.Data.Common; using System.Linq; using System.Text.RegularExpressions; using NHibernate.Dialect; @@ -51,7 +52,7 @@ public override string NamedPrefix get { return "@"; } } - protected override void InitializeParameter(IDbDataParameter dbParam, string name, SqlType sqlType) + protected override void InitializeParameter(DbParameter dbParam, string name, SqlType sqlType) { var convertedSqlType = sqlType; if (convertedSqlType.DbType == DbType.Currency) @@ -60,7 +61,7 @@ protected override void InitializeParameter(IDbDataParameter dbParam, string nam base.InitializeParameter(dbParam, name, convertedSqlType); } - public override IDbCommand GenerateCommand(CommandType type, SqlString sqlString, SqlType[] parameterTypes) + public override DbCommand GenerateCommand(CommandType type, SqlString sqlString, SqlType[] parameterTypes) { var command = base.GenerateCommand(type, sqlString, parameterTypes); @@ -68,10 +69,10 @@ public override IDbCommand GenerateCommand(CommandType type, SqlString sqlString if (!string.IsNullOrWhiteSpace(expWithParams)) { var candidates = GetCastCandidates(expWithParams); - var castParams = from IDbDataParameter p in command.Parameters + var castParams = from DbParameter p in command.Parameters where candidates.Contains(p.ParameterName) select p; - foreach (IDbDataParameter param in castParams) + foreach (var param in castParams) { TypeCastParam(param, command); } @@ -95,7 +96,7 @@ private HashSet GetCastCandidates(string statement) return new HashSet(candidates); } - private void TypeCastParam(IDbDataParameter param, IDbCommand command) + private void TypeCastParam(DbParameter param, DbCommand command) { var castType = GetFbTypeFromDbType(param.DbType); command.CommandText = command.CommandText.ReplaceWholeWord(param.ParameterName, string.Format("cast({0} as {1})", param.ParameterName, castType)); diff --git a/src/NHibernate/Driver/IDriveConnectionCommandProvider.cs b/src/NHibernate/Driver/IDriveConnectionCommandProvider.cs index 637048f4e5c..db6de57696d 100644 --- a/src/NHibernate/Driver/IDriveConnectionCommandProvider.cs +++ b/src/NHibernate/Driver/IDriveConnectionCommandProvider.cs @@ -1,10 +1,10 @@ -using System.Data; +using System.Data.Common; namespace NHibernate.Driver { public interface IDriveConnectionCommandProvider { - IDbConnection CreateConnection(); - IDbCommand CreateCommand(); + DbConnection CreateConnection(); + DbCommand CreateCommand(); } } \ No newline at end of file diff --git a/src/NHibernate/Driver/IDriver.cs b/src/NHibernate/Driver/IDriver.cs index d860d5d23ce..8fdf6afaf7f 100644 --- a/src/NHibernate/Driver/IDriver.cs +++ b/src/NHibernate/Driver/IDriver.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.Data; +using System.Data.Common; using NHibernate.Engine; using NHibernate.SqlCommand; using NHibernate.SqlTypes; @@ -14,7 +15,7 @@ namespace NHibernate.Driver /// /// The IDriver interface is not intended to be exposed to the application. /// Instead it is used internally by NHibernate to obtain connection objects, command objects, and - /// to generate and prepare IDbCommands. Implementors should provide a + /// to generate and prepare DbCommands. Implementors should provide a /// public default constructor. /// /// @@ -36,24 +37,24 @@ public interface IDriver void Configure(IDictionary settings); /// - /// Creates an uninitialized IDbConnection object for the specific Driver + /// Creates an uninitialized DbConnection object for the specific Driver /// - IDbConnection CreateConnection(); + DbConnection CreateConnection(); /// - /// Does this Driver support having more than 1 open IDataReader with - /// the same IDbConnection. + /// Does this Driver support having more than 1 open DbDataReader with + /// the same DbConnection. /// /// /// /// A value of indicates that an exception would be thrown if NHibernate - /// attempted to have 2 IDataReaders open using the same IDbConnection. NHibernate + /// attempted to have 2 DbDataReaders open using the same DbConnection. NHibernate /// (since this version is a close to straight port of Hibernate) relies on the - /// ability to recursively open 2 IDataReaders. If the Driver does not support it - /// then NHibernate will read the values from the IDataReader into an . + /// ability to recursively open 2 DbDataReaders. If the Driver does not support it + /// then NHibernate will read the values from the DbDataReader into an . /// /// - /// A value of will result in greater performance because an IDataReader can be used + /// A value of will result in greater performance because an DbDataReader can be used /// instead of the . So if the Driver supports it then make sure /// it is set to . /// @@ -61,38 +62,38 @@ public interface IDriver bool SupportsMultipleOpenReaders { get; } /// - /// Generates an IDbCommand from the SqlString according to the requirements of the DataProvider. + /// Generates an DbCommand from the SqlString according to the requirements of the DataProvider. /// /// The of the command to generate. /// The SqlString that contains the SQL. /// The types of the parameters to generate for the command. - /// An IDbCommand with the CommandText and Parameters fully set. - IDbCommand GenerateCommand(CommandType type, SqlString sqlString, SqlType[] parameterTypes); + /// An DbCommand with the CommandText and Parameters fully set. + DbCommand GenerateCommand(CommandType type, SqlString sqlString, SqlType[] parameterTypes); /// - /// Prepare the by calling . + /// Prepare the by calling . /// May be a no-op if the driver does not support preparing commands, or for any other reason. /// /// The command. - void PrepareCommand(IDbCommand command); + void PrepareCommand(DbCommand command); /// - /// Generates an IDbDataParameter for the IDbCommand. It does not add the IDbDataParameter to the IDbCommand's + /// Generates an DbParameter for the DbCommand. It does not add the DbParameter to the DbCommand's /// Parameter collection. /// - /// The IDbCommand to use to create the IDbDataParameter. - /// The name to set for IDbDataParameter.Name - /// The SqlType to set for IDbDataParameter. - /// An IDbDataParameter ready to be added to an IDbCommand. - IDbDataParameter GenerateParameter(IDbCommand command, string name, SqlType sqlType); + /// The DbCommand to use to create the DbParameter. + /// The name to set for DbParameter.Name + /// The SqlType to set for DbParameter. + /// An DbParameter ready to be added to an DbCommand. + DbParameter GenerateParameter(DbCommand command, string name, SqlType sqlType); /// - /// Remove 'extra' parameters from the IDbCommand + /// Remove 'extra' parameters from the DbCommand /// /// /// We sometimes create more parameters than necessary (see NH-2792 & also comments in SqlStringFormatter.ISqlStringVisitor.Parameter) /// - void RemoveUnusedCommandParameters(IDbCommand cmd, SqlString sqlString); + void RemoveUnusedCommandParameters(DbCommand cmd, SqlString sqlString); /// /// Expand the parameters of the cmd to have a single parameter for each parameter in the @@ -103,19 +104,19 @@ public interface IDriver /// for 'select ... from MyTable t where t.Col1 = @p0 and t.Col2 = @p0' we can issue /// 'select ... from MyTable t where t.Col1 = ? and t.Col2 = ?' /// - void ExpandQueryParameters(IDbCommand cmd, SqlString sqlString); + void ExpandQueryParameters(DbCommand cmd, SqlString sqlString); IResultSetsCommand GetResultSetsCommand(ISessionImplementor session); bool SupportsMultipleQueries { get; } /// - /// Make any adjustments to each IDbCommand object before it is added to the batcher. + /// Make any adjustments to each DbCommand object before it is added to the batcher. /// /// The command. /// /// This method should be executed before add each single command to the batcher. /// If you have to adjust parameters values/type (when the command is full filled) this is a good place where do it. /// - void AdjustCommand(IDbCommand command); + void AdjustCommand(DbCommand command); } } \ No newline at end of file diff --git a/src/NHibernate/Driver/IResultSetsCommand.cs b/src/NHibernate/Driver/IResultSetsCommand.cs index 40a348f279a..3b9f4680bf3 100644 --- a/src/NHibernate/Driver/IResultSetsCommand.cs +++ b/src/NHibernate/Driver/IResultSetsCommand.cs @@ -1,4 +1,4 @@ -using System.Data; +using System.Data.Common; using NHibernate.SqlCommand; namespace NHibernate.Driver @@ -8,6 +8,6 @@ public interface IResultSetsCommand void Append(ISqlCommand command); bool HasQueries { get; } SqlString Sql { get; } - IDataReader GetReader(int? commandTimeout); + DbDataReader GetReader(int? commandTimeout); } } \ No newline at end of file diff --git a/src/NHibernate/Driver/MySqlDataDriver.cs b/src/NHibernate/Driver/MySqlDataDriver.cs index 5b04e454945..8d7ab9023f1 100644 --- a/src/NHibernate/Driver/MySqlDataDriver.cs +++ b/src/NHibernate/Driver/MySqlDataDriver.cs @@ -57,8 +57,8 @@ public override string NamedPrefix } /// - /// The MySql.Data driver does NOT support more than 1 open IDataReader - /// with only 1 IDbConnection. + /// The MySql.Data driver does NOT support more than 1 open DbDataReader + /// with only 1 DbConnection. /// /// - it is not supported. public override bool SupportsMultipleOpenReaders diff --git a/src/NHibernate/Driver/NDataReader.cs b/src/NHibernate/Driver/NDataReader.cs index 5c0b7fda420..9f345bce966 100644 --- a/src/NHibernate/Driver/NDataReader.cs +++ b/src/NHibernate/Driver/NDataReader.cs @@ -1,7 +1,7 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Data; +using System.Data;using System.Data.Common; using NHibernate.Util; namespace NHibernate.Driver @@ -12,10 +12,10 @@ namespace NHibernate.Driver /// of Collections. /// /// - /// This is a completely off-line DataReader - the underlying IDataReader that was used to create + /// This is a completely off-line DataReader - the underlying DbDataReader that was used to create /// this has been closed and no connections to the Db exists. /// - public class NDataReader : IDataReader + public class NDataReader : DbDataReader { private NResult[] results; @@ -32,17 +32,17 @@ public class NDataReader : IDataReader private int cachedColIndex = -1; /// - /// Creates a NDataReader from a + /// Creates a NDataReader from a /// - /// The to get the records from the Database. - /// if we are loading the in the middle of reading it. + /// The to get the records from the Database. + /// if we are loading the in the middle of reading it. /// - /// NHibernate attempts to not have to read the contents of an into memory until it absolutely - /// has to. What that means is that it might have processed some records from the and will - /// pick up the midstream so that the underlying can be closed + /// NHibernate attempts to not have to read the contents of an into memory until it absolutely + /// has to. What that means is that it might have processed some records from the and will + /// pick up the midstream so that the underlying can be closed /// so a new one can be opened. /// - public NDataReader(IDataReader reader, bool isMidstream) + public NDataReader(DbDataReader reader, bool isMidstream) { var resultList = new List(2); @@ -68,7 +68,7 @@ public NDataReader(IDataReader reader, bool isMidstream) } catch (Exception e) { - throw new ADOException("There was a problem converting an IDataReader to NDataReader", e); + throw new ADOException("There was a problem converting an DbDataReader to NDataReader", e); } finally { @@ -99,7 +99,7 @@ private object GetValue(string name) return GetCurrentResult().GetValue(currentRowIndex, name); } - #region IDataReader Members + #region DbDataReader Members /// public int RecordsAffected @@ -176,7 +176,7 @@ public DataTable GetSchemaTable() /// /// There are not any unmanaged resources or any disposable managed /// resources that this class is holding onto. It is in here - /// to comply with the interface. + /// to comply with the interface. /// public void Dispose() { @@ -406,7 +406,7 @@ public float GetFloat(int i) /// /// /// - public IDataReader GetData(int i) + public DbDataReader GetData(int i) { throw new NotImplementedException("GetData(int) has not been implemented."); } @@ -493,12 +493,12 @@ private class NResult /// /// Initializes a new instance of the NResult class. /// - /// The IDataReader to populate the Result with. + /// The DbDataReader to populate the Result with. /// - /// if the is already positioned on the record + /// if the is already positioned on the record /// to start reading from. /// - internal NResult(IDataReader reader, bool isMidstream) + internal NResult(DbDataReader reader, bool isMidstream) { schemaTable = reader.GetSchemaTable(); diff --git a/src/NHibernate/Driver/NHybridDataReader.cs b/src/NHibernate/Driver/NHybridDataReader.cs index 3a7be5982ec..94cffd14d09 100644 --- a/src/NHibernate/Driver/NHybridDataReader.cs +++ b/src/NHibernate/Driver/NHybridDataReader.cs @@ -1,48 +1,48 @@ using System; -using System.Data; +using System.Data;using System.Data.Common; namespace NHibernate.Driver { /// - /// An implementation of that will work with either an - /// returned by Execute or with an + /// An implementation of that will work with either an + /// returned by Execute or with an /// whose contents have been read into a . /// /// /// - /// This allows NHibernate to use the underlying for as long as + /// This allows NHibernate to use the underlying for as long as /// possible without the need to read everything into the . /// /// - /// The consumer of the returned from does + /// The consumer of the returned from does /// not need to know the underlying reader and can use it the same even if it switches from an - /// to in the middle of its use. + /// to in the middle of its use. /// /// - public class NHybridDataReader : IDataReader + public class NHybridDataReader : DbDataReader { private IInternalLogger log = LoggerProvider.LoggerFor(typeof(NHybridDataReader)); - private IDataReader _reader; + private DbDataReader _reader; private bool _isMidstream = false; - public IDataReader Target { get { return _reader; } } + public DbDataReader Target { get { return _reader; } } /// /// Initializes a new instance of the class. /// - /// The underlying IDataReader to use. - public NHybridDataReader(IDataReader reader) : this(reader, false) + /// The underlying DbDataReader to use. + public NHybridDataReader(DbDataReader reader) : this(reader, false) { } /// /// Initializes a new instance of the NHybridDataReader class. /// - /// The underlying IDataReader to use. - /// if the contents of the IDataReader should be read into memory right away. - public NHybridDataReader(IDataReader reader, bool inMemory) + /// The underlying DbDataReader to use. + /// if the contents of the DbDataReader should be read into memory right away. + public NHybridDataReader(DbDataReader reader, bool inMemory) { if (inMemory) { @@ -55,7 +55,7 @@ public NHybridDataReader(IDataReader reader, bool inMemory) } /// - /// Reads all of the contents into memory because another + /// Reads all of the contents into memory because another /// needs to be opened. /// /// @@ -67,7 +67,7 @@ public void ReadIntoMemory() { if (log.IsDebugEnabled) { - log.Debug("Moving IDataReader into an NDataReader. It was converted in midstream " + _isMidstream.ToString()); + log.Debug("Moving DbDataReader into an NDataReader. It was converted in midstream " + _isMidstream.ToString()); } _reader = new NDataReader(_reader, _isMidstream); } @@ -76,13 +76,13 @@ public void ReadIntoMemory() /// /// Gets if the object is in the middle of reading a Result. /// - /// if NextResult and Read have been called on the . + /// if NextResult and Read have been called on the . public bool IsMidstream { get { return _isMidstream; } } - #region IDataReader Members + #region DbDataReader Members /// public int RecordsAffected @@ -388,7 +388,7 @@ public float GetFloat(int i) /// /// /// - public IDataReader GetData(int i) + public DbDataReader GetData(int i) { return _reader.GetData(i); } diff --git a/src/NHibernate/Driver/NpgsqlDriver.cs b/src/NHibernate/Driver/NpgsqlDriver.cs index e324f13304b..d9afe0822cc 100644 --- a/src/NHibernate/Driver/NpgsqlDriver.cs +++ b/src/NHibernate/Driver/NpgsqlDriver.cs @@ -1,4 +1,5 @@ using System.Data; +using System.Data.Common; namespace NHibernate.Driver { @@ -75,7 +76,7 @@ public override bool SupportsMultipleQueries get { return true; } } - protected override void InitializeParameter(IDbDataParameter dbParam, string name, SqlTypes.SqlType sqlType) + protected override void InitializeParameter(DbParameter dbParam, string name, SqlTypes.SqlType sqlType) { base.InitializeParameter(dbParam, name, sqlType); diff --git a/src/NHibernate/Driver/OdbcDriver.cs b/src/NHibernate/Driver/OdbcDriver.cs index 181fdb41e1a..6101d321a5e 100644 --- a/src/NHibernate/Driver/OdbcDriver.cs +++ b/src/NHibernate/Driver/OdbcDriver.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Data; +using System.Data.Common; using System.Data.Odbc; using NHibernate.SqlTypes; using NHibernate.Util; @@ -33,12 +34,12 @@ public override void Configure(IDictionary settings) } } - public override IDbConnection CreateConnection() + public override DbConnection CreateConnection() { return new OdbcConnection(); } - public override IDbCommand CreateCommand() + public override DbCommand CreateCommand() { return new OdbcCommand(); } @@ -58,10 +59,10 @@ public override string NamedPrefix get { return String.Empty; } } - private void SetVariableLengthParameterSize(IDbDataParameter dbParam, SqlType sqlType) + private void SetVariableLengthParameterSize(DbParameter dbParam, SqlType sqlType) { if (Equals(sqlType, SqlTypeFactory.DateTime) && _dbDateTimeScale != null) - dbParam.Scale = _dbDateTimeScale.Value; + ((IDbDataParameter)dbParam).Scale = _dbDateTimeScale.Value; // Override the defaults using data from SqlType. if (sqlType.LengthDefined) @@ -71,12 +72,12 @@ private void SetVariableLengthParameterSize(IDbDataParameter dbParam, SqlType sq if (sqlType.PrecisionDefined) { - dbParam.Precision = sqlType.Precision; - dbParam.Scale = sqlType.Scale; + ((IDbDataParameter)dbParam).Precision = sqlType.Precision; + ((IDbDataParameter)dbParam).Scale = sqlType.Scale; } } - protected override void InitializeParameter(IDbDataParameter dbParam, string name, SqlType sqlType) + protected override void InitializeParameter(DbParameter dbParam, string name, SqlType sqlType) { base.InitializeParameter(dbParam, name, sqlType); SetVariableLengthParameterSize(dbParam, sqlType); diff --git a/src/NHibernate/Driver/OleDbDriver.cs b/src/NHibernate/Driver/OleDbDriver.cs index 130699667a5..cb0d00c63c8 100644 --- a/src/NHibernate/Driver/OleDbDriver.cs +++ b/src/NHibernate/Driver/OleDbDriver.cs @@ -1,5 +1,5 @@ using System; -using System.Data; +using System.Data.Common; using System.Data.OleDb; namespace NHibernate.Driver @@ -16,12 +16,12 @@ public OleDbDriver() { } - public override IDbConnection CreateConnection() + public override DbConnection CreateConnection() { return new OleDbConnection(); } - public override IDbCommand CreateCommand() + public override DbCommand CreateCommand() { return new OleDbCommand(); } diff --git a/src/NHibernate/Driver/OracleClientDriver.cs b/src/NHibernate/Driver/OracleClientDriver.cs index f93b848b1eb..df302b3c1d8 100644 --- a/src/NHibernate/Driver/OracleClientDriver.cs +++ b/src/NHibernate/Driver/OracleClientDriver.cs @@ -1,4 +1,5 @@ using System.Data; +using System.Data.Common; using NHibernate.Engine.Query; using NHibernate.SqlTypes; @@ -33,7 +34,7 @@ public override string NamedPrefix get { return ":"; } } - protected override void InitializeParameter(IDbDataParameter dbParam, string name, SqlType sqlType) + protected override void InitializeParameter(DbParameter dbParam, string name, SqlType sqlType) { if (sqlType.DbType == DbType.Guid) { @@ -45,7 +46,7 @@ protected override void InitializeParameter(IDbDataParameter dbParam, string nam } } - protected override void OnBeforePrepare(IDbCommand command) + protected override void OnBeforePrepare(DbCommand command) { base.OnBeforePrepare(command); diff --git a/src/NHibernate/Driver/OracleDataClientDriver.cs b/src/NHibernate/Driver/OracleDataClientDriver.cs index 2e0524501ac..465f9da81a5 100644 --- a/src/NHibernate/Driver/OracleDataClientDriver.cs +++ b/src/NHibernate/Driver/OracleDataClientDriver.cs @@ -1,5 +1,6 @@ using System; using System.Data; +using System.Data.Common; using System.Reflection; using NHibernate.AdoNet; using NHibernate.Engine.Query; @@ -73,7 +74,7 @@ public override string NamedPrefix /// This adds logic to ensure that a DbType.Boolean parameter is not created since /// ODP.NET doesn't support it. /// - protected override void InitializeParameter(IDbDataParameter dbParam, string name, SqlType sqlType) + protected override void InitializeParameter(DbParameter dbParam, string name, SqlType sqlType) { // if the parameter coming in contains a boolean then we need to convert it // to another type since ODP.NET doesn't support DbType.Boolean @@ -94,13 +95,13 @@ protected override void InitializeParameter(IDbDataParameter dbParam, string nam } } - private void InitializeParameter(IDbDataParameter dbParam, string name, object sqlType) + private void InitializeParameter(DbParameter dbParam, string name, object sqlType) { dbParam.ParameterName = FormatNameForParameter(name); oracleDbType.SetValue(dbParam, sqlType, null); } - protected override void OnBeforePrepare(IDbCommand command) + protected override void OnBeforePrepare(DbCommand command) { base.OnBeforePrepare(command); @@ -117,7 +118,7 @@ protected override void OnBeforePrepare(IDbCommand command) command.CommandText = detail.FunctionName; oracleCommandBindByName.SetValue(command, false, null); - IDbDataParameter outCursor = command.CreateParameter(); + var outCursor = command.CreateParameter(); oracleDbType.SetValue(outCursor, oracleDbTypeRefCursor, null); outCursor.Direction = detail.HasReturn ? ParameterDirection.ReturnValue : ParameterDirection.Output; diff --git a/src/NHibernate/Driver/OracleLiteDataClientDriver.cs b/src/NHibernate/Driver/OracleLiteDataClientDriver.cs index af7218bd996..98497360c28 100644 --- a/src/NHibernate/Driver/OracleLiteDataClientDriver.cs +++ b/src/NHibernate/Driver/OracleLiteDataClientDriver.cs @@ -1,4 +1,5 @@ using System.Data; +using System.Data.Common; using NHibernate.AdoNet; using NHibernate.SqlTypes; @@ -42,7 +43,7 @@ public override string NamedPrefix /// This adds logic to ensure that a DbType.Boolean parameter is not created since /// ODP.NET doesn't support it. /// - protected override void InitializeParameter(IDbDataParameter dbParam, string name, SqlType sqlType) + protected override void InitializeParameter(DbParameter dbParam, string name, SqlType sqlType) { // if the parameter coming in contains a boolean then we need to convert it // to another type since ODP.NET doesn't support DbType.Boolean diff --git a/src/NHibernate/Driver/OracleManagedDataClientDriver.cs b/src/NHibernate/Driver/OracleManagedDataClientDriver.cs index 2f45e1ba401..86cac7dffac 100644 --- a/src/NHibernate/Driver/OracleManagedDataClientDriver.cs +++ b/src/NHibernate/Driver/OracleManagedDataClientDriver.cs @@ -1,5 +1,6 @@ using System; using System.Data; +using System.Data.Common; using System.Reflection; using NHibernate.AdoNet; using NHibernate.Engine.Query; @@ -70,7 +71,7 @@ public override bool UseNamedPrefixInSql /// This adds logic to ensure that a DbType.Boolean parameter is not created since /// ODP.NET doesn't support it. /// - protected override void InitializeParameter(IDbDataParameter dbParam, string name, SqlType sqlType) + protected override void InitializeParameter(DbParameter dbParam, string name, SqlType sqlType) { // if the parameter coming in contains a boolean then we need to convert it // to another type since ODP.NET doesn't support DbType.Boolean @@ -94,13 +95,13 @@ protected override void InitializeParameter(IDbDataParameter dbParam, string nam } } - private void InitializeParameter(IDbDataParameter dbParam, string name, object sqlType) + private void InitializeParameter(DbParameter dbParam, string name, object sqlType) { dbParam.ParameterName = FormatNameForParameter(name); oracleDbType.SetValue(dbParam, sqlType, null); } - protected override void OnBeforePrepare(IDbCommand command) + protected override void OnBeforePrepare(DbCommand command) { base.OnBeforePrepare(command); diff --git a/src/NHibernate/Driver/ReflectionBasedDriver.cs b/src/NHibernate/Driver/ReflectionBasedDriver.cs index c5809b1ef61..dfe487004ac 100644 --- a/src/NHibernate/Driver/ReflectionBasedDriver.cs +++ b/src/NHibernate/Driver/ReflectionBasedDriver.cs @@ -1,4 +1,3 @@ -using System.Data; using System.Data.Common; using NHibernate.Util; @@ -6,7 +5,7 @@ namespace NHibernate.Driver { public abstract class ReflectionBasedDriver : DriverBase { - protected const string ReflectionTypedProviderExceptionMessageTemplate = "The IDbCommand and IDbConnection implementation in the assembly {0} could not be found. " + protected const string ReflectionTypedProviderExceptionMessageTemplate = "The DbCommand and DbConnection implementation in the assembly {0} could not be found. " + "Ensure that the assembly {0} is located in the application directory or in the Global " + "Assembly Cache. If the assembly is in the GAC, use element in the " + "application configuration file to specify the full name of the assembly."; @@ -55,12 +54,12 @@ protected ReflectionBasedDriver(string providerInvariantName, string driverAssem } } - public override IDbConnection CreateConnection() + public override DbConnection CreateConnection() { return connectionCommandProvider.CreateConnection(); } - public override IDbCommand CreateCommand() + public override DbCommand CreateCommand() { return connectionCommandProvider.CreateCommand(); } diff --git a/src/NHibernate/Driver/ReflectionDriveConnectionCommandProvider.cs b/src/NHibernate/Driver/ReflectionDriveConnectionCommandProvider.cs index 2954a1d4897..1e77e779e23 100644 --- a/src/NHibernate/Driver/ReflectionDriveConnectionCommandProvider.cs +++ b/src/NHibernate/Driver/ReflectionDriveConnectionCommandProvider.cs @@ -1,5 +1,5 @@ using System; -using System.Data; +using System.Data.Common; using Environment = NHibernate.Cfg.Environment; namespace NHibernate.Driver @@ -25,14 +25,14 @@ public ReflectionDriveConnectionCommandProvider(System.Type connectionType, Syst #region IDriveConnectionCommandProvider Members - public IDbConnection CreateConnection() + public DbConnection CreateConnection() { - return (IDbConnection) Environment.BytecodeProvider.ObjectsFactory.CreateInstance(connectionType); + return (DbConnection) Environment.BytecodeProvider.ObjectsFactory.CreateInstance(connectionType); } - public IDbCommand CreateCommand() + public DbCommand CreateCommand() { - return (IDbCommand) Environment.BytecodeProvider.ObjectsFactory.CreateInstance(commandType); + return (DbCommand) Environment.BytecodeProvider.ObjectsFactory.CreateInstance(commandType); } #endregion diff --git a/src/NHibernate/Driver/SQLite20Driver.cs b/src/NHibernate/Driver/SQLite20Driver.cs index ed32b2c891f..00cdf8b8be4 100644 --- a/src/NHibernate/Driver/SQLite20Driver.cs +++ b/src/NHibernate/Driver/SQLite20Driver.cs @@ -35,9 +35,9 @@ public SQLite20Driver() : base( { } - public override IDbConnection CreateConnection() + public override DbConnection CreateConnection() { - DbConnection connection = (DbConnection)base.CreateConnection(); + var connection = base.CreateConnection(); connection.StateChange += Connection_StateChange; return connection; } @@ -47,8 +47,8 @@ private static void Connection_StateChange(object sender, StateChangeEventArgs e if ((e.OriginalState == ConnectionState.Broken || e.OriginalState == ConnectionState.Closed || e.OriginalState == ConnectionState.Connecting) && e.CurrentState == ConnectionState.Open) { - DbConnection connection = (DbConnection)sender; - using (DbCommand command = connection.CreateCommand()) + var connection = (DbConnection)sender; + using (var command = connection.CreateCommand()) { // Activated foreign keys if supported by SQLite. Unknown pragmas are ignored. command.CommandText = "PRAGMA foreign_keys = ON"; diff --git a/src/NHibernate/Driver/Sql2008ClientDriver.cs b/src/NHibernate/Driver/Sql2008ClientDriver.cs index ed7254d45d7..d387c90d99f 100644 --- a/src/NHibernate/Driver/Sql2008ClientDriver.cs +++ b/src/NHibernate/Driver/Sql2008ClientDriver.cs @@ -1,5 +1,6 @@ using System; using System.Data; +using System.Data.Common; using System.Data.SqlClient; using System.Linq; @@ -7,7 +8,7 @@ namespace NHibernate.Driver { public class Sql2008ClientDriver : SqlClientDriver { - protected override void InitializeParameter(IDbDataParameter dbParam, string name, SqlTypes.SqlType sqlType) + protected override void InitializeParameter(DbParameter dbParam, string name, SqlTypes.SqlType sqlType) { base.InitializeParameter(dbParam, name, sqlType); if (sqlType.DbType == DbType.Time) @@ -16,7 +17,7 @@ protected override void InitializeParameter(IDbDataParameter dbParam, string nam } } - public override void AdjustCommand(IDbCommand command) + public override void AdjustCommand(DbCommand command) { foreach (var parameter in command.Parameters.Cast().Where(x => x.SqlDbType == SqlDbType.Time && (x.Value is DateTime))) { diff --git a/src/NHibernate/Driver/SqlClientDriver.cs b/src/NHibernate/Driver/SqlClientDriver.cs index 4c748ff38a9..fadec4ea5ab 100644 --- a/src/NHibernate/Driver/SqlClientDriver.cs +++ b/src/NHibernate/Driver/SqlClientDriver.cs @@ -1,4 +1,5 @@ using System.Data; +using System.Data.Common; using System.Data.SqlClient; using NHibernate.AdoNet; using NHibernate.Dialect; @@ -26,21 +27,21 @@ public class SqlClientDriver : DriverBase, IEmbeddedBatcherFactoryProvider public const byte MaxDateTimeOffset = 10; /// - /// Creates an uninitialized object for + /// Creates an uninitialized object for /// the SqlClientDriver. /// /// An unitialized object. - public override IDbConnection CreateConnection() + public override DbConnection CreateConnection() { return new SqlConnection(); } /// - /// Creates an uninitialized object for + /// Creates an uninitialized object for /// the SqlClientDriver. /// /// An unitialized object. - public override IDbCommand CreateCommand() + public override DbCommand CreateCommand() { return new System.Data.SqlClient.SqlCommand(); } @@ -79,12 +80,12 @@ public override string NamedPrefix } /// - /// The SqlClient driver does NOT support more than 1 open IDataReader - /// with only 1 IDbConnection. + /// The SqlClient driver does NOT support more than 1 open DbDataReader + /// with only 1 DbConnection. /// /// - it is not supported. /// - /// MS SQL Server 2000 (and 7) throws an exception when multiple IDataReaders are + /// MS SQL Server 2000 (and 7) throws an exception when multiple DbDataReaders are /// attempted to be opened. When SQL Server 2005 comes out a new driver will be /// created for it because SQL Server 2005 is supposed to support it. /// @@ -93,14 +94,14 @@ public override bool SupportsMultipleOpenReaders get { return false; } } - protected override void InitializeParameter(IDbDataParameter dbParam, string name, SqlType sqlType) + protected override void InitializeParameter(DbParameter dbParam, string name, SqlType sqlType) { base.InitializeParameter(dbParam, name, sqlType); SetVariableLengthParameterSize(dbParam, sqlType); } // Used from SqlServerCeDriver as well - public static void SetVariableLengthParameterSize(IDbDataParameter dbParam, SqlType sqlType) + public static void SetVariableLengthParameterSize(DbParameter dbParam, SqlType sqlType) { SetDefaultParameterSize(dbParam, sqlType); @@ -113,12 +114,12 @@ public static void SetVariableLengthParameterSize(IDbDataParameter dbParam, SqlT if (sqlType.PrecisionDefined) { - dbParam.Precision = sqlType.Precision; - dbParam.Scale = sqlType.Scale; + ((IDbDataParameter) dbParam).Precision = sqlType.Precision; + ((IDbDataParameter) dbParam).Scale = sqlType.Scale; } } - protected static void SetDefaultParameterSize(IDbDataParameter dbParam, SqlType sqlType) + protected static void SetDefaultParameterSize(DbParameter dbParam, SqlType sqlType) { switch (dbParam.DbType) { @@ -130,8 +131,8 @@ protected static void SetDefaultParameterSize(IDbDataParameter dbParam, SqlType dbParam.Size = IsBlob(dbParam, sqlType) ? MaxSizeForBlob : MaxSizeForLengthLimitedBinary; break; case DbType.Decimal: - dbParam.Precision = MaxPrecision; - dbParam.Scale = MaxScale; + ((IDbDataParameter) dbParam).Precision = MaxPrecision; + ((IDbDataParameter) dbParam).Scale = MaxScale; break; case DbType.String: case DbType.StringFixedLength: @@ -155,7 +156,7 @@ protected static void SetDefaultParameterSize(IDbDataParameter dbParam, SqlType /// The parameter /// The of the parameter /// True, if the parameter should be interpreted as a Clob, otherwise False - protected static bool IsAnsiText(IDbDataParameter dbParam, SqlType sqlType) + protected static bool IsAnsiText(DbParameter dbParam, SqlType sqlType) { return ((DbType.AnsiString == dbParam.DbType || DbType.AnsiStringFixedLength == dbParam.DbType) && sqlType.LengthDefined && (sqlType.Length > MaxSizeForLengthLimitedAnsiString)); } @@ -166,7 +167,7 @@ protected static bool IsAnsiText(IDbDataParameter dbParam, SqlType sqlType) /// The parameter /// The of the parameter /// True, if the parameter should be interpreted as a Clob, otherwise False - protected static bool IsText(IDbDataParameter dbParam, SqlType sqlType) + protected static bool IsText(DbParameter dbParam, SqlType sqlType) { return (sqlType is StringClobSqlType) || ((DbType.String == dbParam.DbType || DbType.StringFixedLength == dbParam.DbType) && sqlType.LengthDefined && (sqlType.Length > MaxSizeForLengthLimitedString)); } @@ -177,7 +178,7 @@ protected static bool IsText(IDbDataParameter dbParam, SqlType sqlType) /// The parameter /// The of the parameter /// True, if the parameter should be interpreted as a Blob, otherwise False - protected static bool IsBlob(IDbDataParameter dbParam, SqlType sqlType) + protected static bool IsBlob(DbParameter dbParam, SqlType sqlType) { return (sqlType is BinaryBlobSqlType) || ((DbType.Binary == dbParam.DbType) && sqlType.LengthDefined && (sqlType.Length > MaxSizeForLengthLimitedBinary)); } diff --git a/src/NHibernate/Driver/SqlServerCeDriver.cs b/src/NHibernate/Driver/SqlServerCeDriver.cs index f89ac6b1080..bc06f7f9aae 100644 --- a/src/NHibernate/Driver/SqlServerCeDriver.cs +++ b/src/NHibernate/Driver/SqlServerCeDriver.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Data; +using System.Data.Common; using System.Reflection; using NHibernate.SqlTypes; using NHibernate.Util; @@ -32,9 +33,9 @@ public override void Configure(IDictionary settings) base.Configure(settings); prepareSql = PropertiesHelper.GetBoolean(Environment.PrepareSql, settings, false); - using (IDbCommand cmd = CreateCommand()) + using (var cmd = CreateCommand()) { - IDbDataParameter dbParam = cmd.CreateParameter(); + var dbParam = cmd.CreateParameter(); dbParamSqlDbTypeProperty = dbParam.GetType().GetProperty("SqlDbType"); } } @@ -73,8 +74,8 @@ public override string NamedPrefix } /// - /// The SqlClient driver does NOT support more than 1 open IDataReader - /// with only 1 IDbConnection. + /// The SqlClient driver does NOT support more than 1 open DbDataReader + /// with only 1 DbConnection. /// /// - it is not supported. /// @@ -87,7 +88,7 @@ public override bool SupportsMultipleOpenReaders get { return false; } } - protected override void SetCommandTimeout(IDbCommand cmd) + protected override void SetCommandTimeout(DbCommand cmd) { } @@ -96,7 +97,7 @@ public override IResultSetsCommand GetResultSetsCommand(Engine.ISessionImplement return new BasicResultSetsCommand(session); } - protected override void InitializeParameter(IDbDataParameter dbParam, string name, SqlType sqlType) + protected override void InitializeParameter(DbParameter dbParam, string name, SqlType sqlType) { base.InitializeParameter(dbParam, name, AdjustSqlType(sqlType)); @@ -124,7 +125,7 @@ private static SqlType AdjustSqlType(SqlType sqlType) } } - private void AdjustDbParamTypeForLargeObjects(IDbDataParameter dbParam, SqlType sqlType) + private void AdjustDbParamTypeForLargeObjects(DbParameter dbParam, SqlType sqlType) { if (sqlType is BinaryBlobSqlType) { diff --git a/src/NHibernate/Driver/SqlStringFormatter.cs b/src/NHibernate/Driver/SqlStringFormatter.cs index 5ce1fe718c5..c16889b22d0 100644 --- a/src/NHibernate/Driver/SqlStringFormatter.cs +++ b/src/NHibernate/Driver/SqlStringFormatter.cs @@ -54,10 +54,10 @@ void ISqlStringVisitor.Parameter(Parameter parameter) return; } - // NH: even if using SqlType[] the final commad may have X parameters, with this line we will use Y parameters in the IDbCommand + // NH: even if using SqlType[] the final commad may have X parameters, with this line we will use Y parameters in the DbCommand // for example the ParameterCollection may contains two parameters called @p0 and @p1 but the command contains just @p0. // In this way the same parameter can be used in different places in the query without create a problem to the dear SQL-server (see NH1981) - // TODO: find a way to have exactly the same amount of parameters between the final IDbCommand and its IDataParameterCollection + // TODO: find a way to have exactly the same amount of parameters between the final DbCommand and its DbParameterCollection // A candidateplace is making DriverBase.SetCommandParameters a little bit more intelligent... perhaps SqlString aware (see also DriverBase.SetCommandText, DriverBase.GenerateCommand) string name = formatter.GetParameterName(parameter.ParameterPosition ?? parameterIndex); diff --git a/src/NHibernate/Engine/IBatcher.cs b/src/NHibernate/Engine/IBatcher.cs index 42158bf29b2..4abb914fabe 100644 --- a/src/NHibernate/Engine/IBatcher.cs +++ b/src/NHibernate/Engine/IBatcher.cs @@ -1,5 +1,6 @@ using System; using System.Data; +using System.Data.Common; using NHibernate.AdoNet; using NHibernate.SqlCommand; using NHibernate.SqlTypes; @@ -7,14 +8,14 @@ namespace NHibernate.Engine { /// - /// Manages s and s + /// Manages s and s /// for an . /// /// ///

/// Abstracts ADO.NET batching to maintain the illusion that a single logical batch /// exists for the whole session, even when batching is disabled. - /// Provides transparent IDbCommand caching. + /// Provides transparent DbCommand caching. ///

///

/// This will be useful once ADO.NET gets support for batching. Until that point @@ -25,14 +26,14 @@ namespace NHibernate.Engine public interface IBatcher : IDisposable { ///

- /// Get an for using in loading / querying. + /// Get an for using in loading / querying. /// - /// The to convert to an . + /// The to convert to an . /// The of the command. /// The SqlTypes of parameters /// in . /// - /// An that is ready to be executed. + /// An that is ready to be executed. /// /// /// @@ -40,53 +41,53 @@ public interface IBatcher : IDisposable /// released when the session is closed or disconnected. /// /// - /// This does NOT add anything to the batch - it only creates the IDbCommand and + /// This does NOT add anything to the batch - it only creates the DbCommand and /// does NOT cause the batch to execute... /// /// - IDbCommand PrepareQueryCommand(CommandType commandType, SqlString sql, SqlType[] parameterTypes); + DbCommand PrepareQueryCommand(CommandType commandType, SqlString sql, SqlType[] parameterTypes); /// - /// Get a non-batchable an to use for inserting / deleting / updating. + /// Get a non-batchable an to use for inserting / deleting / updating. /// Must be explicitly released by CloseCommand() /// - /// The to convert to an . + /// The to convert to an . /// The of the command. /// The SqlTypes of parameters /// in . /// - /// An that is ready to have the parameter values set + /// An that is ready to have the parameter values set /// and then executed. /// - IDbCommand PrepareCommand(CommandType commandType, SqlString sql, SqlType[] parameterTypes); + DbCommand PrepareCommand(CommandType commandType, SqlString sql, SqlType[] parameterTypes); /// - /// Close a opened using PrepareCommand() + /// Close a opened using PrepareCommand() /// - /// The to ensure is closed. - /// The to ensure is closed. - void CloseCommand(IDbCommand cmd, IDataReader reader); + /// The to ensure is closed. + /// The to ensure is closed. + void CloseCommand(DbCommand cmd, DbDataReader reader); /// - /// Close a opened using + /// Close a opened using /// - /// The to ensure is closed. - void CloseReader(IDataReader reader); + /// The to ensure is closed. + void CloseReader(DbDataReader reader); /// - /// Get a batchable to use for inserting / deleting / updating + /// Get a batchable to use for inserting / deleting / updating /// (might be called many times before a single call to ExecuteBatch() /// /// /// After setting parameters, call AddToBatch() - do not execute the statement /// explicitly. /// - /// The to convert to an . + /// The to convert to an . /// The of the command. /// The SqlTypes of parameters /// in . /// - IDbCommand PrepareBatchCommand(CommandType commandType, SqlString sql, SqlType[] parameterTypes); + DbCommand PrepareBatchCommand(CommandType commandType, SqlString sql, SqlType[] parameterTypes); /// /// Add an insert / delete / update to the current batch (might be called multiple times @@ -110,26 +111,26 @@ public interface IBatcher : IDisposable void CloseCommands(); /// - /// Gets an by calling ExecuteReader on the . + /// Gets an by calling ExecuteReader on the . /// - /// The to execute to get the . - /// The from the . + /// The to execute to get the . + /// The from the . /// /// The Batcher is responsible for ensuring that all of the Drivers rules for how many open - /// s it can have are followed. + /// s it can have are followed. /// - IDataReader ExecuteReader(IDbCommand cmd); + DbDataReader ExecuteReader(DbCommand cmd); /// - /// Executes the . + /// Executes the . /// - /// The to execute. + /// The to execute. /// The number of rows affected. /// /// The Batcher is responsible for ensuring that all of the Drivers rules for how many open - /// s it can have are followed. + /// s it can have are followed. /// - int ExecuteNonQuery(IDbCommand cmd); + int ExecuteNonQuery(DbCommand cmd); /// /// Must be called when an exception occurs. @@ -144,7 +145,7 @@ public interface IBatcher : IDisposable /// /// Gets the value indicating whether there are any open resources - /// managed by this batcher (IDbCommands or IDataReaders). + /// managed by this batcher (DbCommands or DbDataReaders). /// bool HasOpenResources { get; } diff --git a/src/NHibernate/Engine/ISessionFactoryImplementor.cs b/src/NHibernate/Engine/ISessionFactoryImplementor.cs index 232405a05aa..2bc91bf1329 100644 --- a/src/NHibernate/Engine/ISessionFactoryImplementor.cs +++ b/src/NHibernate/Engine/ISessionFactoryImplementor.cs @@ -1,5 +1,5 @@ using System.Collections.Generic; -using System.Data; +using System.Data.Common; using NHibernate.Cache; using NHibernate.Cfg; using NHibernate.Connection; @@ -147,7 +147,7 @@ public interface ISessionFactoryImplementor : IMapping, ISessionFactory /// /// The release mode for managed jdbc connections. /// An appropriate session. - ISession OpenSession(IDbConnection connection, bool flushBeforeCompletionEnabled, bool autoCloseSessionEnabled, + ISession OpenSession(DbConnection connection, bool flushBeforeCompletionEnabled, bool autoCloseSessionEnabled, ConnectionReleaseMode connectionReleaseMode); /// diff --git a/src/NHibernate/Engine/ISessionImplementor.cs b/src/NHibernate/Engine/ISessionImplementor.cs index 8d64edf61e6..bc31bf37ff7 100644 --- a/src/NHibernate/Engine/ISessionImplementor.cs +++ b/src/NHibernate/Engine/ISessionImplementor.cs @@ -1,7 +1,7 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Data; +using System.Data.Common; using NHibernate.AdoNet; using NHibernate.Cache; using NHibernate.Collection; @@ -293,7 +293,7 @@ public interface ISessionImplementor /// The guessed entity name for an entity not in an association string GuessEntityName(object entity); - IDbConnection Connection { get; } + DbConnection Connection { get; } IQuery GetNamedQuery(string queryName); diff --git a/src/NHibernate/Engine/Loading/CollectionLoadContext.cs b/src/NHibernate/Engine/Loading/CollectionLoadContext.cs index 78cafbb89e6..8d4738311e4 100644 --- a/src/NHibernate/Engine/Loading/CollectionLoadContext.cs +++ b/src/NHibernate/Engine/Loading/CollectionLoadContext.cs @@ -1,6 +1,6 @@ using System.Collections; using System.Collections.Generic; -using System.Data; +using System.Data.Common; using System.Diagnostics; using NHibernate.Cache; @@ -12,18 +12,18 @@ namespace NHibernate.Engine.Loading { /// - /// Represents state associated with the processing of a given + /// Represents state associated with the processing of a given /// in regards to loading collections. /// /// - /// Another implementation option to consider is to not expose ResultSets + /// Another implementation option to consider is to not expose ResultSets /// directly (in the JDBC redesign) but to always "wrap" them and apply a [series of] context[s] to that wrapper. /// public class CollectionLoadContext { private static readonly IInternalLogger log = LoggerProvider.LoggerFor(typeof(CollectionLoadContext)); private readonly LoadContexts loadContexts; - private readonly IDataReader resultSet; + private readonly DbDataReader resultSet; private readonly ISet localLoadingCollectionKeys = new HashSet(); /// @@ -31,7 +31,7 @@ public class CollectionLoadContext /// /// Callback to other collection load contexts. /// The result set this is "wrapping". - public CollectionLoadContext(LoadContexts loadContexts, IDataReader resultSet) + public CollectionLoadContext(LoadContexts loadContexts, DbDataReader resultSet) { this.loadContexts = loadContexts; this.resultSet = resultSet; @@ -42,7 +42,7 @@ public LoadContexts LoadContext get { return loadContexts; } } - public IDataReader ResultSet + public DbDataReader ResultSet { get { return resultSet; } } diff --git a/src/NHibernate/Engine/Loading/LoadContexts.cs b/src/NHibernate/Engine/Loading/LoadContexts.cs index f7a98131448..da771380eeb 100644 --- a/src/NHibernate/Engine/Loading/LoadContexts.cs +++ b/src/NHibernate/Engine/Loading/LoadContexts.cs @@ -1,7 +1,7 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Data; +using System.Data.Common; using NHibernate.Collection; using NHibernate.Impl; @@ -11,13 +11,13 @@ namespace NHibernate.Engine.Loading { /// - /// Maps to specific contextual data - /// related to processing that . + /// Maps to specific contextual data + /// related to processing that . /// /// /// Implementation note: internally an is used to maintain /// the mappings; was chosen because I'd rather not be - /// dependent upon potentially bad and + /// dependent upon potentially bad and /// implementations. /// Considering the JDBC-redesign work, would further like this contextual info /// not mapped separately, but available based on the result set being processed. @@ -67,7 +67,7 @@ internal IDictionary LoadingCollectionXRe /// This should be called when we are done with processing said result set, /// ideally as the result set is being closed. /// - public virtual void Cleanup(IDataReader resultSet) + public virtual void Cleanup(DbDataReader resultSet) { if (collectionLoadContexts != null) { @@ -121,7 +121,7 @@ public bool HasRegisteredLoadingCollectionEntries /// /// The result set for which to retrieve the context. /// The processing context. - public CollectionLoadContext GetCollectionLoadContext(IDataReader resultSet) + public CollectionLoadContext GetCollectionLoadContext(DbDataReader resultSet) { CollectionLoadContext context = null; if (collectionLoadContexts == null) diff --git a/src/NHibernate/Engine/Loading/LoadingCollectionEntry.cs b/src/NHibernate/Engine/Loading/LoadingCollectionEntry.cs index 8edb201edf9..992abf1ae5e 100644 --- a/src/NHibernate/Engine/Loading/LoadingCollectionEntry.cs +++ b/src/NHibernate/Engine/Loading/LoadingCollectionEntry.cs @@ -1,5 +1,5 @@ using System; -using System.Data; +using System.Data.Common; using NHibernate.Collection; using NHibernate.Impl; using NHibernate.Persister.Collection; @@ -11,12 +11,12 @@ namespace NHibernate.Engine.Loading /// public class LoadingCollectionEntry { - private readonly IDataReader resultSet; + private readonly DbDataReader resultSet; private readonly ICollectionPersister persister; private readonly object key; private readonly IPersistentCollection collection; - public LoadingCollectionEntry(IDataReader resultSet, ICollectionPersister persister, object key, IPersistentCollection collection) + public LoadingCollectionEntry(DbDataReader resultSet, ICollectionPersister persister, object key, IPersistentCollection collection) { this.resultSet = resultSet; this.persister = persister; @@ -24,7 +24,7 @@ public LoadingCollectionEntry(IDataReader resultSet, ICollectionPersister persis this.collection = collection; } - public IDataReader ResultSet + public DbDataReader ResultSet { get { return resultSet; } } diff --git a/src/NHibernate/Engine/Query/NativeSQLQueryPlan.cs b/src/NHibernate/Engine/Query/NativeSQLQueryPlan.cs index 93f3829c802..87d0c8ed1b4 100644 --- a/src/NHibernate/Engine/Query/NativeSQLQueryPlan.cs +++ b/src/NHibernate/Engine/Query/NativeSQLQueryPlan.cs @@ -2,6 +2,7 @@ using System.Collections; using System.Collections.Generic; using System.Data; +using System.Data.Common; using System.Linq; using NHibernate.Action; using NHibernate.Engine.Query.Sql; @@ -78,7 +79,7 @@ public int PerformExecuteUpdate(QueryParameters queryParameters, ISessionImpleme var sqlParametersList = sql.GetParameters().ToList(); SqlType[] sqlTypes = parametersSpecifications.GetQueryParameterTypes(sqlParametersList, session.Factory); - IDbCommand ps = session.Batcher.PrepareCommand(CommandType.Text, sql, sqlTypes); + var ps = session.Batcher.PrepareCommand(CommandType.Text, sql, sqlTypes); try { diff --git a/src/NHibernate/Engine/RowSelection.cs b/src/NHibernate/Engine/RowSelection.cs index 334965d064d..2602a83505b 100644 --- a/src/NHibernate/Engine/RowSelection.cs +++ b/src/NHibernate/Engine/RowSelection.cs @@ -3,8 +3,8 @@ namespace NHibernate.Engine { /// - /// Information to determine how to run an IDbCommand and what - /// records to return from the IDataReader. + /// Information to determine how to run an DbCommand and what + /// records to return from the DbDataReader. /// [Serializable] public sealed class RowSelection diff --git a/src/NHibernate/Engine/Transaction/IIsolatedWork.cs b/src/NHibernate/Engine/Transaction/IIsolatedWork.cs index bbe88e95309..5352989925a 100644 --- a/src/NHibernate/Engine/Transaction/IIsolatedWork.cs +++ b/src/NHibernate/Engine/Transaction/IIsolatedWork.cs @@ -1,4 +1,4 @@ -using System.Data; +using System.Data.Common; namespace NHibernate.Engine.Transaction { @@ -14,6 +14,6 @@ public interface IIsolatedWork /// /// The ADP connection to use. /// The active transaction of the connection. - void DoWork(IDbConnection connection, IDbTransaction transaction); + void DoWork(DbConnection connection, DbTransaction transaction); } } \ No newline at end of file diff --git a/src/NHibernate/Engine/Transaction/Isolater.cs b/src/NHibernate/Engine/Transaction/Isolater.cs index 5c3ec37ec33..5f4ca98cb2f 100644 --- a/src/NHibernate/Engine/Transaction/Isolater.cs +++ b/src/NHibernate/Engine/Transaction/Isolater.cs @@ -1,5 +1,4 @@ using System; -using System.Data; using System.Data.Common; using NHibernate.Dialect; diff --git a/src/NHibernate/Engine/TransactionHelper.cs b/src/NHibernate/Engine/TransactionHelper.cs index b2922ba5abb..e8f8f9fa986 100644 --- a/src/NHibernate/Engine/TransactionHelper.cs +++ b/src/NHibernate/Engine/TransactionHelper.cs @@ -1,4 +1,3 @@ -using System.Data; using System.Data.Common; using NHibernate.Engine.Transaction; using NHibernate.Exceptions; @@ -25,7 +24,7 @@ public Work(ISessionImplementor session, TransactionHelper owner) #region Implementation of IIsolatedWork - public void DoWork(IDbConnection connection, IDbTransaction transaction) + public void DoWork(DbConnection connection, DbTransaction transaction) { try { @@ -41,7 +40,7 @@ public void DoWork(IDbConnection connection, IDbTransaction transaction) } /// The work to be done - public abstract object DoWorkInCurrentTransaction(ISessionImplementor session, IDbConnection conn, IDbTransaction transaction); + public abstract object DoWorkInCurrentTransaction(ISessionImplementor session, DbConnection conn, DbTransaction transaction); /// Suspend the current transaction and perform work in a new transaction public virtual object DoWorkInNewTransaction(ISessionImplementor session) diff --git a/src/NHibernate/Hql/Ast/ANTLR/Exec/AbstractStatementExecutor.cs b/src/NHibernate/Hql/Ast/ANTLR/Exec/AbstractStatementExecutor.cs index cf40408aa81..94a396d0e4e 100644 --- a/src/NHibernate/Hql/Ast/ANTLR/Exec/AbstractStatementExecutor.cs +++ b/src/NHibernate/Hql/Ast/ANTLR/Exec/AbstractStatementExecutor.cs @@ -1,5 +1,5 @@ using System; -using System.Data; +using System.Data.Common; using Antlr.Runtime; using Antlr.Runtime.Tree; using NHibernate.Action; @@ -13,6 +13,7 @@ using NHibernate.SqlTypes; using NHibernate.Transaction; using NHibernate.Util; +using System.Data; namespace NHibernate.Hql.Ast.ANTLR.Exec { @@ -192,7 +193,7 @@ protected virtual void DropTemporaryTableIfNecessary(IQueryable persister, ISess else { // at the very least cleanup the data :) - IDbCommand ps = null; + DbCommand ps = null; try { var commandText = new SqlString("delete from " + persister.TemporaryIdTableName); @@ -233,9 +234,9 @@ public TmpIdTableCreationIsolatedWork(IQueryable persister, IInternalLogger log, this.session = session; } - public void DoWork(IDbConnection connection, IDbTransaction transaction) + public void DoWork(DbConnection connection, DbTransaction transaction) { - IDbCommand stmnt = null; + DbCommand stmnt = null; try { stmnt = connection.CreateCommand(); @@ -278,9 +279,9 @@ public TmpIdTableDropIsolatedWork(IQueryable persister, IInternalLogger log, ISe private readonly IInternalLogger log; private readonly ISessionImplementor session; - public void DoWork(IDbConnection connection, IDbTransaction transaction) + public void DoWork(DbConnection connection, DbTransaction transaction) { - IDbCommand stmnt = null; + DbCommand stmnt = null; try { stmnt = connection.CreateCommand(); diff --git a/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs b/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs index e0b5e130ddb..92de0ee3a3d 100644 --- a/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs +++ b/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs @@ -52,7 +52,7 @@ public override int Execute(QueryParameters parameters, ISessionImplementor sess { CoordinateSharedCacheCleanup(session); - IDbCommand st = null; + DbCommand st = null; RowSelection selection = parameters.RowSelection; try diff --git a/src/NHibernate/Hql/Ast/ANTLR/Exec/MultiTableDeleteExecutor.cs b/src/NHibernate/Hql/Ast/ANTLR/Exec/MultiTableDeleteExecutor.cs index 39cd128f9e3..22ce6eb59b6 100644 --- a/src/NHibernate/Hql/Ast/ANTLR/Exec/MultiTableDeleteExecutor.cs +++ b/src/NHibernate/Hql/Ast/ANTLR/Exec/MultiTableDeleteExecutor.cs @@ -75,7 +75,7 @@ public override int Execute(QueryParameters parameters, ISessionImplementor sess try { // First, save off the pertinent ids, saving the number of pertinent ids for return - IDbCommand ps = null; + DbCommand ps = null; int resultCount; try { diff --git a/src/NHibernate/Hql/Ast/ANTLR/Exec/MultiTableUpdateExecutor.cs b/src/NHibernate/Hql/Ast/ANTLR/Exec/MultiTableUpdateExecutor.cs index 11db5b5970e..866105b3362 100644 --- a/src/NHibernate/Hql/Ast/ANTLR/Exec/MultiTableUpdateExecutor.cs +++ b/src/NHibernate/Hql/Ast/ANTLR/Exec/MultiTableUpdateExecutor.cs @@ -97,7 +97,7 @@ public override int Execute(QueryParameters parameters, ISessionImplementor sess try { // First, save off the pertinent ids, as the return value - IDbCommand ps = null; + DbCommand ps = null; int resultCount; try { diff --git a/src/NHibernate/IInterceptor.cs b/src/NHibernate/IInterceptor.cs index 07bb60c0265..26f6969427d 100644 --- a/src/NHibernate/IInterceptor.cs +++ b/src/NHibernate/IInterceptor.cs @@ -1,5 +1,5 @@ using System.Collections; -using System.Data; +using System.Data.Common; using NHibernate.SqlCommand; using NHibernate.Type; @@ -195,7 +195,7 @@ int[] FindDirty(object entity, object id, object[] currentState, object[] previo /// The use of singleton-interceptor may cause problems in multi-thread scenario. ///
/// - /// + /// void SetSession(ISession session); #endregion diff --git a/src/NHibernate/ISession.cs b/src/NHibernate/ISession.cs index 937302983d5..55dcffe5700 100644 --- a/src/NHibernate/ISession.cs +++ b/src/NHibernate/ISession.cs @@ -1,6 +1,6 @@ using System; -using System.Collections; using System.Data; +using System.Data.Common; using System.Linq.Expressions; using NHibernate.Engine; using NHibernate.Stat; @@ -114,7 +114,7 @@ public interface ISession : IDisposable /// Applications are responsible for calling commit/rollback upon the connection before /// closing the ISession. ///
- IDbConnection Connection { get; } + DbConnection Connection { get; } /// /// Disconnect the ISession from the current ADO.NET connection. @@ -125,7 +125,7 @@ public interface ISession : IDisposable /// long transactions. /// /// The connection provided by the application or - IDbConnection Disconnect(); + DbConnection Disconnect(); /// /// Obtain a new ADO.NET connection. @@ -140,7 +140,7 @@ public interface ISession : IDisposable /// /// This is used by applications which require long transactions /// An ADO.NET connection - void Reconnect(IDbConnection connection); + void Reconnect(DbConnection connection); /// /// End the ISession by disconnecting from the ADO.NET connection and cleaning up. @@ -150,7 +150,7 @@ public interface ISession : IDisposable /// at least Disconnect() it. /// /// The connection provided by the application or - IDbConnection Close(); + DbConnection Close(); /// /// Cancel execution of the current query. diff --git a/src/NHibernate/ISessionFactory.cs b/src/NHibernate/ISessionFactory.cs index b3e358ddb41..08e4dcfc301 100644 --- a/src/NHibernate/ISessionFactory.cs +++ b/src/NHibernate/ISessionFactory.cs @@ -1,7 +1,7 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Data; +using System.Data.Common; using NHibernate.Connection; using NHibernate.Engine; using NHibernate.Metadata; @@ -36,7 +36,7 @@ public interface ISessionFactory : IDisposable /// any statements you might have executed in the same transaction. /// Consider implementing your own . /// - ISession OpenSession(IDbConnection conn); + ISession OpenSession(DbConnection conn); /// /// Create database connection and open a ISession on it, specifying an interceptor @@ -57,7 +57,7 @@ public interface ISessionFactory : IDisposable /// any statements you might have executed in the same transaction. /// Consider implementing your own . /// - ISession OpenSession(IDbConnection conn, IInterceptor sessionLocalInterceptor); + ISession OpenSession(DbConnection conn, IInterceptor sessionLocalInterceptor); /// /// Create a database connection and open a ISession on it @@ -171,7 +171,7 @@ public interface ISessionFactory : IDisposable IStatelessSession OpenStatelessSession(); /// Get a new stateless session for the given ADO.NET connection. - IStatelessSession OpenStatelessSession(IDbConnection connection); + IStatelessSession OpenStatelessSession(DbConnection connection); /// /// Obtain the definition of a filter by name. diff --git a/src/NHibernate/IStatelessSession.cs b/src/NHibernate/IStatelessSession.cs index dd0ad009ee7..665de8b5ce2 100644 --- a/src/NHibernate/IStatelessSession.cs +++ b/src/NHibernate/IStatelessSession.cs @@ -1,5 +1,6 @@ using System; using System.Data; +using System.Data.Common; using System.Linq.Expressions; using NHibernate.Engine; @@ -32,7 +33,7 @@ public interface IStatelessSession : IDisposable /// close the connection returned by this call. Otherwise, the /// application should not close the connection. /// - IDbConnection Connection { get; } + DbConnection Connection { get; } /// Get the current NHibernate transaction. ITransaction Transaction { get; } diff --git a/src/NHibernate/ITransaction.cs b/src/NHibernate/ITransaction.cs index 58908abb0ff..acba42a7777 100644 --- a/src/NHibernate/ITransaction.cs +++ b/src/NHibernate/ITransaction.cs @@ -1,5 +1,6 @@ using System; using System.Data; +using System.Data.Common; using NHibernate.Transaction; namespace NHibernate @@ -62,13 +63,13 @@ public interface ITransaction : IDisposable bool WasCommitted { get; } /// - /// Enlist the in the current Transaction. + /// Enlist the in the current Transaction. /// - /// The to enlist. + /// The to enlist. /// /// It is okay for this to be a no op implementation. /// - void Enlist(IDbCommand command); + void Enlist(DbCommand command); /// diff --git a/src/NHibernate/Id/Enhanced/SequenceStructure.cs b/src/NHibernate/Id/Enhanced/SequenceStructure.cs index 84e76359b05..e9de07d56ba 100644 --- a/src/NHibernate/Id/Enhanced/SequenceStructure.cs +++ b/src/NHibernate/Id/Enhanced/SequenceStructure.cs @@ -98,8 +98,8 @@ public virtual long GetNextValue() _owner._accessCounter++; try { - IDbCommand st = _session.Batcher.PrepareCommand(CommandType.Text, _owner._sql, SqlTypeFactory.NoTypes); - IDataReader rs = null; + var st = _session.Batcher.PrepareCommand(CommandType.Text, _owner._sql, SqlTypeFactory.NoTypes); + DbDataReader rs = null; try { rs = _session.Batcher.ExecuteReader(st); diff --git a/src/NHibernate/Id/Enhanced/TableGenerator.cs b/src/NHibernate/Id/Enhanced/TableGenerator.cs index 6cc8e133db6..f39293bfa96 100644 --- a/src/NHibernate/Id/Enhanced/TableGenerator.cs +++ b/src/NHibernate/Id/Enhanced/TableGenerator.cs @@ -1,6 +1,7 @@ using System; -using System.Data; +using System.Data.Common; using System.Collections.Generic; +using System.Data; using System.Runtime.CompilerServices; using NHibernate.Engine; using NHibernate.Mapping; @@ -431,7 +432,7 @@ public long GetNextValue() } - public override object DoWorkInCurrentTransaction(ISessionImplementor session, System.Data.IDbConnection conn, System.Data.IDbTransaction transaction) + public override object DoWorkInCurrentTransaction(ISessionImplementor session, DbConnection conn, DbTransaction transaction) { long result; int updatedRows; @@ -442,13 +443,13 @@ public override object DoWorkInCurrentTransaction(ISessionImplementor session, S try { - IDbCommand selectCmd = session.Factory.ConnectionProvider.Driver.GenerateCommand(CommandType.Text, selectQuery, selectParameterTypes); + var selectCmd = session.Factory.ConnectionProvider.Driver.GenerateCommand(CommandType.Text, selectQuery, selectParameterTypes); using (selectCmd) { selectCmd.Connection = conn; selectCmd.Transaction = transaction; string s = selectCmd.CommandText; - ((IDataParameter)selectCmd.Parameters[0]).Value = SegmentValue; + selectCmd.Parameters[0].Value = SegmentValue; PersistentIdGeneratorParmsNames.SqlStatementLogger.LogCommand(selectCmd, FormatStyle.Basic); selectedValue = selectCmd.ExecuteScalar(); @@ -458,14 +459,14 @@ public override object DoWorkInCurrentTransaction(ISessionImplementor session, S { result = InitialValue; - IDbCommand insertCmd = session.Factory.ConnectionProvider.Driver.GenerateCommand(CommandType.Text, insertQuery, insertParameterTypes); + var insertCmd = session.Factory.ConnectionProvider.Driver.GenerateCommand(CommandType.Text, insertQuery, insertParameterTypes); using (insertCmd) { insertCmd.Connection = conn; insertCmd.Transaction = transaction; - ((IDataParameter)insertCmd.Parameters[0]).Value = SegmentValue; - ((IDataParameter)insertCmd.Parameters[1]).Value = result; + insertCmd.Parameters[0].Value = SegmentValue; + insertCmd.Parameters[1].Value = result; PersistentIdGeneratorParmsNames.SqlStatementLogger.LogCommand(insertCmd, FormatStyle.Basic); insertCmd.ExecuteNonQuery(); @@ -485,16 +486,16 @@ public override object DoWorkInCurrentTransaction(ISessionImplementor session, S try { - IDbCommand updateCmd = session.Factory.ConnectionProvider.Driver.GenerateCommand(CommandType.Text, updateQuery, updateParameterTypes); + var updateCmd = session.Factory.ConnectionProvider.Driver.GenerateCommand(CommandType.Text, updateQuery, updateParameterTypes); using (updateCmd) { updateCmd.Connection = conn; updateCmd.Transaction = transaction; int increment = Optimizer.ApplyIncrementSizeToSourceValues ? IncrementSize : 1; - ((IDataParameter)updateCmd.Parameters[0]).Value = result + increment; - ((IDataParameter)updateCmd.Parameters[1]).Value = result; - ((IDataParameter)updateCmd.Parameters[2]).Value = SegmentValue; + updateCmd.Parameters[0].Value = result + increment; + updateCmd.Parameters[1].Value = result; + updateCmd.Parameters[2].Value = SegmentValue; PersistentIdGeneratorParmsNames.SqlStatementLogger.LogCommand(updateCmd, FormatStyle.Basic); updatedRows = updateCmd.ExecuteNonQuery(); } diff --git a/src/NHibernate/Id/Enhanced/TableStructure.cs b/src/NHibernate/Id/Enhanced/TableStructure.cs index 898db495437..165fa6541a2 100644 --- a/src/NHibernate/Id/Enhanced/TableStructure.cs +++ b/src/NHibernate/Id/Enhanced/TableStructure.cs @@ -1,5 +1,6 @@ using System; using System.Data; +using System.Data.Common; using NHibernate.Engine; using NHibernate.SqlCommand; @@ -96,7 +97,7 @@ public virtual string[] SqlDropStrings(Dialect.Dialect dialect) #region Overrides of TransactionHelper - public override object DoWorkInCurrentTransaction(ISessionImplementor session, IDbConnection conn, IDbTransaction transaction) + public override object DoWorkInCurrentTransaction(ISessionImplementor session, DbConnection conn, DbTransaction transaction) { long result; int updatedRows; @@ -107,7 +108,7 @@ public override object DoWorkInCurrentTransaction(ISessionImplementor session, I { object selectedValue; - IDbCommand selectCmd = session.Factory.ConnectionProvider.Driver.GenerateCommand(CommandType.Text, _selectQuery, SqlTypeFactory.NoTypes); + var selectCmd = session.Factory.ConnectionProvider.Driver.GenerateCommand(CommandType.Text, _selectQuery, SqlTypeFactory.NoTypes); using (selectCmd) { selectCmd.Connection = conn; @@ -133,7 +134,7 @@ public override object DoWorkInCurrentTransaction(ISessionImplementor session, I try { - IDbCommand updateCmd = session.Factory.ConnectionProvider.Driver.GenerateCommand(CommandType.Text, _updateQuery, _updateParameterTypes); + var updateCmd = session.Factory.ConnectionProvider.Driver.GenerateCommand(CommandType.Text, _updateQuery, _updateParameterTypes); using (updateCmd) { updateCmd.Connection = conn; @@ -141,8 +142,8 @@ public override object DoWorkInCurrentTransaction(ISessionImplementor session, I PersistentIdGeneratorParmsNames.SqlStatementLogger.LogCommand(updateCmd, FormatStyle.Basic); int increment = _applyIncrementSizeToSourceValues ? _incrementSize : 1; - ((IDataParameter)updateCmd.Parameters[0]).Value = result + increment; - ((IDataParameter)updateCmd.Parameters[1]).Value = result; + updateCmd.Parameters[0].Value = result + increment; + updateCmd.Parameters[1].Value = result; updatedRows = updateCmd.ExecuteNonQuery(); } } diff --git a/src/NHibernate/Id/IdentifierGeneratorFactory.cs b/src/NHibernate/Id/IdentifierGeneratorFactory.cs index 0a44738fdaa..be329770737 100644 --- a/src/NHibernate/Id/IdentifierGeneratorFactory.cs +++ b/src/NHibernate/Id/IdentifierGeneratorFactory.cs @@ -1,7 +1,7 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Data; +using System.Data.Common; using NHibernate.Engine; using NHibernate.Type; @@ -87,11 +87,11 @@ public static class IdentifierGeneratorFactory private static readonly IInternalLogger log = LoggerProvider.LoggerFor(typeof (IdentifierGeneratorFactory)); /// Get the generated identifier when using identity columns - /// The to read the identifier value from. + /// The to read the identifier value from. /// The the value should be converted to. /// The the value is retrieved in. /// The value for the identifier. - public static object GetGeneratedIdentity(IDataReader rs, IType type, ISessionImplementor session) + public static object GetGeneratedIdentity(DbDataReader rs, IType type, ISessionImplementor session) { if (!rs.Read()) { @@ -107,20 +107,20 @@ public static object GetGeneratedIdentity(IDataReader rs, IType type, ISessionIm } /// - /// Gets the value of the identifier from the and + /// Gets the value of the identifier from the and /// ensures it is the correct . /// - /// The to read the identifier value from. + /// The to read the identifier value from. /// The the value should be converted to. /// The the value is retrieved in. /// /// The value for the identifier. /// /// - /// Thrown if there is any problem getting the value from the + /// Thrown if there is any problem getting the value from the /// or with converting it to the . /// - public static object Get(IDataReader rs, IType type, ISessionImplementor session) + public static object Get(DbDataReader rs, IType type, ISessionImplementor session) { // here is an interesting one: // - MsSql's @@identity returns a Decimal diff --git a/src/NHibernate/Id/IdentityGenerator.cs b/src/NHibernate/Id/IdentityGenerator.cs index ecfc9d18490..66950614c4f 100644 --- a/src/NHibernate/Id/IdentityGenerator.cs +++ b/src/NHibernate/Id/IdentityGenerator.cs @@ -1,5 +1,6 @@ using System; using System.Data; +using System.Data.Common; using NHibernate.Engine; using NHibernate.Id.Insert; using NHibernate.SqlCommand; @@ -64,14 +65,14 @@ public override IdentifierGeneratingInsert PrepareIdentifierGeneratingInsert() return insert; } - protected internal override IDbCommand Prepare(SqlCommandInfo insertSQL, ISessionImplementor session) + protected internal override DbCommand Prepare(SqlCommandInfo insertSQL, ISessionImplementor session) { return session.Batcher.PrepareCommand(CommandType.Text, insertSQL.Text, insertSQL.ParameterTypes); } - public override object ExecuteAndExtract(IDbCommand insert, ISessionImplementor session) + public override object ExecuteAndExtract(DbCommand insert, ISessionImplementor session) { - IDataReader rs = session.Batcher.ExecuteReader(insert); + var rs = session.Batcher.ExecuteReader(insert); try { return IdentifierGeneratorFactory.GetGeneratedIdentity(rs, persister.IdentifierType, session); @@ -117,7 +118,7 @@ public override IdentifierGeneratingInsert PrepareIdentifierGeneratingInsert() return insert; } - protected internal override object GetResult(ISessionImplementor session, IDataReader rs, object obj) + protected internal override object GetResult(ISessionImplementor session, DbDataReader rs, object obj) { return IdentifierGeneratorFactory.GetGeneratedIdentity(rs, persister.IdentifierType, session); } diff --git a/src/NHibernate/Id/IncrementGenerator.cs b/src/NHibernate/Id/IncrementGenerator.cs index 97c29bd5021..d9ef06da4d0 100644 --- a/src/NHibernate/Id/IncrementGenerator.cs +++ b/src/NHibernate/Id/IncrementGenerator.cs @@ -102,7 +102,7 @@ private void GetNext(ISessionImplementor session) try { var cmd = session.Batcher.PrepareCommand(CommandType.Text, _sql, SqlTypeFactory.NoTypes); - IDataReader reader = null; + DbDataReader reader = null; try { reader = session.Batcher.ExecuteReader(cmd); diff --git a/src/NHibernate/Id/Insert/AbstractReturningDelegate.cs b/src/NHibernate/Id/Insert/AbstractReturningDelegate.cs index 487c9497249..b516a769b28 100644 --- a/src/NHibernate/Id/Insert/AbstractReturningDelegate.cs +++ b/src/NHibernate/Id/Insert/AbstractReturningDelegate.cs @@ -1,4 +1,3 @@ -using System.Data; using System.Data.Common; using NHibernate.Engine; using NHibernate.Exceptions; @@ -35,7 +34,7 @@ public object PerformInsert(SqlCommandInfo insertSQL, ISessionImplementor sessio try { // prepare and execute the insert - IDbCommand insert = Prepare(insertSQL, session); + var insert = Prepare(insertSQL, session); try { binder.BindValues(insert); @@ -55,13 +54,13 @@ public object PerformInsert(SqlCommandInfo insertSQL, ISessionImplementor sessio #endregion - protected internal virtual void ReleaseStatement(IDbCommand insert, ISessionImplementor session) + protected internal virtual void ReleaseStatement(DbCommand insert, ISessionImplementor session) { session.Batcher.CloseCommand(insert, null); } - protected internal abstract IDbCommand Prepare(SqlCommandInfo insertSQL, ISessionImplementor session); + protected internal abstract DbCommand Prepare(SqlCommandInfo insertSQL, ISessionImplementor session); - public abstract object ExecuteAndExtract(IDbCommand insert, ISessionImplementor session); + public abstract object ExecuteAndExtract(DbCommand insert, ISessionImplementor session); } } \ No newline at end of file diff --git a/src/NHibernate/Id/Insert/AbstractSelectingDelegate.cs b/src/NHibernate/Id/Insert/AbstractSelectingDelegate.cs index 1a969c33a7f..2afa5842fe6 100644 --- a/src/NHibernate/Id/Insert/AbstractSelectingDelegate.cs +++ b/src/NHibernate/Id/Insert/AbstractSelectingDelegate.cs @@ -31,7 +31,7 @@ public object PerformInsert(SqlCommandInfo insertSQL, ISessionImplementor sessio try { // prepare and execute the insert - IDbCommand insert = session.Batcher.PrepareCommand(insertSQL.CommandType, insertSQL.Text, insertSQL.ParameterTypes); + var insert = session.Batcher.PrepareCommand(insertSQL.CommandType, insertSQL.Text, insertSQL.ParameterTypes); try { binder.BindValues(insert); @@ -53,11 +53,11 @@ public object PerformInsert(SqlCommandInfo insertSQL, ISessionImplementor sessio try { //fetch the generated id in a separate query - IDbCommand idSelect = session.Batcher.PrepareCommand(CommandType.Text, selectSQL, ParametersTypes); + var idSelect = session.Batcher.PrepareCommand(CommandType.Text, selectSQL, ParametersTypes); try { BindParameters(session, idSelect, binder.Entity); - IDataReader rs = session.Batcher.ExecuteReader(idSelect); + var rs = session.Batcher.ExecuteReader(idSelect); try { return GetResult(session, rs, binder.Entity); @@ -91,13 +91,13 @@ public object PerformInsert(SqlCommandInfo insertSQL, ISessionImplementor sessio /// The result set containing the generated primary key values. /// The entity being saved. /// The generated identifier - protected internal abstract object GetResult(ISessionImplementor session, IDataReader rs, object entity); + protected internal abstract object GetResult(ISessionImplementor session, DbDataReader rs, object entity); /// Bind any required parameter values into the SQL command . /// The session /// The prepared command /// The entity being saved. - protected internal virtual void BindParameters(ISessionImplementor session, IDbCommand ps, object entity) { } + protected internal virtual void BindParameters(ISessionImplementor session, DbCommand ps, object entity) { } #region NH Specific diff --git a/src/NHibernate/Id/Insert/IBinder.cs b/src/NHibernate/Id/Insert/IBinder.cs index 79bb9d3cac3..ec5a6bb2a6d 100644 --- a/src/NHibernate/Id/Insert/IBinder.cs +++ b/src/NHibernate/Id/Insert/IBinder.cs @@ -1,10 +1,10 @@ -using System.Data; +using System.Data.Common; namespace NHibernate.Id.Insert { public interface IBinder { object Entity { get;} - void BindValues(IDbCommand cm); + void BindValues(DbCommand cm); } } \ No newline at end of file diff --git a/src/NHibernate/Id/Insert/OutputParamReturningDelegate.cs b/src/NHibernate/Id/Insert/OutputParamReturningDelegate.cs index 7ef564f4ca8..deb5b086684 100644 --- a/src/NHibernate/Id/Insert/OutputParamReturningDelegate.cs +++ b/src/NHibernate/Id/Insert/OutputParamReturningDelegate.cs @@ -1,5 +1,6 @@ using System; using System.Data; +using System.Data.Common; using NHibernate.Dialect; using NHibernate.Engine; using NHibernate.SqlCommand; @@ -40,11 +41,11 @@ public override IdentifierGeneratingInsert PrepareIdentifierGeneratingInsert() return new ReturningIdentifierInsert(factory, idColumnName, ReturnParameterName); } - protected internal override IDbCommand Prepare(SqlCommandInfo insertSQL, ISessionImplementor session) + protected internal override DbCommand Prepare(SqlCommandInfo insertSQL, ISessionImplementor session) { - IDbCommand command = session.Batcher.PrepareCommand(CommandType.Text, insertSQL.Text, insertSQL.ParameterTypes); + var command = session.Batcher.PrepareCommand(CommandType.Text, insertSQL.Text, insertSQL.ParameterTypes); //Add the output parameter - IDbDataParameter idParameter = factory.ConnectionProvider.Driver.GenerateParameter(command, ReturnParameterName, + var idParameter = factory.ConnectionProvider.Driver.GenerateParameter(command, ReturnParameterName, paramType); driveGeneratedParamName = idParameter.ParameterName; @@ -59,10 +60,10 @@ protected internal override IDbCommand Prepare(SqlCommandInfo insertSQL, ISessio return command; } - public override object ExecuteAndExtract(IDbCommand insert, ISessionImplementor session) + public override object ExecuteAndExtract(DbCommand insert, ISessionImplementor session) { session.Batcher.ExecuteNonQuery(insert); - return Convert.ChangeType(((IDbDataParameter) insert.Parameters[driveGeneratedParamName]).Value, Persister.IdentifierType.ReturnedClass); + return Convert.ChangeType(insert.Parameters[driveGeneratedParamName].Value, Persister.IdentifierType.ReturnedClass); } #endregion diff --git a/src/NHibernate/Id/NativeGuidGenerator.cs b/src/NHibernate/Id/NativeGuidGenerator.cs index 7616456d57b..0164f23e870 100644 --- a/src/NHibernate/Id/NativeGuidGenerator.cs +++ b/src/NHibernate/Id/NativeGuidGenerator.cs @@ -1,5 +1,6 @@ using System; using System.Data; +using System.Data.Common; using NHibernate.Engine; using NHibernate.Exceptions; @@ -24,8 +25,8 @@ public object Generate(ISessionImplementor session, object obj) var sql = new SqlString(session.Factory.Dialect.SelectGUIDString); try { - IDbCommand st = session.Batcher.PrepareCommand(CommandType.Text, sql, SqlTypeFactory.NoTypes); - IDataReader reader = null; + var st = session.Batcher.PrepareCommand(CommandType.Text, sql, SqlTypeFactory.NoTypes); + DbDataReader reader = null; try { reader = session.Batcher.ExecuteReader(st); diff --git a/src/NHibernate/Id/SelectGenerator.cs b/src/NHibernate/Id/SelectGenerator.cs index e2efaac451a..717959d469f 100644 --- a/src/NHibernate/Id/SelectGenerator.cs +++ b/src/NHibernate/Id/SelectGenerator.cs @@ -1,5 +1,5 @@ using System.Collections.Generic; -using System.Data; +using System.Data.Common; using NHibernate.Engine; using NHibernate.Id.Insert; using NHibernate.Persister.Entity; @@ -103,14 +103,14 @@ public override IdentifierGeneratingInsert PrepareIdentifierGeneratingInsert() return new IdentifierGeneratingInsert(factory); } - protected internal override void BindParameters(ISessionImplementor session, IDbCommand ps, object entity) + protected internal override void BindParameters(ISessionImplementor session, DbCommand ps, object entity) { object uniqueKeyValue = ((IEntityPersister) persister).GetPropertyValue(entity, uniqueKeyPropertyName, session.EntityMode); uniqueKeyType.NullSafeSet(ps, uniqueKeyValue, 0, session); } - protected internal override object GetResult(ISessionImplementor session, IDataReader rs, object entity) + protected internal override object GetResult(ISessionImplementor session, DbDataReader rs, object entity) { if (!rs.Read()) { diff --git a/src/NHibernate/Id/SequenceGenerator.cs b/src/NHibernate/Id/SequenceGenerator.cs index 16859f86a5b..721ce0d6395 100644 --- a/src/NHibernate/Id/SequenceGenerator.cs +++ b/src/NHibernate/Id/SequenceGenerator.cs @@ -1,6 +1,5 @@ using System; using System.Collections; -using System.Data; using NHibernate.Engine; using NHibernate.Exceptions; @@ -9,6 +8,7 @@ using NHibernate.Type; using NHibernate.Util; using System.Collections.Generic; +using System.Data; using System.Data.Common; namespace NHibernate.Id @@ -113,8 +113,8 @@ public virtual object Generate(ISessionImplementor session, object obj) { try { - IDbCommand cmd = session.Batcher.PrepareCommand(CommandType.Text, sql, SqlTypeFactory.NoTypes); - IDataReader reader = null; + var cmd = session.Batcher.PrepareCommand(CommandType.Text, sql, SqlTypeFactory.NoTypes); + DbDataReader reader = null; try { reader = session.Batcher.ExecuteReader(cmd); diff --git a/src/NHibernate/Id/TableGenerator.cs b/src/NHibernate/Id/TableGenerator.cs index b4dea86eccc..11396482008 100644 --- a/src/NHibernate/Id/TableGenerator.cs +++ b/src/NHibernate/Id/TableGenerator.cs @@ -2,6 +2,7 @@ using System.Collections; using System.Collections.Generic; using System.Data; +using System.Data.Common; using System.Runtime.CompilerServices; using NHibernate.AdoNet.Util; @@ -209,8 +210,8 @@ public string GeneratorKey() #endregion - public override object DoWorkInCurrentTransaction(ISessionImplementor session, IDbConnection conn, - IDbTransaction transaction) + public override object DoWorkInCurrentTransaction(ISessionImplementor session, DbConnection conn, + DbTransaction transaction) { long result; int rows; @@ -220,8 +221,8 @@ public override object DoWorkInCurrentTransaction(ISessionImplementor session, I //select + uspdate even for no transaction //or read committed isolation level (needed for .net?) - IDbCommand qps = conn.CreateCommand(); - IDataReader rs = null; + var qps = conn.CreateCommand(); + DbDataReader rs = null; qps.CommandText = query; qps.CommandType = CommandType.Text; qps.Transaction = transaction; @@ -259,8 +260,7 @@ public override object DoWorkInCurrentTransaction(ISessionImplementor session, I qps.Dispose(); } - IDbCommand ups = session.Factory.ConnectionProvider.Driver.GenerateCommand(CommandType.Text, updateSql, - parameterTypes); + var ups = session.Factory.ConnectionProvider.Driver.GenerateCommand(CommandType.Text, updateSql, parameterTypes); ups.Connection = conn; ups.Transaction = transaction; diff --git a/src/NHibernate/Impl/AbstractSessionImpl.cs b/src/NHibernate/Impl/AbstractSessionImpl.cs index 85c3521afff..aaa6ad229a9 100644 --- a/src/NHibernate/Impl/AbstractSessionImpl.cs +++ b/src/NHibernate/Impl/AbstractSessionImpl.cs @@ -1,7 +1,7 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Data; +using System.Data.Common; using NHibernate.AdoNet; using NHibernate.Cache; using NHibernate.Collection; @@ -258,7 +258,7 @@ public virtual IQueryTranslator[] GetQueries(string query, bool scalar) public abstract string FetchProfile { get; set; } public abstract string BestGuessEntityName(object entity); public abstract string GuessEntityName(object entity); - public abstract IDbConnection Connection { get; } + public abstract DbConnection Connection { get; } public abstract int ExecuteNativeUpdate(NativeSQLQuerySpecification specification, QueryParameters queryParameters); public abstract FutureCriteriaBatch FutureCriteriaBatch { get; protected internal set; } public abstract FutureQueryBatch FutureQueryBatch { get; protected internal set; } diff --git a/src/NHibernate/Impl/EnumerableImpl.cs b/src/NHibernate/Impl/EnumerableImpl.cs index a737ca08dfc..d3183568d1c 100644 --- a/src/NHibernate/Impl/EnumerableImpl.cs +++ b/src/NHibernate/Impl/EnumerableImpl.cs @@ -1,6 +1,5 @@ using System; using System.Collections; -using System.Data; using System.Data.Common; using NHibernate.Engine; @@ -22,7 +21,7 @@ public class EnumerableImpl : IEnumerable, IEnumerator, IDisposable { private static readonly IInternalLogger log = LoggerProvider.LoggerFor(typeof(EnumerableImpl)); - private IDataReader _reader; + private DbDataReader _reader; private IEventSource _session; private IType[] _types; private bool _single; @@ -30,7 +29,7 @@ public class EnumerableImpl : IEnumerable, IEnumerator, IDisposable private bool _hasNext; private bool _startedReading; // True if at least one MoveNext call was made. private string[][] _names; - private IDbCommand _cmd; + private DbCommand _cmd; private bool _readOnly; // when we start enumerating through the DataReader we are positioned @@ -40,21 +39,21 @@ public class EnumerableImpl : IEnumerable, IEnumerator, IDisposable private RowSelection _selection; /// - /// Create an wrapper over an . + /// Create an wrapper over an . /// - /// The to enumerate over. - /// The used to create the . + /// The to enumerate over. + /// The used to create the . /// The to use to load objects. /// - /// The s contained in the . - /// The names of the columns in the . - /// The that should be applied to the . + /// The s contained in the . + /// The names of the columns in the . + /// The that should be applied to the . /// Instantiator of the result holder (used for "select new SomeClass(...)" queries). /// - /// The should already be positioned on the first record in . + /// The should already be positioned on the first record in . /// - public EnumerableImpl(IDataReader reader, - IDbCommand cmd, + public EnumerableImpl(DbDataReader reader, + DbCommand cmd, IEventSource session, bool readOnly, IType[] types, @@ -186,13 +185,13 @@ private void PostMoveNext(bool hasNext) { object[] currentResults = new object[_types.Length]; - // move through each of the ITypes contained in the IDataReader and convert them + // move through each of the ITypes contained in the DbDataReader and convert them // to their objects. for (int i = 0; i < _types.Length; i++) { - // The IType knows how to extract its value out of the IDataReader. If the IType - // is a value type then the value will simply be pulled out of the IDataReader. If - // the IType is an Entity type then the IType will extract the id from the IDataReader + // The IType knows how to extract its value out of the DbDataReader. If the IType + // is a value type then the value will simply be pulled out of the DbDataReader. If + // the IType is an Entity type then the IType will extract the id from the DbDataReader // and use the ISession to load an instance of the object. currentResults[i] = _types[i].NullSafeGet(_reader, _names[i], _session, null); } diff --git a/src/NHibernate/Impl/SessionFactoryImpl.cs b/src/NHibernate/Impl/SessionFactoryImpl.cs index b15e065ecde..32d4ef09edb 100644 --- a/src/NHibernate/Impl/SessionFactoryImpl.cs +++ b/src/NHibernate/Impl/SessionFactoryImpl.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Concurrent; using System.Collections.Generic; -using System.Data; +using System.Data.Common; using System.Linq; using System.Runtime.Serialization; using System.Security; @@ -51,10 +51,10 @@ namespace NHibernate.Impl /// Caches "compiled" queries (memory sensitive cache) /// /// - /// Manages PreparedStatements/IDbCommands - how true in NH? + /// Manages PreparedStatements/DbCommands - how true in NH? /// /// - /// Delegates IDbConnection management to the + /// Delegates DbConnection management to the /// /// /// Factory for instances of @@ -465,12 +465,12 @@ public ISession OpenSession() return OpenSession(interceptor); } - public ISession OpenSession(IDbConnection connection) + public ISession OpenSession(DbConnection connection) { return OpenSession(connection, interceptor); } - public ISession OpenSession(IDbConnection connection, IInterceptor sessionLocalInterceptor) + public ISession OpenSession(DbConnection connection, IInterceptor sessionLocalInterceptor) { if (sessionLocalInterceptor == null) { @@ -489,7 +489,7 @@ public ISession OpenSession(IInterceptor sessionLocalInterceptor) return OpenSession(null, true, timestamp, sessionLocalInterceptor); } - public ISession OpenSession(IDbConnection connection, bool flushBeforeCompletionEnabled, bool autoCloseSessionEnabled, + public ISession OpenSession(DbConnection connection, bool flushBeforeCompletionEnabled, bool autoCloseSessionEnabled, ConnectionReleaseMode connectionReleaseMode) { #pragma warning disable 618 @@ -1093,7 +1093,7 @@ public IStatelessSession OpenStatelessSession() } /// Get a new stateless session for the given ADO.NET connection. - public IStatelessSession OpenStatelessSession(IDbConnection connection) + public IStatelessSession OpenStatelessSession(DbConnection connection) { return new StatelessSessionImpl(connection, this); } @@ -1202,7 +1202,7 @@ private IDictionary CheckNamedQueries() return errors; } - private SessionImpl OpenSession(IDbConnection connection, bool autoClose, long timestamp, IInterceptor sessionLocalInterceptor) + private SessionImpl OpenSession(DbConnection connection, bool autoClose, long timestamp, IInterceptor sessionLocalInterceptor) { #pragma warning disable 618 var isInterceptorsBeforeTransactionCompletionIgnoreExceptionsEnabled = settings.IsInterceptorsBeforeTransactionCompletionIgnoreExceptionsEnabled; diff --git a/src/NHibernate/Impl/SessionImpl.cs b/src/NHibernate/Impl/SessionImpl.cs index 1b8a520e323..51f8f1a5ab7 100644 --- a/src/NHibernate/Impl/SessionImpl.cs +++ b/src/NHibernate/Impl/SessionImpl.cs @@ -2,6 +2,7 @@ using System.Collections; using System.Collections.Generic; using System.Data; +using System.Data.Common; using System.Linq.Expressions; using System.Runtime.Serialization; using System.Security; @@ -203,7 +204,7 @@ void IDeserializationCallback.OnDeserialization(object sender) /// The mode by which we should release JDBC connections. /// The default flush mode for this session internal SessionImpl( - IDbConnection connection, + DbConnection connection, SessionFactoryImpl factory, bool autoclose, long timestamp, @@ -347,7 +348,7 @@ public bool ShouldAutoClose /// Close() is not aware of distributed transactions /// /// - public IDbConnection Close() + public DbConnection Close() { using (new SessionIdLoggingContext(SessionId)) { @@ -1580,7 +1581,7 @@ public override void InitializeCollection(IPersistentCollection collection, bool } } - public override IDbConnection Connection + public override DbConnection Connection { get { return connectionManager.GetConnection(); } } @@ -1592,7 +1593,7 @@ public override IDbConnection Connection /// if the ISession is connected. /// /// - /// An ISession is considered connected if there is an (regardless + /// An ISession is considered connected if there is an (regardless /// of its state) or if it the field connect is true. Meaning that it will connect /// at the next operation that requires a connection. /// @@ -1602,7 +1603,7 @@ public override bool IsConnected } /// - public IDbConnection Disconnect() + public DbConnection Disconnect() { using (new SessionIdLoggingContext(SessionId)) { @@ -1622,7 +1623,7 @@ public void Reconnect() } } - public void Reconnect(IDbConnection conn) + public void Reconnect(DbConnection conn) { using (new SessionIdLoggingContext(SessionId)) { diff --git a/src/NHibernate/Impl/StatelessSessionImpl.cs b/src/NHibernate/Impl/StatelessSessionImpl.cs index 0e648b1997b..4deb6cf6717 100644 --- a/src/NHibernate/Impl/StatelessSessionImpl.cs +++ b/src/NHibernate/Impl/StatelessSessionImpl.cs @@ -2,6 +2,7 @@ using System.Collections; using System.Collections.Generic; using System.Data; +using System.Data.Common; using System.Linq.Expressions; using NHibernate.AdoNet; using NHibernate.Cache; @@ -32,7 +33,7 @@ public class StatelessSessionImpl : AbstractSessionImpl, IStatelessSession [NonSerialized] private readonly StatefulPersistenceContext temporaryPersistenceContext; - internal StatelessSessionImpl(IDbConnection connection, SessionFactoryImpl factory) + internal StatelessSessionImpl(DbConnection connection, SessionFactoryImpl factory) : base(factory) { using (new SessionIdLoggingContext(SessionId)) @@ -365,7 +366,7 @@ public override string GuessEntityName(object entity) return entity.GetType().FullName; } - public override IDbConnection Connection + public override DbConnection Connection { get { return connectionManager.GetConnection(); } } diff --git a/src/NHibernate/Loader/Criteria/CriteriaLoader.cs b/src/NHibernate/Loader/Criteria/CriteriaLoader.cs index ef2bd9ad822..ad7a06862ae 100644 --- a/src/NHibernate/Loader/Criteria/CriteriaLoader.cs +++ b/src/NHibernate/Loader/Criteria/CriteriaLoader.cs @@ -1,7 +1,7 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Data; +using System.Data.Common; using NHibernate.Engine; using NHibernate.Impl; using NHibernate.Param; @@ -106,7 +106,7 @@ protected override bool AreResultSetRowsTransformedImmediately() return true; } - protected override object GetResultColumnOrRow(object[] row, IResultTransformer customResultTransformer, IDataReader rs, + protected override object GetResultColumnOrRow(object[] row, IResultTransformer customResultTransformer, DbDataReader rs, ISessionImplementor session) { return ResolveResultTransformer(customResultTransformer) @@ -114,7 +114,7 @@ protected override object GetResultColumnOrRow(object[] row, IResultTransformer } - protected override object[] GetResultRow(object[] row, IDataReader rs, ISessionImplementor session) + protected override object[] GetResultRow(object[] row, DbDataReader rs, ISessionImplementor session) { object[] result; diff --git a/src/NHibernate/Loader/Custom/CustomLoader.cs b/src/NHibernate/Loader/Custom/CustomLoader.cs index 9ba951847c2..ca295053f63 100644 --- a/src/NHibernate/Loader/Custom/CustomLoader.cs +++ b/src/NHibernate/Loader/Custom/CustomLoader.cs @@ -2,7 +2,7 @@ using System.Linq; using System.Collections; using System.Collections.Generic; -using System.Data; +using System.Data.Common; using NHibernate.Engine; using NHibernate.Hql; using NHibernate.Param; @@ -287,7 +287,7 @@ public IList List(ISessionImplementor session, QueryParameters queryParameters) // Not ported: scroll - protected override object GetResultColumnOrRow(object[] row, IResultTransformer resultTransformer, IDataReader rs, + protected override object GetResultColumnOrRow(object[] row, IResultTransformer resultTransformer, DbDataReader rs, ISessionImplementor session) { return rowProcessor.BuildResultRow(row, rs, resultTransformer != null, session); @@ -326,7 +326,7 @@ public override IList GetResultList(IList results, IResultTransformer resultTran } } - protected internal override void AutoDiscoverTypes(IDataReader rs) + protected internal override void AutoDiscoverTypes(DbDataReader rs) { MetaData metadata = new MetaData(rs); List aliases = new List(); @@ -396,7 +396,7 @@ public ResultRowProcessor(bool hasScalars, IResultColumnProcessor[] columnProces /// At this point, Loader has already processed all non-scalar result data. We /// just need to account for scalar result data here... /// - public object BuildResultRow(object[] data, IDataReader resultSet, bool hasTransformer, ISessionImplementor session) + public object BuildResultRow(object[] data, DbDataReader resultSet, bool hasTransformer, ISessionImplementor session) { object[] resultRow; // NH Different behavior (patched in NH-1612 to solve Hibernate issue HHH-2831). @@ -435,7 +435,7 @@ public void PrepareForAutoDiscovery(MetaData metadata) public interface IResultColumnProcessor { - object Extract(object[] data, IDataReader resultSet, ISessionImplementor session); + object Extract(object[] data, DbDataReader resultSet, ISessionImplementor session); void PerformDiscovery(MetaData metadata, IList types, IList aliases); } @@ -448,7 +448,7 @@ public NonScalarResultColumnProcessor(int position) this.position = position; } - public object Extract(object[] data, IDataReader resultSet, ISessionImplementor session) + public object Extract(object[] data, DbDataReader resultSet, ISessionImplementor session) { return data[position]; } @@ -473,7 +473,7 @@ public ScalarResultColumnProcessor(string alias, IType type) this.type = type; } - public object Extract(object[] data, IDataReader resultSet, ISessionImplementor session) + public object Extract(object[] data, DbDataReader resultSet, ISessionImplementor session) { return type.NullSafeGet(resultSet, alias, session, null); } @@ -502,13 +502,13 @@ public void PerformDiscovery(MetaData metadata, IList types, IList public class MetaData { - private readonly IDataReader resultSet; + private readonly DbDataReader resultSet; /// /// Initializes a new instance of the class. /// /// The result set. - public MetaData(IDataReader resultSet) + public MetaData(DbDataReader resultSet) { this.resultSet = resultSet; } diff --git a/src/NHibernate/Loader/Entity/AbstractEntityLoader.cs b/src/NHibernate/Loader/Entity/AbstractEntityLoader.cs index 921bf60429e..1578bda9b51 100644 --- a/src/NHibernate/Loader/Entity/AbstractEntityLoader.cs +++ b/src/NHibernate/Loader/Entity/AbstractEntityLoader.cs @@ -1,6 +1,6 @@ using System.Collections; using System.Collections.Generic; -using System.Data; +using System.Data.Common; using System.Linq; using NHibernate.Engine; using NHibernate.Param; @@ -66,7 +66,7 @@ protected virtual object Load(ISessionImplementor session, object id, object opt } } - protected override object GetResultColumnOrRow(object[] row, IResultTransformer resultTransformer, IDataReader rs, + protected override object GetResultColumnOrRow(object[] row, IResultTransformer resultTransformer, DbDataReader rs, ISessionImplementor session) { return row[row.Length - 1]; diff --git a/src/NHibernate/Loader/Entity/CollectionElementLoader.cs b/src/NHibernate/Loader/Entity/CollectionElementLoader.cs index 2bc8ca5cb80..d8c27f7fb15 100644 --- a/src/NHibernate/Loader/Entity/CollectionElementLoader.cs +++ b/src/NHibernate/Loader/Entity/CollectionElementLoader.cs @@ -1,6 +1,6 @@ using System.Collections; using System.Collections.Generic; -using System.Data; +using System.Data.Common; using System.Linq; using NHibernate.Engine; using NHibernate.Param; @@ -94,7 +94,7 @@ public virtual object LoadElement(ISessionImplementor session, object key, objec } } - protected override object GetResultColumnOrRow(object[] row, IResultTransformer transformer, IDataReader rs, + protected override object GetResultColumnOrRow(object[] row, IResultTransformer transformer, DbDataReader rs, ISessionImplementor session) { return row[row.Length - 1]; diff --git a/src/NHibernate/Loader/Hql/QueryLoader.cs b/src/NHibernate/Loader/Hql/QueryLoader.cs index 2273716525e..8b8d081956e 100644 --- a/src/NHibernate/Loader/Hql/QueryLoader.cs +++ b/src/NHibernate/Loader/Hql/QueryLoader.cs @@ -1,7 +1,7 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Data; +using System.Data.Common; using System.Diagnostics; using NHibernate.Engine; using NHibernate.Event; @@ -324,7 +324,7 @@ protected override IResultTransformer ResolveResultTransformer(IResultTransforme return HolderInstantiator.ResolveResultTransformer(_selectNewTransformer, resultTransformer); } - protected override object GetResultColumnOrRow(object[] row, IResultTransformer resultTransformer, IDataReader rs, + protected override object GetResultColumnOrRow(object[] row, IResultTransformer resultTransformer, DbDataReader rs, ISessionImplementor session) { Object[] resultRow = GetResultRow(row, rs, session); @@ -335,7 +335,7 @@ protected override object GetResultColumnOrRow(object[] row, IResultTransformer ); } - protected override object[] GetResultRow(object[] row, IDataReader rs, ISessionImplementor session) + protected override object[] GetResultRow(object[] row, DbDataReader rs, ISessionImplementor session) { object[] resultRow; @@ -424,10 +424,10 @@ internal IEnumerable GetEnumerable(QueryParameters queryParameters, IEventSource stopWath.Start(); } - IDbCommand cmd = PrepareQueryCommand(queryParameters, false, session); + var cmd = PrepareQueryCommand(queryParameters, false, session); - // This IDataReader is disposed of in EnumerableImpl.Dispose - IDataReader rs = GetResultSet(cmd, queryParameters.HasAutoDiscoverScalarTypes, false, queryParameters.RowSelection, session); + // This DbDataReader is disposed of in EnumerableImpl.Dispose + var rs = GetResultSet(cmd, queryParameters.HasAutoDiscoverScalarTypes, false, queryParameters.RowSelection, session); HolderInstantiator hi = HolderInstantiator.GetHolderInstantiator(_selectNewTransformer, queryParameters.ResultTransformer, _queryReturnAliases); diff --git a/src/NHibernate/Loader/Loader.cs b/src/NHibernate/Loader/Loader.cs index 77890dfa737..5baefdf843e 100644 --- a/src/NHibernate/Loader/Loader.cs +++ b/src/NHibernate/Loader/Loader.cs @@ -2,6 +2,7 @@ using System.Collections; using System.Collections.Generic; using System.Data; +using System.Data.Common; using System.Diagnostics; using System.Linq; using System.Runtime.CompilerServices; @@ -275,7 +276,7 @@ private IList DoQueryAndInitializeNonLazyCollections(ISessionImplementor session /// Should proxies be generated /// The loaded "row". /// - protected object LoadSingleRow(IDataReader resultSet, ISessionImplementor session, QueryParameters queryParameters, + protected object LoadSingleRow(DbDataReader resultSet, ISessionImplementor session, QueryParameters queryParameters, bool returnProxies) { int entitySpan = EntityPersisters.Length; @@ -322,7 +323,7 @@ internal static EntityKey GetOptionalObjectKey(QueryParameters queryParameters, } } - internal object GetRowFromResultSet(IDataReader resultSet, ISessionImplementor session, + internal object GetRowFromResultSet(DbDataReader resultSet, ISessionImplementor session, QueryParameters queryParameters, LockMode[] lockModeArray, EntityKey optionalObjectKey, IList hydratedObjects, EntityKey[] keys, bool returnProxies) @@ -331,7 +332,7 @@ internal object GetRowFromResultSet(IDataReader resultSet, ISessionImplementor s keys, returnProxies, null); } - internal object GetRowFromResultSet(IDataReader resultSet, ISessionImplementor session, + internal object GetRowFromResultSet(DbDataReader resultSet, ISessionImplementor session, QueryParameters queryParameters, LockMode[] lockModeArray, EntityKey optionalObjectKey, IList hydratedObjects, EntityKey[] keys, bool returnProxies, IResultTransformer forcedResultTransformer) @@ -381,7 +382,7 @@ internal object GetRowFromResultSet(IDataReader resultSet, ISessionImplementor s /// /// Read any collection elements contained in a single row of the result set /// - private void ReadCollectionElements(object[] row, IDataReader resultSet, ISessionImplementor session) + private void ReadCollectionElements(object[] row, DbDataReader resultSet, ISessionImplementor session) { //TODO: make this handle multiple collection roles! @@ -431,10 +432,9 @@ private IList DoQuery(ISessionImplementor session, QueryParameters queryParamete List hydratedObjects = entitySpan == 0 ? null : new List(entitySpan*10); - IDbCommand st = PrepareQueryCommand(queryParameters, false, session); + var st = PrepareQueryCommand(queryParameters, false, session); - IDataReader rs = GetResultSet(st, queryParameters.HasAutoDiscoverScalarTypes, queryParameters.Callable, selection, - session); + var rs = GetResultSet(st, queryParameters.HasAutoDiscoverScalarTypes, queryParameters.Callable, selection, session); // would be great to move all this below here into another method that could also be used // from the new scrolling stuff. @@ -642,7 +642,7 @@ internal void InitializeEntitiesAndCollections(IList hydratedObjects, object res private static void EndCollectionLoad(object resultSetId, ISessionImplementor session, ICollectionPersister collectionPersister) { //this is a query and we are loading multiple instances of the same collection role - session.PersistenceContext.LoadContexts.GetCollectionLoadContext((IDataReader)resultSetId).EndLoadingCollections( + session.PersistenceContext.LoadContexts.GetCollectionLoadContext((DbDataReader)resultSetId).EndLoadingCollections( collectionPersister); } @@ -691,7 +691,7 @@ protected virtual string[] ResultRowAliases /// This empty implementation merely returns its first argument. This is /// overridden by some subclasses. /// - protected virtual object GetResultColumnOrRow(object[] row, IResultTransformer resultTransformer, IDataReader rs, ISessionImplementor session) + protected virtual object GetResultColumnOrRow(object[] row, IResultTransformer resultTransformer, DbDataReader rs, ISessionImplementor session) { return row; } @@ -701,12 +701,11 @@ protected virtual bool[] IncludeInResultRow get { return null; } } - protected virtual object[] GetResultRow(Object[] row, IDataReader rs, ISessionImplementor session) + protected virtual object[] GetResultRow(Object[] row, DbDataReader rs, ISessionImplementor session) { return row; } - /// /// For missing objects associated by one-to-one with another object in the /// result set, register the fact that the the object is missing with the @@ -742,7 +741,7 @@ private void RegisterNonExists(EntityKey[] keys, ISessionImplementor session) /// Read one collection element from the current row of the ADO.NET result set /// private static void ReadCollectionElement(object optionalOwner, object optionalKey, ICollectionPersister persister, - ICollectionAliases descriptor, IDataReader rs, ISessionImplementor session) + ICollectionAliases descriptor, DbDataReader rs, ISessionImplementor session) { IPersistenceContext persistenceContext = session.PersistenceContext; @@ -819,7 +818,7 @@ internal void HandleEmptyCollections(object[] keys, object resultSetId, ISession Log.Debug("result set contains (possibly empty) collection: " + MessageHelper.CollectionInfoString(collectionPersisters[j], keys[i])); } - session.PersistenceContext.LoadContexts.GetCollectionLoadContext((IDataReader)resultSetId).GetLoadingCollection( + session.PersistenceContext.LoadContexts.GetCollectionLoadContext((DbDataReader)resultSetId).GetLoadingCollection( collectionPersisters[j], keys[i]); } } @@ -829,13 +828,13 @@ internal void HandleEmptyCollections(object[] keys, object resultSetId, ISession } /// - /// Read a row of EntityKeys from the IDataReader into the given array. + /// Read a row of EntityKeys from the DbDataReader into the given array. /// /// /// Warning: this method is side-effecty. If an id is given, don't bother going - /// to the IDataReader + /// to the DbDataReader /// - private EntityKey GetKeyFromResultSet(int i, IEntityPersister persister, object id, IDataReader rs, ISessionImplementor session) + private EntityKey GetKeyFromResultSet(int i, IEntityPersister persister, object id, DbDataReader rs, ISessionImplementor session) { object resultId; @@ -864,12 +863,12 @@ private EntityKey GetKeyFromResultSet(int i, IEntityPersister persister, object } /// - /// Check the version of the object in the IDataReader against + /// Check the version of the object in the DbDataReader against /// the object version in the session cache, throwing an exception /// if the version numbers are different. /// /// - private void CheckVersion(int i, IEntityPersister persister, object id, object entity, IDataReader rs, ISessionImplementor session) + private void CheckVersion(int i, IEntityPersister persister, object id, object entity, DbDataReader rs, ISessionImplementor session) { object version = session.PersistenceContext.GetEntry(entity).Version; @@ -891,12 +890,12 @@ private void CheckVersion(int i, IEntityPersister persister, object id, object e } /// - /// Resolve any ids for currently loaded objects, duplications within the IDataReader, - /// etc. Instantiate empty objects to be initialized from the IDataReader. Return an + /// Resolve any ids for currently loaded objects, duplications within the DbDataReader, + /// etc. Instantiate empty objects to be initialized from the DbDataReader. Return an /// array of objects (a row of results) and an array of booleans (by side-effect) that determine /// whether the corresponding object should be initialized /// - private object[] GetRow(IDataReader rs, ILoadable[] persisters, EntityKey[] keys, object optionalObject, + private object[] GetRow(DbDataReader rs, ILoadable[] persisters, EntityKey[] keys, object optionalObject, EntityKey optionalObjectKey, LockMode[] lockModes, IList hydratedObjects, ISessionImplementor session) { @@ -948,7 +947,7 @@ private object[] GetRow(IDataReader rs, ILoadable[] persisters, EntityKey[] keys /// /// The entity instance is already in the session cache /// - private void InstanceAlreadyLoaded(IDataReader rs, int i, IEntityPersister persister, EntityKey key, object obj, + private void InstanceAlreadyLoaded(DbDataReader rs, int i, IEntityPersister persister, EntityKey key, object obj, LockMode lockMode, ISessionImplementor session) { if (!persister.IsInstance(obj, session.EntityMode)) @@ -978,7 +977,7 @@ private void InstanceAlreadyLoaded(IDataReader rs, int i, IEntityPersister persi /// /// The entity instance is not in the session cache /// - private object InstanceNotYetLoaded(IDataReader dr, int i, ILoadable persister, EntityKey key, LockMode lockMode, + private object InstanceNotYetLoaded(DbDataReader dr, int i, ILoadable persister, EntityKey key, LockMode lockMode, string rowIdAlias, EntityKey optionalObjectKey, object optionalObject, IList hydratedObjects, ISessionImplementor session) { @@ -1017,11 +1016,11 @@ private bool IsEagerPropertyFetchEnabled(int i) } /// - /// Hydrate the state of an object from the SQL IDataReader, into + /// Hydrate the state of an object from the SQL DbDataReader, into /// an array of "hydrated" values (do not resolve associations yet), /// and pass the hydrated state to the session. /// - private void LoadFromResultSet(IDataReader rs, int i, object obj, string instanceClass, EntityKey key, + private void LoadFromResultSet(DbDataReader rs, int i, object obj, string instanceClass, EntityKey key, string rowIdAlias, LockMode lockMode, ILoadable rootPersister, ISessionImplementor session) { @@ -1076,9 +1075,9 @@ private void LoadFromResultSet(IDataReader rs, int i, object obj, string instanc } /// - /// Determine the concrete class of an instance for the IDataReader + /// Determine the concrete class of an instance for the DbDataReader /// - private string GetInstanceClass(IDataReader rs, int i, ILoadable persister, object id, ISessionImplementor session) + private string GetInstanceClass(DbDataReader rs, int i, ILoadable persister, object id, ISessionImplementor session) { if (persister.HasSubclasses) { @@ -1101,9 +1100,9 @@ private string GetInstanceClass(IDataReader rs, int i, ILoadable persister, obje } /// - /// Advance the cursor to the first required row of the IDataReader + /// Advance the cursor to the first required row of the DbDataReader /// - internal static void Advance(IDataReader rs, RowSelection selection) + internal static void Advance(DbDataReader rs, RowSelection selection) { int firstRow = GetFirstRow(selection); @@ -1177,24 +1176,24 @@ internal bool UseLimit(RowSelection selection, Dialect.Dialect dialect) } /// - /// Obtain an IDbCommand with all parameters pre-bound. Bind positional parameters, + /// Obtain an DbCommand with all parameters pre-bound. Bind positional parameters, /// named parameters, and limit parameters. /// /// - /// Creates an IDbCommand object and populates it with the values necessary to execute it against the + /// Creates an DbCommand object and populates it with the values necessary to execute it against the /// database to Load an Entity. /// - /// The to use for the IDbCommand. + /// The to use for the DbCommand. /// TODO: find out where this is used... /// The SessionImpl this Command is being prepared in. - /// A CommandWrapper wrapping an IDbCommand that is ready to be executed. - protected internal virtual IDbCommand PrepareQueryCommand(QueryParameters queryParameters, bool scroll, ISessionImplementor session) + /// A CommandWrapper wrapping an DbCommand that is ready to be executed. + protected internal virtual DbCommand PrepareQueryCommand(QueryParameters queryParameters, bool scroll, ISessionImplementor session) { ISqlCommand sqlCommand = CreateSqlCommand(queryParameters, session); SqlString sqlString = sqlCommand.Query; sqlCommand.ResetParametersIndexesForTheCommand(0); - IDbCommand command = session.Batcher.PrepareQueryCommand(CommandType.Text, sqlString, sqlCommand.ParameterTypes); + var command = session.Batcher.PrepareQueryCommand(CommandType.Text, sqlString, sqlCommand.ParameterTypes); try { @@ -1244,18 +1243,18 @@ internal static int GetMaxOrLimit(Dialect.Dialect dialect, RowSelection selectio } /// - /// Fetch a IDbCommand, call SetMaxRows and then execute it, - /// advance to the first result and return an SQL IDataReader + /// Fetch a DbCommand, call SetMaxRows and then execute it, + /// advance to the first result and return an SQL DbDataReader /// - /// The to execute. - /// The to apply to the and . + /// The to execute. + /// The to apply to the and . /// true if result types need to be auto-discovered by the loader; false otherwise. /// The to load in. /// - /// An IDataReader advanced to the first record in RowSelection. - protected IDataReader GetResultSet(IDbCommand st, bool autoDiscoverTypes, bool callable, RowSelection selection, ISessionImplementor session) + /// An DbDataReader advanced to the first record in RowSelection. + protected DbDataReader GetResultSet(DbCommand st, bool autoDiscoverTypes, bool callable, RowSelection selection, ISessionImplementor session) { - IDataReader rs = null; + DbDataReader rs = null; try { Log.Info(st.CommandText); @@ -1288,13 +1287,13 @@ protected IDataReader GetResultSet(IDbCommand st, bool autoDiscoverTypes, bool c } } - protected internal virtual void AutoDiscoverTypes(IDataReader rs) + protected internal virtual void AutoDiscoverTypes(DbDataReader rs) { throw new AssertionFailure("Auto discover types not supported in this loader"); } [MethodImpl(MethodImplOptions.Synchronized)] - private IDataReader WrapResultSet(IDataReader rs) + private DbDataReader WrapResultSet(DbDataReader rs) { // synchronized to avoid multi-thread access issues; defined as method synch to avoid // potential deadlock issues due to nature of code. @@ -1310,7 +1309,7 @@ private IDataReader WrapResultSet(IDataReader rs) } } - private ColumnNameCache RetreiveColumnNameToIndexCache(IDataReader rs) + private ColumnNameCache RetreiveColumnNameToIndexCache(DbDataReader rs) { if (_columnNameCache == null) { diff --git a/src/NHibernate/Param/AbstractExplicitParameterSpecification.cs b/src/NHibernate/Param/AbstractExplicitParameterSpecification.cs index dc69804f36f..83d8a57a70f 100644 --- a/src/NHibernate/Param/AbstractExplicitParameterSpecification.cs +++ b/src/NHibernate/Param/AbstractExplicitParameterSpecification.cs @@ -1,6 +1,6 @@ using System; using System.Collections.Generic; -using System.Data; +using System.Data.Common; using NHibernate.Engine; using NHibernate.SqlCommand; using NHibernate.Type; @@ -43,8 +43,8 @@ public int SourceColumn public abstract string RenderDisplayInfo(); public abstract IEnumerable GetIdsForBackTrack(IMapping sessionFactory); - public abstract void Bind(IDbCommand command, IList sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session); - public abstract void Bind(IDbCommand command, IList multiSqlQueryParametersList, int singleSqlParametersOffset, IList sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session); + public abstract void Bind(DbCommand command, IList sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session); + public abstract void Bind(DbCommand command, IList multiSqlQueryParametersList, int singleSqlParametersOffset, IList sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session); public abstract void SetEffectiveType(QueryParameters queryParameters); public abstract int GetSkipValue(QueryParameters queryParameters); diff --git a/src/NHibernate/Param/AggregatedIndexCollectionSelectorParameterSpecifications.cs b/src/NHibernate/Param/AggregatedIndexCollectionSelectorParameterSpecifications.cs index 113e9d14e18..1c48e7f3d6a 100644 --- a/src/NHibernate/Param/AggregatedIndexCollectionSelectorParameterSpecifications.cs +++ b/src/NHibernate/Param/AggregatedIndexCollectionSelectorParameterSpecifications.cs @@ -1,6 +1,6 @@ using System; using System.Collections.Generic; -using System.Data; +using System.Data.Common; using System.Text; using NHibernate.Engine; using NHibernate.SqlCommand; @@ -15,7 +15,7 @@ public AggregatedIndexCollectionSelectorParameterSpecifications(IList sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session) + public void Bind(DbCommand command, IList sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session) { throw new NotImplementedException(); } - public void Bind(IDbCommand command, IList multiSqlQueryParametersList, int singleSqlParametersOffset, IList sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session) + public void Bind(DbCommand command, IList multiSqlQueryParametersList, int singleSqlParametersOffset, IList sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session) { throw new NotImplementedException(); } diff --git a/src/NHibernate/Param/CollectionFilterKeyParameterSpecification.cs b/src/NHibernate/Param/CollectionFilterKeyParameterSpecification.cs index 5cab824e7ee..9740034e5a1 100644 --- a/src/NHibernate/Param/CollectionFilterKeyParameterSpecification.cs +++ b/src/NHibernate/Param/CollectionFilterKeyParameterSpecification.cs @@ -1,6 +1,6 @@ using System; using System.Collections.Generic; -using System.Data; +using System.Data.Common; using System.Linq; using NHibernate.Engine; using NHibernate.SqlCommand; @@ -31,7 +31,7 @@ public CollectionFilterKeyParameterSpecification(string collectionRole, IType ke #region IParameterSpecification Members - public void Bind(IDbCommand command, IList multiSqlQueryParametersList, int singleSqlParametersOffset, IList sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session) + public void Bind(DbCommand command, IList multiSqlQueryParametersList, int singleSqlParametersOffset, IList sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session) { IType type = keyType; object value = queryParameters.PositionalParameterValues[queryParameterPosition]; @@ -61,7 +61,7 @@ public IEnumerable GetIdsForBackTrack(IMapping sessionFactory) } } - public void Bind(IDbCommand command, IList sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session) + public void Bind(DbCommand command, IList sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session) { Bind(command, sqlQueryParametersList, 0, sqlQueryParametersList, queryParameters, session); } diff --git a/src/NHibernate/Param/CriteriaNamedParameterSpecification.cs b/src/NHibernate/Param/CriteriaNamedParameterSpecification.cs index 78224d51ec8..d92e4c86893 100644 --- a/src/NHibernate/Param/CriteriaNamedParameterSpecification.cs +++ b/src/NHibernate/Param/CriteriaNamedParameterSpecification.cs @@ -1,6 +1,6 @@ using System; using System.Collections.Generic; -using System.Data; +using System.Data.Common; using System.Linq; using NHibernate.Engine; using NHibernate.SqlCommand; @@ -21,12 +21,12 @@ public CriteriaNamedParameterSpecification(string name, IType expectedType) #region IParameterSpecification Members - public void Bind(IDbCommand command, IList sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session) + public void Bind(DbCommand command, IList sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session) { Bind(command, sqlQueryParametersList, 0, sqlQueryParametersList, queryParameters, session); } - public void Bind(IDbCommand command, IList multiSqlQueryParametersList, int singleSqlParametersOffset, IList sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session) + public void Bind(DbCommand command, IList multiSqlQueryParametersList, int singleSqlParametersOffset, IList sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session) { TypedValue typedValue = queryParameters.NamedParameters[name]; string backTrackId = GetIdsForBackTrack(session.Factory).First(); diff --git a/src/NHibernate/Param/DynamicFilterParameterSpecification.cs b/src/NHibernate/Param/DynamicFilterParameterSpecification.cs index bb8ccf65594..6eee9c6bbe0 100644 --- a/src/NHibernate/Param/DynamicFilterParameterSpecification.cs +++ b/src/NHibernate/Param/DynamicFilterParameterSpecification.cs @@ -1,7 +1,7 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Data; +using System.Data.Common; using System.Linq; using System.Xml; using NHibernate.Engine; @@ -35,12 +35,12 @@ public DynamicFilterParameterSpecification(string filterName, string parameterNa #region IParameterSpecification Members - public void Bind(IDbCommand command, IList sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session) + public void Bind(DbCommand command, IList sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session) { Bind(command, sqlQueryParametersList, 0, sqlQueryParametersList, queryParameters, session); } - public void Bind(IDbCommand command, IList multiSqlQueryParametersList, int singleSqlParametersOffset, IList sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session) + public void Bind(DbCommand command, IList multiSqlQueryParametersList, int singleSqlParametersOffset, IList sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session) { string backTrackId = GetIdsForBackTrack(session.Factory).First(); // just the first because IType suppose the oders in certain sequence @@ -194,22 +194,22 @@ public bool IsModified(object oldHydratedState, object currentState, bool[] chec return false; } - public object NullSafeGet(IDataReader rs, string[] names, ISessionImplementor session, object owner) + public object NullSafeGet(DbDataReader rs, string[] names, ISessionImplementor session, object owner) { throw new InvalidOperationException(); } - public object NullSafeGet(IDataReader rs, string name, ISessionImplementor session, object owner) + public object NullSafeGet(DbDataReader rs, string name, ISessionImplementor session, object owner) { throw new InvalidOperationException(); } - public void NullSafeSet(IDbCommand st, object value, int index, bool[] settable, ISessionImplementor session) + public void NullSafeSet(DbCommand st, object value, int index, bool[] settable, ISessionImplementor session) { throw new InvalidOperationException(); } - public void NullSafeSet(IDbCommand st, object value, int index, ISessionImplementor session) + public void NullSafeSet(DbCommand st, object value, int index, ISessionImplementor session) { var start = index; var positions = 0; @@ -233,7 +233,7 @@ public object DeepCopy(object val, EntityMode entityMode, ISessionFactoryImpleme throw new InvalidOperationException(); } - public object Hydrate(IDataReader rs, string[] names, ISessionImplementor session, object owner) + public object Hydrate(DbDataReader rs, string[] names, ISessionImplementor session, object owner) { throw new InvalidOperationException(); } diff --git a/src/NHibernate/Param/IParameterSpecification.cs b/src/NHibernate/Param/IParameterSpecification.cs index 6ddcba4420e..11a09753225 100644 --- a/src/NHibernate/Param/IParameterSpecification.cs +++ b/src/NHibernate/Param/IParameterSpecification.cs @@ -1,5 +1,5 @@ using System.Collections.Generic; -using System.Data; +using System.Data.Common; using NHibernate.Engine; using NHibernate.SqlCommand; using NHibernate.Type; @@ -7,7 +7,7 @@ namespace NHibernate.Param { /// - /// Maintains information relating to parameters which need to get bound into a . + /// Maintains information relating to parameters which need to get bound into a . /// public interface IParameterSpecification { @@ -18,14 +18,14 @@ public interface IParameterSpecification /// The list of Sql query parameter in the exact sequence they are present in the query. /// The defined values for the current query execution. /// The session against which the current execution is occuring. - void Bind(IDbCommand command, IList sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session); + void Bind(DbCommand command, IList sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session); /// /// Bind the appropriate value into the given command. /// /// The command into which the value should be bound. /// The parameter-list of the whole query of the command. - /// The offset from where start the list of in the given for the query where this was used. + /// The offset from where start the list of in the given for the query where this was used. /// The list of Sql query parameter in the exact sequence they are present in the query where this was used. /// The defined values for the query where this was used. /// The session against which the current execution is occuring. @@ -34,7 +34,7 @@ public interface IParameterSpecification /// If the first query in has 12 parameters (size of its SqlType array) the offset to bind all s of the second query in the /// is 12 (for the first query we are using from 0 to 11). /// - void Bind(IDbCommand command, IList multiSqlQueryParametersList, int singleSqlParametersOffset, IList sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session); + void Bind(DbCommand command, IList multiSqlQueryParametersList, int singleSqlParametersOffset, IList sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session); /// /// Get or set the type which we are expeting for a bind into this parameter based diff --git a/src/NHibernate/Param/NamedParameterSpecification.cs b/src/NHibernate/Param/NamedParameterSpecification.cs index 38f7df26e2d..dfd79c2f2af 100644 --- a/src/NHibernate/Param/NamedParameterSpecification.cs +++ b/src/NHibernate/Param/NamedParameterSpecification.cs @@ -1,6 +1,6 @@ using System; using System.Collections.Generic; -using System.Data; +using System.Data.Common; using System.Linq; using NHibernate.Engine; using NHibernate.SqlCommand; @@ -50,12 +50,12 @@ public override IEnumerable GetIdsForBackTrack(IMapping sessionFactory) } } - public override void Bind(IDbCommand command, IList sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session) + public override void Bind(DbCommand command, IList sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session) { Bind(command, sqlQueryParametersList, 0, sqlQueryParametersList, queryParameters, session); } - public override void Bind(IDbCommand command, IList multiSqlQueryParametersList, int singleSqlParametersOffset, IList sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session) + public override void Bind(DbCommand command, IList multiSqlQueryParametersList, int singleSqlParametersOffset, IList sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session) { TypedValue typedValue = queryParameters.NamedParameters[name]; string backTrackId = GetIdsForBackTrack(session.Factory).First(); // just the first because IType suppose the oders in certain sequence diff --git a/src/NHibernate/Param/ParametersBackTrackExtensions.cs b/src/NHibernate/Param/ParametersBackTrackExtensions.cs index 1d0459a8eb4..2977d1fc4e5 100644 --- a/src/NHibernate/Param/ParametersBackTrackExtensions.cs +++ b/src/NHibernate/Param/ParametersBackTrackExtensions.cs @@ -36,7 +36,7 @@ public static SqlType[] GetQueryParameterTypes(this IEnumerable typesSequence = from typeLocation in diff --git a/src/NHibernate/Param/PositionalParameterSpecification.cs b/src/NHibernate/Param/PositionalParameterSpecification.cs index 0fd3bf51a24..96e7b1abc5b 100644 --- a/src/NHibernate/Param/PositionalParameterSpecification.cs +++ b/src/NHibernate/Param/PositionalParameterSpecification.cs @@ -1,6 +1,6 @@ using System; using System.Collections.Generic; -using System.Data; +using System.Data.Common; using System.Linq; using NHibernate.Engine; using NHibernate.SqlCommand; @@ -50,12 +50,12 @@ public override IEnumerable GetIdsForBackTrack(IMapping sessionFactory) } } - public override void Bind(IDbCommand command, IList sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session) + public override void Bind(DbCommand command, IList sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session) { Bind(command, sqlQueryParametersList, 0, sqlQueryParametersList, queryParameters, session); } - public override void Bind(IDbCommand command, IList multiSqlQueryParametersList, int singleSqlParametersOffset, IList sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session) + public override void Bind(DbCommand command, IList multiSqlQueryParametersList, int singleSqlParametersOffset, IList sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session) { IType type = ExpectedType; object value = queryParameters.PositionalParameterValues[hqlPosition]; diff --git a/src/NHibernate/Param/QuerySkipParameterSpecification.cs b/src/NHibernate/Param/QuerySkipParameterSpecification.cs index f836966b433..2a47a3bb2e4 100644 --- a/src/NHibernate/Param/QuerySkipParameterSpecification.cs +++ b/src/NHibernate/Param/QuerySkipParameterSpecification.cs @@ -1,6 +1,6 @@ using System; using System.Collections.Generic; -using System.Data; +using System.Data.Common; using System.Linq; using NHibernate.Engine; using NHibernate.SqlCommand; @@ -25,12 +25,12 @@ public QuerySkipParameterSpecification() #region IParameterSpecification Members - public void Bind(IDbCommand command, IList sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session) + public void Bind(DbCommand command, IList sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session) { Bind(command, sqlQueryParametersList, 0, sqlQueryParametersList, queryParameters, session); } - public void Bind(IDbCommand command, IList multiSqlQueryParametersList, int singleSqlParametersOffset, IList sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session) + public void Bind(DbCommand command, IList multiSqlQueryParametersList, int singleSqlParametersOffset, IList sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session) { // The QuerySkipParameterSpecification is unique so we can use multiSqlQueryParametersList var effectiveParameterLocations = multiSqlQueryParametersList.GetEffectiveParameterLocations(limitParametersNameForThisQuery).ToArray(); diff --git a/src/NHibernate/Param/QueryTakeParameterSpecification.cs b/src/NHibernate/Param/QueryTakeParameterSpecification.cs index 322f5c92c8a..70369f45eb0 100644 --- a/src/NHibernate/Param/QueryTakeParameterSpecification.cs +++ b/src/NHibernate/Param/QueryTakeParameterSpecification.cs @@ -1,6 +1,6 @@ using System; using System.Collections.Generic; -using System.Data; +using System.Data.Common; using System.Linq; using NHibernate.Engine; using NHibernate.SqlCommand; @@ -25,12 +25,12 @@ public QueryTakeParameterSpecification() #region IParameterSpecification Members - public void Bind(IDbCommand command, IList sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session) + public void Bind(DbCommand command, IList sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session) { Bind(command, sqlQueryParametersList, 0, sqlQueryParametersList, queryParameters, session); } - public void Bind(IDbCommand command, IList multiSqlQueryParametersList, int singleSqlParametersOffset, IList sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session) + public void Bind(DbCommand command, IList multiSqlQueryParametersList, int singleSqlParametersOffset, IList sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session) { // The QueryTakeParameterSpecification is unique so we can use multiSqlQueryParametersList var effectiveParameterLocations = multiSqlQueryParametersList.GetEffectiveParameterLocations(limitParametersNameForThisQuery).ToArray(); diff --git a/src/NHibernate/Param/VersionTypeSeedParameterSpecification.cs b/src/NHibernate/Param/VersionTypeSeedParameterSpecification.cs index ca6d536750b..02a27c55963 100644 --- a/src/NHibernate/Param/VersionTypeSeedParameterSpecification.cs +++ b/src/NHibernate/Param/VersionTypeSeedParameterSpecification.cs @@ -1,6 +1,6 @@ using System; using System.Collections.Generic; -using System.Data; +using System.Data.Common; using System.Linq; using NHibernate.Engine; using NHibernate.SqlCommand; @@ -21,13 +21,13 @@ public VersionTypeSeedParameterSpecification(IVersionType type) #region IParameterSpecification Members - public void Bind(IDbCommand command, IList sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session) + public void Bind(DbCommand command, IList sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session) { int position = sqlQueryParametersList.GetEffectiveParameterLocations(IdBackTrack).Single(); // version parameter can't appear more than once type.NullSafeSet(command, type.Seed(session), position, session); } - public void Bind(IDbCommand command, IList multiSqlQueryParametersList, int singleSqlParametersOffset, IList sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session) + public void Bind(DbCommand command, IList multiSqlQueryParametersList, int singleSqlParametersOffset, IList sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session) { throw new NotSupportedException("Not supported for multiquery loader."); } diff --git a/src/NHibernate/Persister/Collection/AbstractCollectionPersister.cs b/src/NHibernate/Persister/Collection/AbstractCollectionPersister.cs index 6bf4d3c0937..288c018810f 100644 --- a/src/NHibernate/Persister/Collection/AbstractCollectionPersister.cs +++ b/src/NHibernate/Persister/Collection/AbstractCollectionPersister.cs @@ -708,16 +708,16 @@ public bool HasWhere } /// - /// Reads the Element from the IDataReader. The IDataReader will probably only contain + /// Reads the Element from the DbDataReader. The DbDataReader will probably only contain /// the id of the Element. /// /// See ReadElementIdentifier for an explanation of why this method will be depreciated. - public object ReadElement(IDataReader rs, object owner, string[] aliases, ISessionImplementor session) + public object ReadElement(DbDataReader rs, object owner, string[] aliases, ISessionImplementor session) { return ElementType.NullSafeGet(rs, aliases, session, owner); } - public object ReadIndex(IDataReader rs, string[] aliases, ISessionImplementor session) + public object ReadIndex(DbDataReader rs, string[] aliases, ISessionImplementor session) { object index = IndexType.NullSafeGet(rs, aliases, session, null); if (index == null) @@ -738,7 +738,7 @@ public object DecrementIndexByBase(object index) return index; } - public object ReadIdentifier(IDataReader rs, string alias, ISessionImplementor session) + public object ReadIdentifier(DbDataReader rs, string alias, ISessionImplementor session) { object id = IdentifierType.NullSafeGet(rs, alias, session, null); if (id == null) @@ -749,12 +749,12 @@ public object ReadIdentifier(IDataReader rs, string alias, ISessionImplementor s return id; } - public object ReadKey(IDataReader dr, string[] aliases, ISessionImplementor session) + public object ReadKey(DbDataReader dr, string[] aliases, ISessionImplementor session) { return KeyType.NullSafeGet(dr, aliases, session, null); } - protected int WriteKey(IDbCommand st, object id, int i, ISessionImplementor session) + protected int WriteKey(DbCommand st, object id, int i, ISessionImplementor session) { if (id == null) { @@ -765,13 +765,13 @@ protected int WriteKey(IDbCommand st, object id, int i, ISessionImplementor sess return i + keyColumnAliases.Length; } - protected int WriteElement(IDbCommand st, object elt, int i, ISessionImplementor session) + protected int WriteElement(DbCommand st, object elt, int i, ISessionImplementor session) { ElementType.NullSafeSet(st, elt, i, elementColumnIsSettable, session); return i + ArrayHelper.CountTrue(elementColumnIsSettable); } - protected int WriteIndex(IDbCommand st, object idx, int i, ISessionImplementor session) + protected int WriteIndex(DbCommand st, object idx, int i, ISessionImplementor session) { IndexType.NullSafeSet(st, IncrementIndexByBase(idx), i, indexColumnIsSettable, session); return i + ArrayHelper.CountTrue(indexColumnIsSettable); @@ -787,7 +787,7 @@ protected object IncrementIndexByBase(object index) return index; } - protected int WriteElementToWhere(IDbCommand st, object elt, int i, ISessionImplementor session) + protected int WriteElementToWhere(DbCommand st, object elt, int i, ISessionImplementor session) { if (elementIsPureFormula) { @@ -798,7 +798,7 @@ protected int WriteElementToWhere(IDbCommand st, object elt, int i, ISessionImpl return i + elementColumnAliases.Length; } - protected int WriteIndexToWhere(IDbCommand st, object index, int i, ISessionImplementor session) + protected int WriteIndexToWhere(DbCommand st, object index, int i, ISessionImplementor session) { if (indexContainsFormula) { @@ -809,7 +809,7 @@ protected int WriteIndexToWhere(IDbCommand st, object index, int i, ISessionImpl return i + indexColumnAliases.Length; } - protected int WriteIdentifier(IDbCommand st, object idx, int i, ISessionImplementor session) + protected int WriteIdentifier(DbCommand st, object idx, int i, ISessionImplementor session) { IdentifierType.NullSafeSet(st, idx, i, session); return i + 1; @@ -1047,11 +1047,9 @@ public void Remove(object id, ISessionImplementor session) IExpectation expectation = Expectations.AppropriateExpectation(DeleteAllCheckStyle); //bool callable = DeleteAllCallable; bool useBatch = expectation.CanBeBatched; - IDbCommand st = useBatch - ? session.Batcher.PrepareBatchCommand(SqlDeleteString.CommandType, SqlDeleteString.Text, - SqlDeleteString.ParameterTypes) - : session.Batcher.PrepareCommand(SqlDeleteString.CommandType, SqlDeleteString.Text, - SqlDeleteString.ParameterTypes); + var st = useBatch + ? session.Batcher.PrepareBatchCommand(SqlDeleteString.CommandType, SqlDeleteString.Text, SqlDeleteString.ParameterTypes) + : session.Batcher.PrepareCommand(SqlDeleteString.CommandType, SqlDeleteString.Text, SqlDeleteString.ParameterTypes); try { @@ -1182,7 +1180,7 @@ public void DeleteRows(IPersistentCollection collection, object id, ISessionImpl while (deletes.MoveNext()) { - IDbCommand st; + DbCommand st; IExpectation expectation = Expectations.AppropriateExpectation(deleteCheckStyle); //bool callable = DeleteCallable; @@ -1544,8 +1542,8 @@ public int GetSize(object key, ISessionImplementor session) } - IDbCommand st = session.Batcher.PrepareCommand(CommandType.Text, GenerateSelectSizeString(session), KeyType.SqlTypes(factory)); - IDataReader rs = null; + var st = session.Batcher.PrepareCommand(CommandType.Text, GenerateSelectSizeString(session), KeyType.SqlTypes(factory)); + DbDataReader rs = null; try { KeyType.NullSafeSet(st, key, 0, session); @@ -1583,8 +1581,8 @@ private bool Exists(object key, object indexOrElement, IType indexOrElementType, { List sqlTl = new List(KeyType.SqlTypes(factory)); sqlTl.AddRange(indexOrElementType.SqlTypes(factory)); - IDbCommand st = session.Batcher.PrepareCommand(CommandType.Text, sql, sqlTl.ToArray()); - IDataReader rs = null; + var st = session.Batcher.PrepareCommand(CommandType.Text, sql, sqlTl.ToArray()); + DbDataReader rs = null; try { KeyType.NullSafeSet(st, key, 0, session); @@ -1623,8 +1621,8 @@ public virtual object GetElementByIndex(object key, object index, ISessionImplem { List sqlTl = new List(KeyType.SqlTypes(factory)); sqlTl.AddRange(IndexType.SqlTypes(factory)); - IDbCommand st = session.Batcher.PrepareCommand(CommandType.Text, sqlSelectRowByIndexString, sqlTl.ToArray()); - IDataReader rs = null; + var st = session.Batcher.PrepareCommand(CommandType.Text, sqlSelectRowByIndexString, sqlTl.ToArray()); + DbDataReader rs = null; try { KeyType.NullSafeSet(st, key, 0, session); @@ -1997,11 +1995,9 @@ protected object PerformInsert(object ownerId, IPersistentCollection collection, { object entryId = null; int offset = 0; - IDbCommand st = useBatch - ? session.Batcher.PrepareBatchCommand(SqlInsertRowString.CommandType, SqlInsertRowString.Text, - SqlInsertRowString.ParameterTypes) - : session.Batcher.PrepareCommand(SqlInsertRowString.CommandType, SqlInsertRowString.Text, - SqlInsertRowString.ParameterTypes); + var st = useBatch + ? session.Batcher.PrepareBatchCommand(SqlInsertRowString.CommandType, SqlInsertRowString.Text, SqlInsertRowString.ParameterTypes) + : session.Batcher.PrepareCommand(SqlInsertRowString.CommandType, SqlInsertRowString.Text, SqlInsertRowString.ParameterTypes); try { //offset += expectation.Prepare(st, factory.ConnectionProvider.Driver); @@ -2136,7 +2132,7 @@ public object Entity get { return entry; } } - public void BindValues(IDbCommand cm) + public void BindValues(DbCommand cm) { int offset = 0; offset = persister.WriteKey(cm, ownerId, offset, session); diff --git a/src/NHibernate/Persister/Collection/BasicCollectionPersister.cs b/src/NHibernate/Persister/Collection/BasicCollectionPersister.cs index c9a0457a721..b8de412a1f4 100644 --- a/src/NHibernate/Persister/Collection/BasicCollectionPersister.cs +++ b/src/NHibernate/Persister/Collection/BasicCollectionPersister.cs @@ -1,6 +1,5 @@ using System; using System.Collections; -using System.Data; using System.Data.Common; using NHibernate.AdoNet; using NHibernate.Cache; @@ -162,7 +161,7 @@ protected override int DoUpdateRows(object id, IPersistentCollection collection, try { - IDbCommand st = null; + DbCommand st = null; IExpectation expectation = Expectations.AppropriateExpectation(UpdateCheckStyle); //bool callable = UpdateCallable; bool useBatch = expectation.CanBeBatched; diff --git a/src/NHibernate/Persister/Collection/ICollectionPersister.cs b/src/NHibernate/Persister/Collection/ICollectionPersister.cs index 70deada0267..e98fd4d68aa 100644 --- a/src/NHibernate/Persister/Collection/ICollectionPersister.cs +++ b/src/NHibernate/Persister/Collection/ICollectionPersister.cs @@ -1,5 +1,5 @@ using System.Collections.Generic; -using System.Data; +using System.Data.Common; using NHibernate.Cache; using NHibernate.Cache.Entry; using NHibernate.Collection; @@ -152,27 +152,27 @@ public interface ICollectionPersister bool HasCache { get; } /// - /// Read the key from a row of the + /// Read the key from a row of the /// - object ReadKey(IDataReader rs, string[] keyAliases, ISessionImplementor session); + object ReadKey(DbDataReader rs, string[] keyAliases, ISessionImplementor session); /// - /// Read the element from a row of the + /// Read the element from a row of the /// //TODO: the ReadElement should really be a parameterized TElement - object ReadElement(IDataReader rs, object owner, string[] columnAliases, ISessionImplementor session); + object ReadElement(DbDataReader rs, object owner, string[] columnAliases, ISessionImplementor session); /// - /// Read the index from a row of the + /// Read the index from a row of the /// //TODO: the ReadIndex should really be a parameterized TIndex - object ReadIndex(IDataReader rs, string[] columnAliases, ISessionImplementor session); + object ReadIndex(DbDataReader rs, string[] columnAliases, ISessionImplementor session); /// - /// Read the identifier from a row of the + /// Read the identifier from a row of the /// //TODO: the ReadIdentifier should really be a parameterized TIdentifier - object ReadIdentifier(IDataReader rs, string columnAlias, ISessionImplementor session); + object ReadIdentifier(DbDataReader rs, string columnAlias, ISessionImplementor session); string GetManyToManyFilterFragment(string alias, IDictionary enabledFilters); diff --git a/src/NHibernate/Persister/Collection/OneToManyPersister.cs b/src/NHibernate/Persister/Collection/OneToManyPersister.cs index e422fafb718..9f3914f6983 100644 --- a/src/NHibernate/Persister/Collection/OneToManyPersister.cs +++ b/src/NHibernate/Persister/Collection/OneToManyPersister.cs @@ -1,7 +1,6 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Data; using System.Data.Common; using System.Text; using NHibernate.AdoNet; @@ -186,7 +185,7 @@ protected override int DoUpdateRows(object id, IPersistentCollection collection, { if (collection.NeedsUpdating(entry, i, ElementType)) { - IDbCommand st = null; + DbCommand st = null; // will still be issued when it used to be null if (useBatch) { @@ -247,7 +246,7 @@ protected override int DoUpdateRows(object id, IPersistentCollection collection, { if (collection.NeedsUpdating(entry, i, ElementType)) { - IDbCommand st = null; + DbCommand st = null; if (useBatch) { st = session.Batcher.PrepareBatchCommand(SqlInsertRowString.CommandType, sql.Text, diff --git a/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs b/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs index 5eb4a55d18a..f817f5647d9 100644 --- a/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs +++ b/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs @@ -104,7 +104,7 @@ public object Entity get { return entity; } } - public virtual void BindValues(IDbCommand ps) + public virtual void BindValues(DbCommand ps) { entityPersister.Dehydrate(null, fields, notNull, entityPersister.propertyColumnInsertable, 0, ps, session); } @@ -1280,8 +1280,8 @@ private object InitializeLazyPropertiesFromDatastore(string fieldName, object en try { object result = null; - IDbCommand ps = null; - IDataReader rs = null; + DbCommand ps = null; + DbDataReader rs = null; try { SqlString lazySelect = SQLLazySelectString; @@ -1456,8 +1456,8 @@ public object[] GetDatabaseSnapshot(object id, ISessionImplementor session) using (new SessionIdLoggingContext(session.SessionId)) try { - IDbCommand st = session.Batcher.PrepareCommand(CommandType.Text, SQLSnapshotSelectString, IdentifierType.SqlTypes(factory)); - IDataReader rs = null; + var st = session.Batcher.PrepareCommand(CommandType.Text, SQLSnapshotSelectString, IdentifierType.SqlTypes(factory)); + DbDataReader rs = null; try { IdentifierType.NullSafeSet(st, id, 0, session); @@ -1657,7 +1657,7 @@ public object ForceVersionIncrement(object id, object currentVersion, ISessionIm SqlCommandInfo versionIncrementCommand = GenerateVersionIncrementUpdateString(); try { - IDbCommand st = session.Batcher.PrepareCommand(versionIncrementCommand.CommandType, versionIncrementCommand.Text, versionIncrementCommand.ParameterTypes); + var st = session.Batcher.PrepareCommand(versionIncrementCommand.CommandType, versionIncrementCommand.Text, versionIncrementCommand.ParameterTypes); try { VersionType.NullSafeSet(st, nextVersion, 0, session); @@ -1711,8 +1711,8 @@ public object GetCurrentVersion(object id, ISessionImplementor session) using(new SessionIdLoggingContext(session.SessionId)) try { - IDbCommand st = session.Batcher.PrepareQueryCommand(CommandType.Text, VersionSelectString, IdentifierType.SqlTypes(Factory)); - IDataReader rs = null; + var st = session.Batcher.PrepareQueryCommand(CommandType.Text, VersionSelectString, IdentifierType.SqlTypes(Factory)); + DbDataReader rs = null; try { IdentifierType.NullSafeSet(st, id, 0, session); @@ -2206,7 +2206,7 @@ protected IUniqueEntityLoader CreateEntityLoader(LockMode lockMode) return CreateEntityLoader(lockMode, new CollectionHelper.EmptyMapClass()); } - protected bool Check(int rows, object id, int tableNumber, IExpectation expectation, IDbCommand statement) + protected bool Check(int rows, object id, int tableNumber, IExpectation expectation, DbCommand statement) { try { @@ -2427,14 +2427,14 @@ protected virtual SqlCommandInfo GenerateDeleteString(int j) return deleteBuilder.ToSqlCommandInfo(); } - protected int Dehydrate(object id, object[] fields, bool[] includeProperty, bool[][] includeColumns, int j, IDbCommand st, ISessionImplementor session) + protected int Dehydrate(object id, object[] fields, bool[] includeProperty, bool[][] includeColumns, int j, DbCommand st, ISessionImplementor session) { return Dehydrate(id, fields, null, includeProperty, includeColumns, j, st, session, 0); } /// Marshall the fields of a persistent instance to a prepared statement protected int Dehydrate(object id, object[] fields, object rowId, bool[] includeProperty, bool[][] includeColumns, int table, - IDbCommand statement, ISessionImplementor session, int index) + DbCommand statement, ISessionImplementor session, int index) { if (log.IsDebugEnabled) { @@ -2481,7 +2481,7 @@ protected int Dehydrate(object id, object[] fields, object rowId, bool[] include /// Unmarshall the fields of a persistent instance from a result set, /// without resolving associations or collections /// - public object[] Hydrate(IDataReader rs, object id, object obj, ILoadable rootLoadable, + public object[] Hydrate(DbDataReader rs, object id, object obj, ILoadable rootLoadable, string[][] suffixedPropertyColumns, bool allProperties, ISessionImplementor session) { if (log.IsDebugEnabled) @@ -2492,8 +2492,8 @@ public object[] Hydrate(IDataReader rs, object id, object obj, ILoadable rootLoa AbstractEntityPersister rootPersister = (AbstractEntityPersister)rootLoadable; bool hasDeferred = rootPersister.HasSequentialSelect; - IDbCommand sequentialSelect = null; - IDataReader sequentialResultSet = null; + DbCommand sequentialSelect = null; + DbDataReader sequentialResultSet = null; bool sequentialSelectEmpty = false; using (new SessionIdLoggingContext(session.SessionId)) try @@ -2558,7 +2558,7 @@ public object[] Hydrate(IDataReader rs, object id, object obj, ILoadable rootLoa } else { - IDataReader propertyResultSet = propertyIsDeferred ? sequentialResultSet : rs; + var propertyResultSet = propertyIsDeferred ? sequentialResultSet : rs; string[] cols = propertyIsDeferred ? propertyColumnAliases[i] : suffixedPropertyColumns[i]; values[i] = types[i].Hydrate(propertyResultSet, cols, session, obj); } @@ -2671,9 +2671,9 @@ protected void Insert(object id, object[] fields, bool[] notNull, int j, try { // Render the SQL query - IDbCommand insertCmd = useBatch - ? session.Batcher.PrepareBatchCommand(sql.CommandType, sql.Text, sql.ParameterTypes) - : session.Batcher.PrepareCommand(sql.CommandType, sql.Text, sql.ParameterTypes); + var insertCmd = useBatch + ? session.Batcher.PrepareBatchCommand(sql.CommandType, sql.Text, sql.ParameterTypes) + : session.Batcher.PrepareCommand(sql.CommandType, sql.Text, sql.ParameterTypes); try { @@ -2783,9 +2783,9 @@ protected bool Update(object id, object[] fields, object[] oldFields, object row try { int index = 0; - IDbCommand statement = useBatch - ? session.Batcher.PrepareBatchCommand(sql.CommandType, sql.Text, sql.ParameterTypes) - : session.Batcher.PrepareCommand(sql.CommandType, sql.Text, sql.ParameterTypes); + var statement = useBatch + ? session.Batcher.PrepareBatchCommand(sql.CommandType, sql.Text, sql.ParameterTypes) + : session.Batcher.PrepareCommand(sql.CommandType, sql.Text, sql.ParameterTypes); try { //index += expectation.Prepare(statement, factory.ConnectionProvider.Driver); @@ -2913,15 +2913,9 @@ public void Delete(object id, object version, int j, object obj, SqlCommandInfo try { int index = 0; - IDbCommand statement; - if (useBatch) - { - statement = session.Batcher.PrepareBatchCommand(sql.CommandType, sql.Text, sql.ParameterTypes); - } - else - { - statement = session.Batcher.PrepareCommand(sql.CommandType, sql.Text, sql.ParameterTypes); - } + var statement = useBatch + ? session.Batcher.PrepareBatchCommand(sql.CommandType, sql.Text, sql.ParameterTypes) + : session.Batcher.PrepareCommand(sql.CommandType, sql.Text, sql.ParameterTypes); try { @@ -4131,9 +4125,8 @@ private void ProcessGeneratedPropertiesWithGeneratedSql(object id, object entity using (new SessionIdLoggingContext(session.SessionId)) try { - IDbCommand cmd = - session.Batcher.PrepareQueryCommand(CommandType.Text, selectionSQL, IdentifierType.SqlTypes(Factory)); - IDataReader rs = null; + var cmd = session.Batcher.PrepareQueryCommand(CommandType.Text, selectionSQL, IdentifierType.SqlTypes(Factory)); + DbDataReader rs = null; try { IdentifierType.NullSafeSet(cmd, id, 0, session); @@ -4239,8 +4232,8 @@ public virtual object[] GetNaturalIdentifierSnapshot(object id, ISessionImplemen using (new SessionIdLoggingContext(session.SessionId)) try { - IDbCommand ps = session.Batcher.PrepareCommand(CommandType.Text, sql, IdentifierType.SqlTypes(factory)); - IDataReader rs = null; + var ps = session.Batcher.PrepareCommand(CommandType.Text, sql, IdentifierType.SqlTypes(factory)); + DbDataReader rs = null; try { IdentifierType.NullSafeSet(ps, id, 0, session); diff --git a/src/NHibernate/Persister/Entity/ILoadable.cs b/src/NHibernate/Persister/Entity/ILoadable.cs index 09712286e82..4146c6aea50 100644 --- a/src/NHibernate/Persister/Entity/ILoadable.cs +++ b/src/NHibernate/Persister/Entity/ILoadable.cs @@ -1,6 +1,6 @@ using NHibernate.Type; using NHibernate.Engine; -using System.Data; +using System.Data.Common; namespace NHibernate.Persister.Entity { @@ -68,7 +68,7 @@ public interface ILoadable : IEntityPersister /// /// Retrieve property values from one row of a result set /// - object[] Hydrate(IDataReader rs, object id, object obj, ILoadable rootLoadable, string[][] suffixedPropertyColumns, + object[] Hydrate(DbDataReader rs, object id, object obj, ILoadable rootLoadable, string[][] suffixedPropertyColumns, bool allProperties, ISessionImplementor session); } } diff --git a/src/NHibernate/SqlCommand/ISqlStringBuilder.cs b/src/NHibernate/SqlCommand/ISqlStringBuilder.cs index 0063fb5b905..f0f36c6145c 100644 --- a/src/NHibernate/SqlCommand/ISqlStringBuilder.cs +++ b/src/NHibernate/SqlCommand/ISqlStringBuilder.cs @@ -6,7 +6,7 @@ public interface ISqlStringBuilder /// /// Builds a SqlString from the internal data. /// - /// A valid SqlString that can be converted into an IDbCommand + /// A valid SqlString that can be converted into an DbCommand SqlString ToSqlString(); } } \ No newline at end of file diff --git a/src/NHibernate/SqlCommand/SqlCommandImpl.cs b/src/NHibernate/SqlCommand/SqlCommandImpl.cs index 8ad7f7fe2ff..7821e16c3e8 100644 --- a/src/NHibernate/SqlCommand/SqlCommandImpl.cs +++ b/src/NHibernate/SqlCommand/SqlCommandImpl.cs @@ -1,6 +1,6 @@ using System; using System.Collections.Generic; -using System.Data; +using System.Data.Common; using System.Linq; using NHibernate.Engine; using NHibernate.Param; @@ -15,11 +15,11 @@ public interface ISqlCommand QueryParameters QueryParameters { get; } /// - /// re-set the index of each parameter in the final command. + /// re-set the index of each parameter in the final command. /// - /// The offset from where start the list of , in the given command, for the this . + /// The offset from where start the list of , in the given command, for the this . /// - /// Suppose the final command is composed by two queries. The for the first query is zero. + /// Suppose the final command is composed by two queries. The for the first query is zero. /// If the first query command has 12 parameters (size of its SqlType array) the offset to bind all s, of the second query in the /// command, is 12 (for the first query we are using from 0 to 11). /// @@ -33,14 +33,14 @@ public interface ISqlCommand /// /// The command into which the value should be bound. /// The parameter-list of the whole query of the command. - /// The offset from where start the list of , in the given , for the this . + /// The offset from where start the list of , in the given , for the this . /// The session against which the current execution is occurring. /// /// Suppose the is composed by two queries. The for the first query is zero. /// If the first query in has 12 parameters (size of its SqlType array) the offset to bind all s, of the second query in the /// , is 12 (for the first query we are using from 0 to 11). /// - void Bind(IDbCommand command, IList commandQueryParametersList, int singleSqlParametersOffset, ISessionImplementor session); + void Bind(DbCommand command, IList commandQueryParametersList, int singleSqlParametersOffset, ISessionImplementor session); /// /// Bind the appropriate value into the given command. @@ -49,9 +49,9 @@ public interface ISqlCommand /// The session against which the current execution is occurring. /// /// Use this method when the contains just 'this' instance of . - /// Use the overload when the contains more instances of . + /// Use the overload when the contains more instances of . /// - void Bind(IDbCommand command, ISessionImplementor session); + void Bind(DbCommand command, ISessionImplementor session); } public class SqlCommandImpl : ISqlCommand @@ -104,8 +104,7 @@ public void ResetParametersIndexesForTheCommand(int singleSqlParametersOffset) { throw new AssertionFailure("singleSqlParametersOffset < 0 - this indicate a bug in NHibernate "); } - - // due to IType.NullSafeSet(System.Data.IDbCommand , object, int, ISessionImplementor) the SqlType[] is supposed to be in a certain sequence. + // due to IType.NullSafeSet(DbCommand , object, int, ISessionImplementor) the SqlType[] is supposed to be in a certain sequence. // this mean that found the first location of a parameter for the IType span, the others are in sequence foreach (IParameterSpecification specification in Specifications) { @@ -131,9 +130,9 @@ public void ResetParametersIndexesForTheCommand(int singleSqlParametersOffset) /// /// The command into which the value should be bound. /// The parameter-list of the whole query of the command. - /// The offset from where start the list of , in the given , for the this . + /// The offset from where start the list of , in the given , for the this . /// The session against which the current execution is occuring. - public void Bind(IDbCommand command, IList commandQueryParametersList, int singleSqlParametersOffset, ISessionImplementor session) + public void Bind(DbCommand command, IList commandQueryParametersList, int singleSqlParametersOffset, ISessionImplementor session) { foreach (IParameterSpecification parameterSpecification in Specifications) { @@ -148,9 +147,9 @@ public void Bind(IDbCommand command, IList commandQueryParametersList /// The session against which the current execution is occuring. /// /// Use this method when the contains just 'this' instance of . - /// Use the overload when the contains more instances of . + /// Use the overload when the contains more instances of . /// - public void Bind(IDbCommand command, ISessionImplementor session) + public void Bind(DbCommand command, ISessionImplementor session) { foreach (IParameterSpecification parameterSpecification in Specifications) { diff --git a/src/NHibernate/SqlTypes/AnsiStringFixedLengthSqlType.cs b/src/NHibernate/SqlTypes/AnsiStringFixedLengthSqlType.cs index 8cc4f046ac3..4046999854e 100644 --- a/src/NHibernate/SqlTypes/AnsiStringFixedLengthSqlType.cs +++ b/src/NHibernate/SqlTypes/AnsiStringFixedLengthSqlType.cs @@ -1,16 +1,17 @@ using System; using System.Data; +using System.Data.Common; namespace NHibernate.SqlTypes { /// /// Describes the details of a with the - /// information required to to generate an . + /// information required to to generate an . /// /// - /// This can store the length of the string that the can hold. + /// This can store the length of the string that the can hold. /// If no value is provided for the length then the Driver is responsible for - /// setting the properties on the correctly. + /// setting the properties on the correctly. /// [Serializable] public class AnsiStringFixedLengthSqlType : SqlType @@ -25,7 +26,7 @@ public AnsiStringFixedLengthSqlType() : base(DbType.AnsiStringFixedLength) /// /// Initializes a new instance of the class. /// - /// The length of the string the should hold. + /// The length of the string the should hold. public AnsiStringFixedLengthSqlType(int length) : base(DbType.AnsiStringFixedLength, length) { } diff --git a/src/NHibernate/SqlTypes/AnsiStringSqlType.cs b/src/NHibernate/SqlTypes/AnsiStringSqlType.cs index 414d138a396..33447461ce2 100644 --- a/src/NHibernate/SqlTypes/AnsiStringSqlType.cs +++ b/src/NHibernate/SqlTypes/AnsiStringSqlType.cs @@ -1,16 +1,17 @@ using System; using System.Data; +using System.Data.Common; namespace NHibernate.SqlTypes { /// /// Describes the details of a with the - /// information required to generate an . + /// information required to generate an . /// /// - /// This can store the length of the string that the can hold. + /// This can store the length of the string that the can hold. /// If no value is provided for the length then the Driver is responsible for - /// setting the properties on the correctly. + /// setting the properties on the correctly. /// [Serializable] public class AnsiStringSqlType : SqlType @@ -25,7 +26,7 @@ public AnsiStringSqlType() : base(DbType.AnsiString) /// /// Initializes a new instance of the class. /// - /// The length of the string the should hold. + /// The length of the string the should hold. public AnsiStringSqlType(int length) : base(DbType.AnsiString, length) { } diff --git a/src/NHibernate/SqlTypes/BinaryBlobSqlType.cs b/src/NHibernate/SqlTypes/BinaryBlobSqlType.cs index 16faea47b8b..7421ef1fad7 100644 --- a/src/NHibernate/SqlTypes/BinaryBlobSqlType.cs +++ b/src/NHibernate/SqlTypes/BinaryBlobSqlType.cs @@ -1,22 +1,23 @@ using System; using System.Data; +using System.Data.Common; namespace NHibernate.SqlTypes { /// /// Describes the details of a that is stored in /// a BLOB column with the information required to generate - /// an . + /// an . /// /// ///

- /// This can store the length of the binary data that the can hold. + /// This can store the length of the binary data that the can hold. /// If no value is provided for the length then the Driver is responsible for - /// setting the properties on the correctly. + /// setting the properties on the correctly. ///

///

/// This is only needed by DataProviders (SqlClient) that need to specify a Size for the - /// IDbDataParameter. Most DataProvider(Oralce) don't need to set the Size so a + /// DbParameter. Most DataProvider(Oralce) don't need to set the Size so a /// BinarySqlType would work just fine. ///

///
diff --git a/src/NHibernate/SqlTypes/BinarySqlType.cs b/src/NHibernate/SqlTypes/BinarySqlType.cs index 1dc0b7fa4b6..f9757bc0d84 100644 --- a/src/NHibernate/SqlTypes/BinarySqlType.cs +++ b/src/NHibernate/SqlTypes/BinarySqlType.cs @@ -1,16 +1,17 @@ using System; using System.Data; +using System.Data.Common; namespace NHibernate.SqlTypes { /// /// Describes the details of a with the - /// information required to to generate an . + /// information required to to generate an . /// /// - /// This can store the binary data that the can hold. + /// This can store the binary data that the can hold. /// If no value is provided for the length then the Driver is responsible for - /// setting the properties on the correctly. + /// setting the properties on the correctly. /// [Serializable] public class BinarySqlType : SqlType @@ -25,7 +26,7 @@ public BinarySqlType() : base(DbType.Binary) /// /// Initializes a new instance of the class. /// - /// The length of the binary data the should hold + /// The length of the binary data the should hold public BinarySqlType(int length) : base(DbType.Binary, length) { } diff --git a/src/NHibernate/SqlTypes/SqlType.cs b/src/NHibernate/SqlTypes/SqlType.cs index dbee5754147..23eaee6fed5 100644 --- a/src/NHibernate/SqlTypes/SqlType.cs +++ b/src/NHibernate/SqlTypes/SqlType.cs @@ -1,5 +1,6 @@ using System; using System.Data; +using System.Data.Common; using System.Text; namespace NHibernate.SqlTypes @@ -12,7 +13,7 @@ namespace NHibernate.SqlTypes /// ///

/// The uses the SqlType to get enough - /// information to create an . + /// information to create an . ///

///

/// The use the SqlType to convert the diff --git a/src/NHibernate/SqlTypes/StringClobSqlType.cs b/src/NHibernate/SqlTypes/StringClobSqlType.cs index e7bc9cd6a46..b1b0788310a 100644 --- a/src/NHibernate/SqlTypes/StringClobSqlType.cs +++ b/src/NHibernate/SqlTypes/StringClobSqlType.cs @@ -1,22 +1,23 @@ using System; using System.Data; +using System.Data.Common; namespace NHibernate.SqlTypes { ///

/// Describes the details of a that is stored in /// a CLOB column with the information required to generate - /// an . + /// an . /// /// ///

- /// This can store the length of the binary data that the can hold. + /// This can store the length of the binary data that the can hold. /// If no value is provided for the length then the Driver is responsible for - /// setting the properties on the correctly. + /// setting the properties on the correctly. ///

///

/// This is only needed by DataProviders (SqlClient) that need to specify a Size for the - /// IDbDataParameter. Most DataProvider(Oralce) don't need to set the Size so a + /// DbParameter. Most DataProvider(Oralce) don't need to set the Size so a /// StringSqlType would work just fine. ///

///
@@ -34,7 +35,7 @@ public StringClobSqlType() /// /// Initializes a new instance of the class. /// - /// The length of the string the should hold. + /// The length of the string the should hold. public StringClobSqlType(int length) : base(length) { } diff --git a/src/NHibernate/SqlTypes/StringFixedLengthSqlType.cs b/src/NHibernate/SqlTypes/StringFixedLengthSqlType.cs index 7b0d56b0f5a..0af61094cbb 100644 --- a/src/NHibernate/SqlTypes/StringFixedLengthSqlType.cs +++ b/src/NHibernate/SqlTypes/StringFixedLengthSqlType.cs @@ -1,16 +1,17 @@ using System; using System.Data; +using System.Data.Common; namespace NHibernate.SqlTypes { /// /// Describes the details of a with the - /// information required to to generate an . + /// information required to to generate an . /// /// - /// This can store the length of the string that the can hold. + /// This can store the length of the string that the can hold. /// If no value is provided for the length then the Driver is responsible for - /// setting the properties on the correctly. + /// setting the properties on the correctly. /// [Serializable] public class StringFixedLengthSqlType : SqlType @@ -25,7 +26,7 @@ public StringFixedLengthSqlType() : base(DbType.StringFixedLength) /// /// Initializes a new instance of the class. /// - /// The length of the string the should hold. + /// The length of the string the should hold. public StringFixedLengthSqlType(int length) : base(DbType.StringFixedLength, length) { } diff --git a/src/NHibernate/SqlTypes/StringSqlType.cs b/src/NHibernate/SqlTypes/StringSqlType.cs index 6ee0a2e3f2c..dfaf98500b6 100644 --- a/src/NHibernate/SqlTypes/StringSqlType.cs +++ b/src/NHibernate/SqlTypes/StringSqlType.cs @@ -1,16 +1,17 @@ using System; using System.Data; +using System.Data.Common; namespace NHibernate.SqlTypes { /// /// Describes the details of a with the - /// information required to generate an . + /// information required to generate an . /// /// - /// This can store the length of the string that the can hold. + /// This can store the length of the string that the can hold. /// If no value is provided for the length then the Driver is responsible for - /// setting the properties on the correctly. + /// setting the properties on the correctly. /// [Serializable] public class StringSqlType : SqlType @@ -25,7 +26,7 @@ public StringSqlType() : base(DbType.String) /// /// Initializes a new instance of the class. /// - /// The length of the string the should hold. + /// The length of the string the should hold. public StringSqlType(int length) : base(DbType.String, length) { } diff --git a/src/NHibernate/Tool/hbm2ddl/DatabaseMetadata.cs b/src/NHibernate/Tool/hbm2ddl/DatabaseMetadata.cs index e7f6cebb88c..50a96ebc27d 100644 --- a/src/NHibernate/Tool/hbm2ddl/DatabaseMetadata.cs +++ b/src/NHibernate/Tool/hbm2ddl/DatabaseMetadata.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using System.Data; using System.Data.Common; @@ -110,10 +109,10 @@ private void InitSequences(DbConnection connection, Dialect.Dialect dialect) string sql = dialect.QuerySequencesString; if (sql != null) { - using (IDbCommand statement = connection.CreateCommand()) + using (var statement = connection.CreateCommand()) { statement.CommandText = sql; - using (IDataReader rs = statement.ExecuteReader()) + using (var rs = statement.ExecuteReader()) { while (rs.Read()) sequences.Add(((string) rs[0]).ToLower().Trim()); diff --git a/src/NHibernate/Tool/hbm2ddl/IConnectionHelper.cs b/src/NHibernate/Tool/hbm2ddl/IConnectionHelper.cs index 6238662c7bb..30882900c91 100644 --- a/src/NHibernate/Tool/hbm2ddl/IConnectionHelper.cs +++ b/src/NHibernate/Tool/hbm2ddl/IConnectionHelper.cs @@ -1,4 +1,3 @@ -using System.Data; using System.Data.Common; namespace NHibernate.Tool.hbm2ddl diff --git a/src/NHibernate/Tool/hbm2ddl/ManagedProviderConnectionHelper.cs b/src/NHibernate/Tool/hbm2ddl/ManagedProviderConnectionHelper.cs index 8b306aadd2d..9d45c84d810 100644 --- a/src/NHibernate/Tool/hbm2ddl/ManagedProviderConnectionHelper.cs +++ b/src/NHibernate/Tool/hbm2ddl/ManagedProviderConnectionHelper.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using System.Data; using System.Data.Common; using NHibernate.Connection; @@ -23,7 +22,7 @@ public ManagedProviderConnectionHelper(IDictionary cfgProperties public void Prepare() { connectionProvider = ConnectionProviderFactory.NewConnectionProvider(cfgProperties); - connection = (DbConnection) connectionProvider.GetConnection(); + connection = connectionProvider.GetConnection(); } public DbConnection Connection diff --git a/src/NHibernate/Tool/hbm2ddl/SchemaExport.cs b/src/NHibernate/Tool/hbm2ddl/SchemaExport.cs index 9b5459d8058..742653c698b 100644 --- a/src/NHibernate/Tool/hbm2ddl/SchemaExport.cs +++ b/src/NHibernate/Tool/hbm2ddl/SchemaExport.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Data; +using System.Data.Common; using System.IO; using NHibernate.AdoNet.Util; @@ -162,7 +163,7 @@ public void Drop(TextWriter exportOutput, bool execute) } private void Execute(Action scriptAction, bool execute, bool throwOnError, TextWriter exportOutput, - IDbCommand statement, string sql) + DbCommand statement, string sql) { Initialize(); try @@ -198,7 +199,7 @@ private void Execute(Action scriptAction, bool execute, bool throwOnErro } } - private void ExecuteSql(IDbCommand cmd, string sql) + private void ExecuteSql(DbCommand cmd, string sql) { if (dialect.SupportsSqlBatches) { @@ -237,7 +238,7 @@ private void ExecuteSql(IDbCommand cmd, string sql) /// This overload is provided mainly to enable use of in memory databases. /// It does NOT close the given connection! ///
- public void Execute(bool useStdOut, bool execute, bool justDrop, IDbConnection connection, + public void Execute(bool useStdOut, bool execute, bool justDrop, DbConnection connection, TextWriter exportOutput) { if (useStdOut) @@ -250,11 +251,11 @@ public void Execute(bool useStdOut, bool execute, bool justDrop, IDbConnection c } } - public void Execute(Action scriptAction, bool execute, bool justDrop, IDbConnection connection, + public void Execute(Action scriptAction, bool execute, bool justDrop, DbConnection connection, TextWriter exportOutput) { Initialize(); - IDbCommand statement = null; + DbCommand statement = null; if (execute && connection == null) { @@ -338,7 +339,7 @@ public void Execute(Action scriptAction, bool execute, bool justDrop) public void Execute(Action scriptAction, bool execute, bool justDrop, TextWriter exportOutput) { Initialize(); - IDbConnection connection = null; + DbConnection connection = null; TextWriter fileOutput = exportOutput; IConnectionProvider connectionProvider = null; diff --git a/src/NHibernate/Tool/hbm2ddl/SchemaUpdate.cs b/src/NHibernate/Tool/hbm2ddl/SchemaUpdate.cs index 90649848665..6224e13e2d0 100644 --- a/src/NHibernate/Tool/hbm2ddl/SchemaUpdate.cs +++ b/src/NHibernate/Tool/hbm2ddl/SchemaUpdate.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Data; using System.Data.Common; using NHibernate.Cfg; using NHibernate.Util; @@ -146,7 +145,7 @@ public void Execute(Action scriptAction, bool doUpdate) } DbConnection connection; - IDbCommand stmt = null; + DbCommand stmt = null; exceptions.Clear(); diff --git a/src/NHibernate/Tool/hbm2ddl/SchemaValidator.cs b/src/NHibernate/Tool/hbm2ddl/SchemaValidator.cs index 3a6bbcea365..3f3c5a36853 100644 --- a/src/NHibernate/Tool/hbm2ddl/SchemaValidator.cs +++ b/src/NHibernate/Tool/hbm2ddl/SchemaValidator.cs @@ -99,7 +99,7 @@ public void Validate() { log.Info("fetching database metadata"); connectionHelper.Prepare(); - DbConnection connection = connectionHelper.Connection; + var connection = connectionHelper.Connection; meta = new DatabaseMetadata(connection, dialect, false); } catch (Exception sqle) diff --git a/src/NHibernate/Tool/hbm2ddl/SuppliedConnectionProviderConnectionHelper.cs b/src/NHibernate/Tool/hbm2ddl/SuppliedConnectionProviderConnectionHelper.cs index 4694427176d..4d71d8b104d 100644 --- a/src/NHibernate/Tool/hbm2ddl/SuppliedConnectionProviderConnectionHelper.cs +++ b/src/NHibernate/Tool/hbm2ddl/SuppliedConnectionProviderConnectionHelper.cs @@ -22,7 +22,7 @@ public SuppliedConnectionProviderConnectionHelper(IConnectionProvider provider) public void Prepare() { - connection = (DbConnection)provider.GetConnection(); + connection = provider.GetConnection(); } public DbConnection Connection diff --git a/src/NHibernate/Transaction/AdoNetTransactionFactory.cs b/src/NHibernate/Transaction/AdoNetTransactionFactory.cs index ea9d993456c..ad1225b6e05 100644 --- a/src/NHibernate/Transaction/AdoNetTransactionFactory.cs +++ b/src/NHibernate/Transaction/AdoNetTransactionFactory.cs @@ -32,8 +32,8 @@ public bool IsInDistributedActiveTransaction(ISessionImplementor session) public void ExecuteWorkInIsolation(ISessionImplementor session, IIsolatedWork work, bool transacted) { - IDbConnection connection = null; - IDbTransaction trans = null; + DbConnection connection = null; + DbTransaction trans = null; // bool wasAutoCommit = false; try { diff --git a/src/NHibernate/Transaction/AdoTransaction.cs b/src/NHibernate/Transaction/AdoTransaction.cs index 9c18905b580..1cfd7a4fed9 100644 --- a/src/NHibernate/Transaction/AdoTransaction.cs +++ b/src/NHibernate/Transaction/AdoTransaction.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Data; +using System.Data.Common; using NHibernate.Engine; using NHibernate.Impl; @@ -8,14 +9,14 @@ namespace NHibernate.Transaction { /// - /// Wraps an ADO.NET to implement + /// Wraps an ADO.NET to implement /// the interface. /// public class AdoTransaction : ITransaction { private static readonly IInternalLogger log = LoggerProvider.LoggerFor(typeof(AdoTransaction)); private ISessionImplementor session; - private IDbTransaction trans; + private DbTransaction trans; private bool begun; private bool committed; private bool rolledBack; @@ -33,20 +34,20 @@ public AdoTransaction(ISessionImplementor session) } /// - /// Enlist the in the current . + /// Enlist the in the current . /// - /// The to enlist in this Transaction. + /// The to enlist in this Transaction. /// /// - /// This takes care of making sure the 's Transaction property - /// contains the correct or if there is no + /// This takes care of making sure the 's Transaction property + /// contains the correct or if there is no /// Transaction for the ISession - ie BeginTransaction() not called. /// /// /// This method may be called even when the transaction is disposed. /// /// - public void Enlist(IDbCommand command) + public void Enlist(DbCommand command) { if (trans == null) { @@ -54,7 +55,7 @@ public void Enlist(IDbCommand command) { if (command.Transaction != null) { - log.Warn("set a nonnull IDbCommand.Transaction to null because the Session had no Transaction"); + log.Warn("set a nonnull DbCommand.Transaction to null because the Session had no Transaction"); } } @@ -69,7 +70,7 @@ public void Enlist(IDbCommand command) // don't need to be confused by that - just a normal part of initialization... if (command.Transaction != null && command.Transaction != trans) { - log.Warn("The IDbCommand had a different Transaction than the Session. This can occur when " + + log.Warn("The DbCommand had a different Transaction than the Session. This can occur when " + "Disconnecting and Reconnecting Sessions because the PreparedCommand Cache is Session specific."); } } @@ -98,12 +99,12 @@ public void Begin() } /// - /// Begins the on the + /// Begins the on the /// used by the . /// /// /// Thrown if there is any problems encountered while trying to create - /// the . + /// the . /// public void Begin(IsolationLevel isolationLevel) { @@ -169,11 +170,11 @@ private void AfterTransactionCompletion(bool successful) /// /// Commits the by flushing the - /// and committing the . + /// and committing the . /// /// /// Thrown if there is any exception while trying to call Commit() on - /// the underlying . + /// the underlying . /// public void Commit() { @@ -196,7 +197,7 @@ public void Commit() try { trans.Commit(); - log.Debug("IDbTransaction Committed"); + log.Debug("DbTransaction Committed"); committed = true; AfterTransactionCompletion(true); @@ -226,11 +227,11 @@ public void Commit() /// /// Rolls back the by calling the method Rollback - /// on the underlying . + /// on the underlying . /// /// /// Thrown if there is any exception while trying to call Rollback() on - /// the underlying . + /// the underlying . /// public void Rollback() { @@ -247,7 +248,7 @@ public void Rollback() try { trans.Rollback(); - log.Debug("IDbTransaction RolledBack"); + log.Debug("DbTransaction RolledBack"); rolledBack = true; Dispose(); } @@ -275,7 +276,7 @@ public void Rollback() /// Gets a indicating if the transaction was rolled back. /// /// - /// if the had Rollback called + /// if the had Rollback called /// without any exceptions. /// public bool WasRolledBack @@ -287,7 +288,7 @@ public bool WasRolledBack /// Gets a indicating if the transaction was committed. /// /// - /// if the had Commit called + /// if the had Commit called /// without any exceptions. /// public bool WasCommitted @@ -367,7 +368,7 @@ protected virtual void Dispose(bool isDisposing) { trans.Dispose(); trans = null; - log.Debug("IDbTransaction disposed."); + log.Debug("DbTransaction disposed."); } if (IsActive && session != null) diff --git a/src/NHibernate/Type/AbstractBinaryType.cs b/src/NHibernate/Type/AbstractBinaryType.cs index 62e7dd88614..5f59a43be76 100644 --- a/src/NHibernate/Type/AbstractBinaryType.cs +++ b/src/NHibernate/Type/AbstractBinaryType.cs @@ -1,6 +1,6 @@ using System; using System.Collections; -using System.Data; +using System.Data.Common; using System.Text; using NHibernate.Engine; using NHibernate.SqlTypes; @@ -73,11 +73,11 @@ public virtual int Compare(object x, object y) /// Convert the object into the internal byte[] representation protected internal abstract byte[] ToInternalFormat(object bytes); - public override void Set(IDbCommand cmd, object value, int index) + public override void Set(DbCommand cmd, object value, int index) { byte[] internalValue = ToInternalFormat(value); - var parameter = (IDbDataParameter)cmd.Parameters[index]; + var parameter = cmd.Parameters[index]; // set the parameter value before the size check, since ODBC changes the size automatically parameter.Value = internalValue; @@ -87,7 +87,7 @@ public override void Set(IDbCommand cmd, object value, int index) throw new HibernateException("The length of the byte[] value exceeds the length configured in the mapping/parameter."); } - public override object Get(IDataReader rs, int index) + public override object Get(DbDataReader rs, int index) { int length = (int)rs.GetBytes(index, 0, null, 0, 0); byte[] buffer = new byte[length]; @@ -99,7 +99,7 @@ public override object Get(IDataReader rs, int index) return ToExternalFormat(buffer); } - public override object Get(IDataReader rs, string name) + public override object Get(DbDataReader rs, string name) { return Get(rs, rs.GetOrdinal(name)); } diff --git a/src/NHibernate/Type/AbstractCharType.cs b/src/NHibernate/Type/AbstractCharType.cs index 9129979ade3..86c209fbb7b 100644 --- a/src/NHibernate/Type/AbstractCharType.cs +++ b/src/NHibernate/Type/AbstractCharType.cs @@ -1,5 +1,5 @@ using System; -using System.Data; +using System.Data.Common; using NHibernate.SqlTypes; namespace NHibernate.Type @@ -18,7 +18,7 @@ public override object DefaultValue get { throw new NotSupportedException("not a valid id type"); } } - public override object Get(IDataReader rs, int index) + public override object Get(DbDataReader rs, int index) { string dbValue = Convert.ToString(rs[index]); // The check of the Length is a workaround see NH-2340 @@ -29,7 +29,7 @@ public override object Get(IDataReader rs, int index) return '\0'; // This line should never be executed } - public override object Get(IDataReader rs, string name) + public override object Get(DbDataReader rs, string name) { return Get(rs, rs.GetOrdinal(name)); } @@ -44,9 +44,9 @@ public override System.Type ReturnedClass get { return typeof(char); } } - public override void Set(IDbCommand cmd, object value, int index) + public override void Set(DbCommand cmd, object value, int index) { - ((IDataParameter)cmd.Parameters[index]).Value = Convert.ToChar(value); + cmd.Parameters[index].Value = Convert.ToChar(value); } public override string ObjectToSQLString(object value, Dialect.Dialect dialect) diff --git a/src/NHibernate/Type/AbstractDateTimeSpecificKindType.cs b/src/NHibernate/Type/AbstractDateTimeSpecificKindType.cs index 8c655f47ac3..1a197dfdfa4 100644 --- a/src/NHibernate/Type/AbstractDateTimeSpecificKindType.cs +++ b/src/NHibernate/Type/AbstractDateTimeSpecificKindType.cs @@ -1,5 +1,5 @@ using System; -using System.Data; +using System.Data.Common; namespace NHibernate.Type { @@ -43,13 +43,13 @@ public override bool IsEqual(object x, object y) return base.IsEqual(x, y) && ((DateTime) x).Kind == ((DateTime) y).Kind; } - public override void Set(IDbCommand st, object value, int index) + public override void Set(DbCommand st, object value, int index) { var dateValue = (DateTime) value; - ((IDataParameter) st.Parameters[index]).Value = CreateDateTime(dateValue); + st.Parameters[index].Value = CreateDateTime(dateValue); } - public override object Get(IDataReader rs, int index) + public override object Get(DbDataReader rs, int index) { try { diff --git a/src/NHibernate/Type/AbstractEnumType.cs b/src/NHibernate/Type/AbstractEnumType.cs index 2ade5986c35..0b6ab128392 100644 --- a/src/NHibernate/Type/AbstractEnumType.cs +++ b/src/NHibernate/Type/AbstractEnumType.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Data; using System.Text; using NHibernate.SqlTypes; diff --git a/src/NHibernate/Type/AbstractStringType.cs b/src/NHibernate/Type/AbstractStringType.cs index bbde226703b..822c9ee7882 100644 --- a/src/NHibernate/Type/AbstractStringType.cs +++ b/src/NHibernate/Type/AbstractStringType.cs @@ -1,5 +1,5 @@ using System; -using System.Data; +using System.Data.Common; using NHibernate.SqlTypes; namespace NHibernate.Type @@ -12,9 +12,9 @@ public AbstractStringType(SqlType sqlType) { } - public override void Set(IDbCommand cmd, object value, int index) + public override void Set(DbCommand cmd, object value, int index) { - IDbDataParameter parameter = (IDbDataParameter)cmd.Parameters[index]; + var parameter = cmd.Parameters[index]; // set the parameter value before the size check, since ODBC changes the size automatically parameter.Value = value; @@ -23,12 +23,12 @@ public override void Set(IDbCommand cmd, object value, int index) throw new HibernateException("The length of the string value exceeds the length configured in the mapping/parameter."); } - public override object Get(IDataReader rs, int index) + public override object Get(DbDataReader rs, int index) { return Convert.ToString(rs[index]); } - public override object Get(IDataReader rs, string name) + public override object Get(DbDataReader rs, string name) { return Convert.ToString(rs[name]); } diff --git a/src/NHibernate/Type/AbstractType.cs b/src/NHibernate/Type/AbstractType.cs index 81c54ddd61c..8acb64645f7 100644 --- a/src/NHibernate/Type/AbstractType.cs +++ b/src/NHibernate/Type/AbstractType.cs @@ -1,6 +1,6 @@ using System; using System.Collections; -using System.Data; +using System.Data.Common; using System.Xml; using NHibernate.Engine; using NHibernate.SqlTypes; @@ -112,21 +112,21 @@ public virtual bool IsDirty(object old, object current, ISessionImplementor sess /// /// Retrieves an instance of the mapped class, or the identifier of an entity - /// or collection from a . + /// or collection from a . /// - /// The that contains the values. + /// The that contains the values. /// - /// The names of the columns in the that contain the + /// The names of the columns in the that contain the /// value to populate the IType with. /// /// the session /// The parent Entity /// An identifier or actual object mapped by this IType. /// - /// This method uses the IType.NullSafeGet(IDataReader, string[], ISessionImplementor, object) method + /// This method uses the IType.NullSafeGet(DbDataReader, string[], ISessionImplementor, object) method /// to Hydrate this . /// - public virtual object Hydrate(IDataReader rs, string[] names, ISessionImplementor session, object owner) + public virtual object Hydrate(DbDataReader rs, string[] names, ISessionImplementor session, object owner) { return NullSafeGet(rs, names, session, owner); } @@ -284,24 +284,24 @@ public abstract object Replace(object original, object current, ISessionImplemen public abstract string Name { get; } /// - public abstract object NullSafeGet(IDataReader rs, string[] names, ISessionImplementor session, object owner); + public abstract object NullSafeGet(DbDataReader rs, string[] names, ISessionImplementor session, object owner); /// - public abstract object NullSafeGet(IDataReader rs, string name, ISessionImplementor session, Object owner); + public abstract object NullSafeGet(DbDataReader rs, string name, ISessionImplementor session, Object owner); /// - public abstract void NullSafeSet(IDbCommand st, object value, int index, bool[] settable, ISessionImplementor session); + public abstract void NullSafeSet(DbCommand st, object value, int index, bool[] settable, ISessionImplementor session); /// - public abstract void NullSafeSet(IDbCommand st, object value, int index, ISessionImplementor session); + public abstract void NullSafeSet(DbCommand st, object value, int index, ISessionImplementor session); /// /// /// - public override void NullSafeSet(IDbCommand st, object value, int index, ISessionImplementor session) + public override void NullSafeSet(DbCommand st, object value, int index, ISessionImplementor session) { base.NullSafeSet(st, session.PersistenceContext.GetCollectionHolder(value), index, session); } diff --git a/src/NHibernate/Type/BinaryBlobType.cs b/src/NHibernate/Type/BinaryBlobType.cs index 5a7d5ea1a37..f70dafc0e05 100644 --- a/src/NHibernate/Type/BinaryBlobType.cs +++ b/src/NHibernate/Type/BinaryBlobType.cs @@ -8,7 +8,7 @@ namespace NHibernate.Type /// /// /// This is only needed by DataProviders (SqlClient) that need to specify a Size for the - /// IDbDataParameter. Most DataProvider(Oracle) don't need to set the Size so a BinaryType + /// DbParameter. Most DataProvider(Oracle) don't need to set the Size so a BinaryType /// would work just fine. /// [Serializable] diff --git a/src/NHibernate/Type/BooleanType.cs b/src/NHibernate/Type/BooleanType.cs index 4c441da8e70..0a35ba4d6b5 100644 --- a/src/NHibernate/Type/BooleanType.cs +++ b/src/NHibernate/Type/BooleanType.cs @@ -1,5 +1,6 @@ using System; using System.Data; +using System.Data.Common; using NHibernate.SqlTypes; namespace NHibernate.Type @@ -32,12 +33,12 @@ public BooleanType(AnsiStringFixedLengthSqlType sqlType) : base(sqlType) { } - public override object Get(IDataReader rs, int index) + public override object Get(DbDataReader rs, int index) { return Convert.ToBoolean(rs[index]); } - public override object Get(IDataReader rs, string name) + public override object Get(DbDataReader rs, string name) { return Convert.ToBoolean(rs[name]); } @@ -52,9 +53,9 @@ public override System.Type ReturnedClass get { return typeof(bool); } } - public override void Set(IDbCommand cmd, object value, int index) + public override void Set(DbCommand cmd, object value, int index) { - ((IDataParameter) cmd.Parameters[index]).Value = (bool) value; + cmd.Parameters[index].Value = (bool) value; } public override string Name diff --git a/src/NHibernate/Type/ByteType.cs b/src/NHibernate/Type/ByteType.cs index a65f8eb1360..9986348c90b 100644 --- a/src/NHibernate/Type/ByteType.cs +++ b/src/NHibernate/Type/ByteType.cs @@ -1,6 +1,7 @@ using System; using System.Collections; using System.Data; +using System.Data.Common; using NHibernate.Engine; using NHibernate.SqlTypes; @@ -20,12 +21,12 @@ public ByteType() { } - public override object Get(IDataReader rs, int index) + public override object Get(DbDataReader rs, int index) { return Convert.ToByte(rs[index]); } - public override object Get(IDataReader rs, string name) + public override object Get(DbDataReader rs, string name) { return Convert.ToByte(rs[name]); } @@ -40,9 +41,9 @@ public override System.Type PrimitiveClass get { return typeof(byte); } } - public override void Set(IDbCommand cmd, object value, int index) + public override void Set(DbCommand cmd, object value, int index) { - ((IDataParameter) cmd.Parameters[index]).Value = Convert.ToByte(value); + cmd.Parameters[index].Value = Convert.ToByte(value); } public override string Name diff --git a/src/NHibernate/Type/CharBooleanType.cs b/src/NHibernate/Type/CharBooleanType.cs index c6815f80332..87c47490f1b 100644 --- a/src/NHibernate/Type/CharBooleanType.cs +++ b/src/NHibernate/Type/CharBooleanType.cs @@ -1,5 +1,6 @@ using System; using System.Data; +using System.Data.Common; using NHibernate.SqlTypes; using NHibernate.Util; @@ -32,7 +33,7 @@ protected CharBooleanType(AnsiStringFixedLengthSqlType sqlType) : base(sqlType) /// /// /// - public override object Get(IDataReader rs, int index) + public override object Get(DbDataReader rs, int index) { string code = Convert.ToString(rs[index]); if (code == null) @@ -51,7 +52,7 @@ public override object Get(IDataReader rs, int index) /// /// /// - public override object Get(IDataReader rs, string name) + public override object Get(DbDataReader rs, string name) { return Get(rs, rs.GetOrdinal(name)); } @@ -62,9 +63,9 @@ public override object Get(IDataReader rs, string name) /// /// /// - public override void Set(IDbCommand cmd, Object value, int index) + public override void Set(DbCommand cmd, Object value, int index) { - ((IDataParameter) cmd.Parameters[index]).Value = ToCharacter(value); + cmd.Parameters[index].Value = ToCharacter(value); } private string ToCharacter(object value) diff --git a/src/NHibernate/Type/ClassMetaType.cs b/src/NHibernate/Type/ClassMetaType.cs index 9d5f2c1f6ef..1d9694ac1d8 100644 --- a/src/NHibernate/Type/ClassMetaType.cs +++ b/src/NHibernate/Type/ClassMetaType.cs @@ -1,5 +1,5 @@ using System; -using System.Data; +using System.Data.Common; using System.Xml; using NHibernate.Engine; using NHibernate.SqlTypes; @@ -30,12 +30,12 @@ public override System.Type ReturnedClass get { return typeof (string); } } - public override object NullSafeGet(IDataReader rs, string[] names, ISessionImplementor session, object owner) + public override object NullSafeGet(DbDataReader rs, string[] names, ISessionImplementor session, object owner) { return NullSafeGet(rs, names[0], session, owner); } - public override object NullSafeGet(IDataReader rs,string name,ISessionImplementor session,object owner) + public override object NullSafeGet(DbDataReader rs,string name,ISessionImplementor session,object owner) { int index = rs.GetOrdinal(name); @@ -50,16 +50,16 @@ public override object NullSafeGet(IDataReader rs,string name,ISessionImplemento } } - public override void NullSafeSet(IDbCommand st, object value, int index, bool[] settable, ISessionImplementor session) + public override void NullSafeSet(DbCommand st, object value, int index, bool[] settable, ISessionImplementor session) { if (settable[0]) NullSafeSet(st, value, index, session); } - public override void NullSafeSet(IDbCommand st,object value,int index,ISessionImplementor session) + public override void NullSafeSet(DbCommand st,object value,int index,ISessionImplementor session) { if (value == null) { - ((IDataParameter)st.Parameters[index]).Value = DBNull.Value; + st.Parameters[index].Value = DBNull.Value; } else { diff --git a/src/NHibernate/Type/CollectionType.cs b/src/NHibernate/Type/CollectionType.cs index 47a68bdbf68..2efa1af9dbc 100644 --- a/src/NHibernate/Type/CollectionType.cs +++ b/src/NHibernate/Type/CollectionType.cs @@ -1,6 +1,6 @@ using System; using System.Collections; -using System.Data; +using System.Data.Common; using System.Xml; using NHibernate.Collection; using NHibernate.Engine; @@ -82,22 +82,22 @@ public override int GetHashCode(object x, EntityMode entityMode) /// The instantiated collection. public abstract IPersistentCollection Instantiate(ISessionImplementor session, ICollectionPersister persister, object key); - public override object NullSafeGet(IDataReader rs, string name, ISessionImplementor session, object owner) + public override object NullSafeGet(DbDataReader rs, string name, ISessionImplementor session, object owner) { return NullSafeGet(rs, new string[] { name }, session, owner); } - public override object NullSafeGet(IDataReader rs, string[] name, ISessionImplementor session, object owner) + public override object NullSafeGet(DbDataReader rs, string[] name, ISessionImplementor session, object owner) { return ResolveIdentifier(null, session, owner); } - public override void NullSafeSet(IDbCommand st, object value, int index, bool[] settable, ISessionImplementor session) + public override void NullSafeSet(DbCommand st, object value, int index, bool[] settable, ISessionImplementor session) { // NOOP } - public override void NullSafeSet(IDbCommand cmd, object value, int index, ISessionImplementor session) + public override void NullSafeSet(DbCommand cmd, object value, int index, ISessionImplementor session) { } @@ -218,7 +218,7 @@ public virtual ForeignKeyDirection ForeignKeyDirection get { return ForeignKeyDirection.ForeignKeyToParent; } } - public override object Hydrate(IDataReader rs, string[] name, ISessionImplementor session, object owner) + public override object Hydrate(DbDataReader rs, string[] name, ISessionImplementor session, object owner) { // can't just return null here, since that would // cause an owning component to become null diff --git a/src/NHibernate/Type/ComponentType.cs b/src/NHibernate/Type/ComponentType.cs index 034d70905c3..42c81d20275 100644 --- a/src/NHibernate/Type/ComponentType.cs +++ b/src/NHibernate/Type/ComponentType.cs @@ -1,7 +1,7 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Data; +using System.Data.Common; using System.Reflection; using System.Xml; using NHibernate.Engine; @@ -200,7 +200,7 @@ public override bool IsDirty(object x, object y, bool[] checkable, ISessionImple return false; } - public override object NullSafeGet(IDataReader rs, string[] names, ISessionImplementor session, object owner) + public override object NullSafeGet(DbDataReader rs, string[] names, ISessionImplementor session, object owner) { return ResolveIdentifier(Hydrate(rs, names, session, owner), session, owner); } @@ -212,7 +212,7 @@ public override object NullSafeGet(IDataReader rs, string[] names, ISessionImple /// /// /// - public override void NullSafeSet(IDbCommand st, object value, int begin, ISessionImplementor session) + public override void NullSafeSet(DbCommand st, object value, int begin, ISessionImplementor session) { object[] subvalues = NullSafeGetValues(value, session.EntityMode); @@ -223,7 +223,7 @@ public override void NullSafeSet(IDbCommand st, object value, int begin, ISessio } } - public override void NullSafeSet(IDbCommand st, object value, int begin, bool[] settable, ISessionImplementor session) + public override void NullSafeSet(DbCommand st, object value, int begin, bool[] settable, ISessionImplementor session) { object[] subvalues = NullSafeGetValues(value, session.EntityMode); @@ -266,7 +266,7 @@ private object[] NullSafeGetValues(object value, EntityMode entityMode) } } - public override object NullSafeGet(IDataReader rs, string name, ISessionImplementor session, object owner) + public override object NullSafeGet(DbDataReader rs, string name, ISessionImplementor session, object owner) { return NullSafeGet(rs, new string[] {name}, session, owner); } @@ -478,7 +478,7 @@ public virtual bool IsEmbedded get { return false; } } - public override object Hydrate(IDataReader rs, string[] names, ISessionImplementor session, object owner) + public override object Hydrate(DbDataReader rs, string[] names, ISessionImplementor session, object owner) { int begin = 0; bool notNull = false; diff --git a/src/NHibernate/Type/CompositeCustomType.cs b/src/NHibernate/Type/CompositeCustomType.cs index 614b074f2bb..13164f11c9b 100644 --- a/src/NHibernate/Type/CompositeCustomType.cs +++ b/src/NHibernate/Type/CompositeCustomType.cs @@ -1,6 +1,6 @@ using System; using System.Collections; -using System.Data; +using System.Data.Common; using System.Linq; using System.Reflection; using System.Xml; @@ -164,22 +164,22 @@ public override bool IsMutable get { return userType.IsMutable; } } - public override object NullSafeGet(IDataReader rs, string name, ISessionImplementor session, object owner) + public override object NullSafeGet(DbDataReader rs, string name, ISessionImplementor session, object owner) { return userType.NullSafeGet(rs, new string[] {name}, session, owner); } - public override object NullSafeGet(IDataReader rs, string[] names, ISessionImplementor session, object owner) + public override object NullSafeGet(DbDataReader rs, string[] names, ISessionImplementor session, object owner) { return userType.NullSafeGet(rs, names, session, owner); } - public override void NullSafeSet(IDbCommand st, object value, int index, bool[] settable, ISessionImplementor session) + public override void NullSafeSet(DbCommand st, object value, int index, bool[] settable, ISessionImplementor session) { userType.NullSafeSet(st, value, index, settable, session); } - public override void NullSafeSet(IDbCommand cmd, object value, int index, ISessionImplementor session) + public override void NullSafeSet(DbCommand cmd, object value, int index, ISessionImplementor session) { bool[] settable = Enumerable.Repeat(true, GetColumnSpan(session.Factory)).ToArray(); userType.NullSafeSet(cmd, value, index, settable, session); diff --git a/src/NHibernate/Type/CultureInfoType.cs b/src/NHibernate/Type/CultureInfoType.cs index 9ebe1f36eab..d30d31f7695 100644 --- a/src/NHibernate/Type/CultureInfoType.cs +++ b/src/NHibernate/Type/CultureInfoType.cs @@ -1,5 +1,6 @@ using System; using System.Data; +using System.Data.Common; using System.Globalization; using NHibernate.SqlTypes; @@ -27,7 +28,7 @@ internal CultureInfoType() : base(new StringSqlType(5)) /// /// /// - public override object Get(IDataReader rs, int index) + public override object Get(DbDataReader rs, int index) { string str = (string) NHibernateUtil.String.Get(rs, index); if (str == null) @@ -46,7 +47,7 @@ public override object Get(IDataReader rs, int index) /// /// /// - public override object Get(IDataReader rs, string name) + public override object Get(DbDataReader rs, string name) { return Get(rs, rs.GetOrdinal(name)); } @@ -57,7 +58,7 @@ public override object Get(IDataReader rs, string name) /// /// /// - public override void Set(IDbCommand cmd, object value, int index) + public override void Set(DbCommand cmd, object value, int index) { NHibernateUtil.String.Set(cmd, ((CultureInfo) value).Name, index); } diff --git a/src/NHibernate/Type/CustomType.cs b/src/NHibernate/Type/CustomType.cs index e89757a089c..e7049190afa 100644 --- a/src/NHibernate/Type/CustomType.cs +++ b/src/NHibernate/Type/CustomType.cs @@ -1,6 +1,6 @@ using System; using System.Collections; -using System.Data; +using System.Data.Common; using System.Reflection; using System.Xml; @@ -96,23 +96,23 @@ public override System.Type ReturnedClass get { return userType.ReturnedType; } } - public override object NullSafeGet(IDataReader rs, string[] names, ISessionImplementor session, object owner) + public override object NullSafeGet(DbDataReader rs, string[] names, ISessionImplementor session, object owner) { return userType.NullSafeGet(rs, names, owner); } - public override object NullSafeGet(IDataReader rs, string name, ISessionImplementor session, object owner) + public override object NullSafeGet(DbDataReader rs, string name, ISessionImplementor session, object owner) { return NullSafeGet(rs, new string[] {name}, session, owner); } - public override void NullSafeSet(IDbCommand st, object value, int index, bool[] settable, ISessionImplementor session) + public override void NullSafeSet(DbCommand st, object value, int index, bool[] settable, ISessionImplementor session) { if (settable[0]) userType.NullSafeSet(st, value, index); } - public override void NullSafeSet(IDbCommand cmd, object value, int index, ISessionImplementor session) + public override void NullSafeSet(DbCommand cmd, object value, int index, ISessionImplementor session) { userType.NullSafeSet(cmd, value, index); } diff --git a/src/NHibernate/Type/DateTime2Type.cs b/src/NHibernate/Type/DateTime2Type.cs index 099ac0fe44b..8f4af828c4c 100644 --- a/src/NHibernate/Type/DateTime2Type.cs +++ b/src/NHibernate/Type/DateTime2Type.cs @@ -1,5 +1,6 @@ using System; using System.Data; +using System.Data.Common; using NHibernate.SqlTypes; namespace NHibernate.Type @@ -20,7 +21,7 @@ public override string Name get { return "DateTime2"; } } - public override object Get(IDataReader rs, int index) + public override object Get(DbDataReader rs, int index) { try { @@ -32,9 +33,9 @@ public override object Get(IDataReader rs, int index) } } - public override void Set(IDbCommand st, object value, int index) + public override void Set(DbCommand st, object value, int index) { - ((IDataParameter) st.Parameters[index]).Value = (DateTime) value; + st.Parameters[index].Value = (DateTime) value; } public override bool IsEqual(object x, object y) diff --git a/src/NHibernate/Type/DateTimeOffSetType.cs b/src/NHibernate/Type/DateTimeOffSetType.cs index 44ba067c230..82eb263af61 100644 --- a/src/NHibernate/Type/DateTimeOffSetType.cs +++ b/src/NHibernate/Type/DateTimeOffSetType.cs @@ -2,6 +2,7 @@ using System.Collections; using System.Collections.Generic; using System.Data; +using System.Data.Common; using NHibernate.Engine; using NHibernate.SqlTypes; @@ -46,14 +47,14 @@ public IComparer Comparator get { return Comparer.Default; } } - public override void Set(IDbCommand st, object value, int index) + public override void Set(DbCommand st, object value, int index) { var dateValue = (DateTimeOffset) value; - ((IDataParameter) st.Parameters[index]).Value = + st.Parameters[index].Value = new DateTimeOffset(dateValue.Ticks, dateValue.Offset); } - public override object Get(IDataReader rs, int index) + public override object Get(DbDataReader rs, int index) { try { @@ -66,7 +67,7 @@ public override object Get(IDataReader rs, int index) } } - public override object Get(IDataReader rs, string name) + public override object Get(DbDataReader rs, string name) { return Get(rs, rs.GetOrdinal(name)); } diff --git a/src/NHibernate/Type/DateTimeType.cs b/src/NHibernate/Type/DateTimeType.cs index 7c46ca10276..c14ec598ccb 100644 --- a/src/NHibernate/Type/DateTimeType.cs +++ b/src/NHibernate/Type/DateTimeType.cs @@ -1,9 +1,10 @@ using System; using System.Collections; -using System.Data; +using System.Data.Common; using NHibernate.Engine; using NHibernate.SqlTypes; using System.Collections.Generic; +using System.Data; namespace NHibernate.Type { @@ -36,7 +37,7 @@ public override string Name get { return "DateTime"; } } - public override object Get(IDataReader rs, int index) + public override object Get(DbDataReader rs, int index) { try { @@ -49,7 +50,7 @@ public override object Get(IDataReader rs, int index) } } - public override object Get(IDataReader rs, string name) + public override object Get(DbDataReader rs, string name) { return Get(rs, rs.GetOrdinal(name)); } @@ -59,10 +60,10 @@ public override System.Type ReturnedClass get { return typeof(DateTime); } } - public override void Set(IDbCommand st, object value, int index) + public override void Set(DbCommand st, object value, int index) { DateTime dateValue = (DateTime) value; - ((IDataParameter)st.Parameters[index]).Value = + st.Parameters[index].Value = new DateTime(dateValue.Year, dateValue.Month, dateValue.Day, dateValue.Hour, dateValue.Minute, dateValue.Second); } diff --git a/src/NHibernate/Type/DateType.cs b/src/NHibernate/Type/DateType.cs index 0705d9dd943..1447dcb8638 100644 --- a/src/NHibernate/Type/DateType.cs +++ b/src/NHibernate/Type/DateType.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Data; +using System.Data.Common; using NHibernate.SqlTypes; using NHibernate.UserTypes; @@ -28,7 +29,7 @@ public override string Name get { return "Date"; } } - public override object Get(IDataReader rs, int index) + public override object Get(DbDataReader rs, int index) { try { @@ -41,7 +42,7 @@ public override object Get(IDataReader rs, int index) } } - public override object Get(IDataReader rs, string name) + public override object Get(DbDataReader rs, string name) { return Get(rs, rs.GetOrdinal(name)); } @@ -51,9 +52,9 @@ public override System.Type ReturnedClass get { return typeof(DateTime); } } - public override void Set(IDbCommand st, object value, int index) + public override void Set(DbCommand st, object value, int index) { - var parm = (IDataParameter) st.Parameters[index]; + var parm = st.Parameters[index]; var dateTime = (DateTime)value; if (dateTime < customBaseDate) parm.Value = DBNull.Value; else parm.Value = dateTime.Date; diff --git a/src/NHibernate/Type/DbTimestampType.cs b/src/NHibernate/Type/DbTimestampType.cs index d18a5a4c4ea..35dfa0b0ffc 100644 --- a/src/NHibernate/Type/DbTimestampType.cs +++ b/src/NHibernate/Type/DbTimestampType.cs @@ -57,8 +57,8 @@ private object GetCurrentTimestamp(ISessionImplementor session) protected virtual object UsePreparedStatement(string timestampSelectString, ISessionImplementor session) { var tsSelect = new SqlString(timestampSelectString); - IDbCommand ps = null; - IDataReader rs = null; + DbCommand ps = null; + DbDataReader rs = null; using (new SessionIdLoggingContext(session.SessionId)) try { diff --git a/src/NHibernate/Type/DecimalType.cs b/src/NHibernate/Type/DecimalType.cs index 2b5d19c3523..329e7f33200 100644 --- a/src/NHibernate/Type/DecimalType.cs +++ b/src/NHibernate/Type/DecimalType.cs @@ -1,5 +1,6 @@ using System; using System.Data; +using System.Data.Common; using NHibernate.SqlTypes; namespace NHibernate.Type @@ -20,12 +21,12 @@ public DecimalType(SqlType sqlType) : base(sqlType) { } - public override object Get(IDataReader rs, int index) + public override object Get(DbDataReader rs, int index) { return Convert.ToDecimal(rs[index]); } - public override object Get(IDataReader rs, string name) + public override object Get(DbDataReader rs, string name) { return Convert.ToDecimal(rs[name]); } @@ -35,9 +36,9 @@ public override System.Type ReturnedClass get { return typeof(Decimal); } } - public override void Set(IDbCommand st, object value, int index) + public override void Set(DbCommand st, object value, int index) { - ((IDataParameter) st.Parameters[index]).Value = value; + st.Parameters[index].Value = value; } public override string Name diff --git a/src/NHibernate/Type/DoubleType.cs b/src/NHibernate/Type/DoubleType.cs index ff3c3d20f60..fcf75d4affd 100644 --- a/src/NHibernate/Type/DoubleType.cs +++ b/src/NHibernate/Type/DoubleType.cs @@ -1,5 +1,6 @@ using System; using System.Data; +using System.Data.Common; using NHibernate.SqlTypes; namespace NHibernate.Type @@ -24,7 +25,7 @@ public DoubleType(SqlType sqlType) : base(sqlType) {} /// /// /// - public override object Get(IDataReader rs, int index) + public override object Get(DbDataReader rs, int index) { return Convert.ToDouble(rs[index]); } @@ -35,7 +36,7 @@ public override object Get(IDataReader rs, int index) /// /// /// - public override object Get(IDataReader rs, string name) + public override object Get(DbDataReader rs, string name) { return Convert.ToDouble(rs[name]); } @@ -52,10 +53,9 @@ public override System.Type ReturnedClass /// /// /// - public override void Set(IDbCommand st, object value, int index) + public override void Set(DbCommand st, object value, int index) { - IDataParameter parm = st.Parameters[index] as IDataParameter; - parm.Value = value; + st.Parameters[index].Value = value; } /// diff --git a/src/NHibernate/Type/EntityType.cs b/src/NHibernate/Type/EntityType.cs index 5d2a5db88b3..a9a12bd019d 100644 --- a/src/NHibernate/Type/EntityType.cs +++ b/src/NHibernate/Type/EntityType.cs @@ -1,6 +1,6 @@ using System; using System.Collections; -using System.Data; +using System.Data.Common; using System.Text; using System.Xml; using NHibernate.Engine; @@ -104,7 +104,7 @@ public override bool IsSame(object x, object y, EntityMode entityMode) return ReferenceEquals(x, y); } - public override object NullSafeGet(IDataReader rs, string name, ISessionImplementor session, object owner) + public override object NullSafeGet(DbDataReader rs, string name, ISessionImplementor session, object owner) { return NullSafeGet(rs, new string[] {name}, session, owner); } @@ -311,21 +311,21 @@ public override bool IsAssociationType } /// - /// Converts the id contained in the to an object. + /// Converts the id contained in the to an object. /// - /// The that contains the query results. + /// The that contains the query results. /// A string array of column names that contain the id. /// The this is occurring in. /// The object that this Entity will be a part of. /// /// An instance of the object or if the identifer was null. /// - public override sealed object NullSafeGet(IDataReader rs, string[] names, ISessionImplementor session, object owner) + public override sealed object NullSafeGet(DbDataReader rs, string[] names, ISessionImplementor session, object owner) { return ResolveIdentifier(Hydrate(rs, names, session, owner), session, owner); } - public abstract override object Hydrate(IDataReader rs, string[] names, ISessionImplementor session, object owner); + public abstract override object Hydrate(DbDataReader rs, string[] names, ISessionImplementor session, object owner); public bool IsUniqueKeyReference { diff --git a/src/NHibernate/Type/EnumCharType.cs b/src/NHibernate/Type/EnumCharType.cs index b1d3cf0a246..f3ba20babc3 100644 --- a/src/NHibernate/Type/EnumCharType.cs +++ b/src/NHibernate/Type/EnumCharType.cs @@ -1,5 +1,5 @@ using System; -using System.Data; +using System.Data.Common; using NHibernate.Engine; using NHibernate.SqlTypes; @@ -95,9 +95,9 @@ public virtual object GetValue(object instance) } - public override void Set(IDbCommand cmd, object value, int index) + public override void Set(DbCommand cmd, object value, int index) { - IDataParameter par = (IDataParameter) cmd.Parameters[index]; + var par = cmd.Parameters[index]; if (value == null) { par.Value = DBNull.Value; @@ -108,7 +108,7 @@ public override void Set(IDbCommand cmd, object value, int index) } } - public override object Get(IDataReader rs, int index) + public override object Get(DbDataReader rs, int index) { object code = rs[index]; if (code == DBNull.Value || code == null) @@ -121,7 +121,7 @@ public override object Get(IDataReader rs, int index) } } - public override object Get(IDataReader rs, string name) + public override object Get(DbDataReader rs, string name) { return Get(rs, rs.GetOrdinal(name)); } diff --git a/src/NHibernate/Type/EnumStringType.cs b/src/NHibernate/Type/EnumStringType.cs index b40617e4a59..665dde131aa 100644 --- a/src/NHibernate/Type/EnumStringType.cs +++ b/src/NHibernate/Type/EnumStringType.cs @@ -1,5 +1,6 @@ using System; using System.Data; +using System.Data.Common; using NHibernate.Engine; using NHibernate.SqlTypes; @@ -135,17 +136,9 @@ public virtual object GetValue(object code) /// /// /// - public override void Set(IDbCommand cmd, object value, int index) + public override void Set(DbCommand cmd, object value, int index) { - var par = (IDataParameter) cmd.Parameters[index]; - if (value == null) - { - par.Value = DBNull.Value; - } - else - { - par.Value = GetValue(value); - } + cmd.Parameters[index].Value = value == null ? DBNull.Value : GetValue(value); } /// @@ -154,7 +147,7 @@ public override void Set(IDbCommand cmd, object value, int index) /// /// /// - public override object Get(IDataReader rs, int index) + public override object Get(DbDataReader rs, int index) { object code = rs[index]; if (code == DBNull.Value || code == null) @@ -173,7 +166,7 @@ public override object Get(IDataReader rs, int index) /// /// /// - public override object Get(IDataReader rs, string name) + public override object Get(DbDataReader rs, string name) { return Get(rs, rs.GetOrdinal(name)); } diff --git a/src/NHibernate/Type/GuidType.cs b/src/NHibernate/Type/GuidType.cs index 87903276c95..64a905ca7d2 100644 --- a/src/NHibernate/Type/GuidType.cs +++ b/src/NHibernate/Type/GuidType.cs @@ -1,5 +1,6 @@ using System; using System.Data; +using System.Data.Common; using NHibernate.SqlTypes; namespace NHibernate.Type @@ -22,7 +23,7 @@ public GuidType() : base(SqlTypeFactory.Guid) /// /// /// - public override object Get(IDataReader rs, int index) + public override object Get(DbDataReader rs, int index) { if (rs.GetFieldType(index) == typeof (Guid)) { @@ -43,7 +44,7 @@ public override object Get(IDataReader rs, int index) /// /// /// - public override object Get(IDataReader rs, string name) + public override object Get(DbDataReader rs, string name) { return Get(rs, rs.GetOrdinal(name)); } @@ -54,9 +55,9 @@ public override System.Type ReturnedClass get { return typeof(Guid); } } - public override void Set(IDbCommand cmd, object value, int index) + public override void Set(DbCommand cmd, object value, int index) { - var dp = (IDataParameter) cmd.Parameters[index]; + var dp = cmd.Parameters[index]; dp.Value = dp.DbType == DbType.Binary ? ((Guid)value).ToByteArray() : value; } diff --git a/src/NHibernate/Type/IType.cs b/src/NHibernate/Type/IType.cs index 58eef44ffd7..dae8aeb58d4 100644 --- a/src/NHibernate/Type/IType.cs +++ b/src/NHibernate/Type/IType.cs @@ -1,5 +1,5 @@ using System.Collections; -using System.Data; +using System.Data.Common; using System.Xml; using NHibernate.Engine; using NHibernate.SqlTypes; @@ -76,24 +76,24 @@ public interface IType : ICacheAssembler bool IsModified(object oldHydratedState, object currentState, bool[] checkable, ISessionImplementor session); /// - object NullSafeGet(IDataReader rs, string[] names, ISessionImplementor session, object owner); + object NullSafeGet(DbDataReader rs, string[] names, ISessionImplementor session, object owner); /// - object NullSafeGet(IDataReader rs, string name, ISessionImplementor session, object owner); + object NullSafeGet(DbDataReader rs, string name, ISessionImplementor session, object owner); /// - void NullSafeSet(IDbCommand st, object value, int index, bool[] settable, ISessionImplementor session); + void NullSafeSet(DbCommand st, object value, int index, bool[] settable, ISessionImplementor session); /// - void NullSafeSet(IDbCommand st, object value, int index, ISessionImplementor session); + void NullSafeSet(DbCommand st, object value, int index, ISessionImplementor session); /// - object Hydrate(IDataReader rs, string[] names, ISessionImplementor session, object owner); + object Hydrate(DbDataReader rs, string[] names, ISessionImplementor session, object owner); /// true if the field is dirty - + When implemented by a class, gets an instance of the object mapped by - this IType from the . + this IType from the . - The that contains the values + The that contains the values - The names of the columns in the that contain the + The names of the columns in the that contain the value to populate the IType with. @@ -124,13 +124,13 @@ - + When implemented by a class, gets an instance of the object - mapped by this IType from the . + mapped by this IType from the . - The that contains the values - The name of the column in the that contains the + The that contains the values + The name of the column in the that contains the value to populate the IType with. @@ -144,11 +144,11 @@ When implemented by a class, puts the value/values from the mapped - class into the . + class into the . - The to put the values into. + The to put the values into. The object that contains the values. - The index of the to start writing the values to. + The index of the to start writing the values to. Indicates which columns are to be set. @@ -160,14 +160,14 @@ When implemented by a class, puts the value/values from the mapped - class into the . + class into the . - The to put the values into. + The to put the values into. The object that contains the values. - The index of the to start writing the values to. + The index of the to start writing the values to. @@ -272,11 +272,11 @@ When implemented by a class, retrieves an instance of the mapped class, - or the identifier of an entity or collection from a . + or the identifier of an entity or collection from a . - The that contains the values. + The that contains the values. - The names of the columns in the that contain the + The names of the columns in the that contain the value to populate the IType with. the session diff --git a/src/NHibernate/Type/Int16Type.cs b/src/NHibernate/Type/Int16Type.cs index 2be800bc3a2..c52cb1d1433 100644 --- a/src/NHibernate/Type/Int16Type.cs +++ b/src/NHibernate/Type/Int16Type.cs @@ -1,9 +1,10 @@ using System; using System.Collections; -using System.Data; +using System.Data.Common; using NHibernate.Engine; using NHibernate.SqlTypes; using System.Collections.Generic; +using System.Data; namespace NHibernate.Type { @@ -26,7 +27,7 @@ public override string Name } private static readonly Int16 ZERO = 0; - public override object Get(IDataReader rs, int index) + public override object Get(DbDataReader rs, int index) { try { @@ -38,7 +39,7 @@ public override object Get(IDataReader rs, int index) } } - public override object Get(IDataReader rs, string name) + public override object Get(DbDataReader rs, string name) { try { @@ -55,9 +56,9 @@ public override System.Type ReturnedClass get { return typeof(Int16); } } - public override void Set(IDbCommand rs, object value, int index) + public override void Set(DbCommand rs, object value, int index) { - ((IDataParameter)rs.Parameters[index]).Value = value; + rs.Parameters[index].Value = value; } public object StringToObject(string xml) diff --git a/src/NHibernate/Type/Int32Type.cs b/src/NHibernate/Type/Int32Type.cs index 79de6c67e67..5df847f2102 100644 --- a/src/NHibernate/Type/Int32Type.cs +++ b/src/NHibernate/Type/Int32Type.cs @@ -1,9 +1,10 @@ using System; using System.Collections; -using System.Data; +using System.Data.Common; using NHibernate.Engine; using NHibernate.SqlTypes; using System.Collections.Generic; +using System.Data; namespace NHibernate.Type { @@ -26,7 +27,7 @@ public override string Name } private static readonly Int32 ZERO = 0; - public override object Get(IDataReader rs, int index) + public override object Get(DbDataReader rs, int index) { try { @@ -38,7 +39,7 @@ public override object Get(IDataReader rs, int index) } } - public override object Get(IDataReader rs, string name) + public override object Get(DbDataReader rs, string name) { try { @@ -55,9 +56,9 @@ public override System.Type ReturnedClass get { return typeof(Int32); } } - public override void Set(IDbCommand rs, object value, int index) + public override void Set(DbCommand rs, object value, int index) { - ((IDataParameter)rs.Parameters[index]).Value = value; + rs.Parameters[index].Value = value; } public object StringToObject(string xml) diff --git a/src/NHibernate/Type/Int64Type.cs b/src/NHibernate/Type/Int64Type.cs index 76c66ee7280..44e6d5aeb4e 100644 --- a/src/NHibernate/Type/Int64Type.cs +++ b/src/NHibernate/Type/Int64Type.cs @@ -2,6 +2,7 @@ using System.Collections; using System.Collections.Generic; using System.Data; +using System.Data.Common; using NHibernate.Engine; using NHibernate.SqlTypes; @@ -26,7 +27,7 @@ public override string Name } private static readonly Int64 ZERO = 0; - public override object Get(IDataReader rs, int index) + public override object Get(DbDataReader rs, int index) { try { @@ -38,7 +39,7 @@ public override object Get(IDataReader rs, int index) } } - public override object Get(IDataReader rs, string name) + public override object Get(DbDataReader rs, string name) { try { @@ -55,9 +56,9 @@ public override System.Type ReturnedClass get { return typeof(Int64); } } - public override void Set(IDbCommand rs, object value, int index) + public override void Set(DbCommand rs, object value, int index) { - ((IDataParameter)rs.Parameters[index]).Value = value; + rs.Parameters[index].Value = value; } public object StringToObject(string xml) diff --git a/src/NHibernate/Type/ManyToOneType.cs b/src/NHibernate/Type/ManyToOneType.cs index cd382f1de39..e255bb36b37 100644 --- a/src/NHibernate/Type/ManyToOneType.cs +++ b/src/NHibernate/Type/ManyToOneType.cs @@ -1,5 +1,5 @@ using System; -using System.Data; +using System.Data.Common; using NHibernate.Engine; using NHibernate.Persister.Entity; using NHibernate.SqlTypes; @@ -46,13 +46,13 @@ public override SqlType[] SqlTypes(IMapping mapping) return GetIdentifierOrUniqueKeyType(mapping).SqlTypes(mapping); } - public override void NullSafeSet(IDbCommand st, object value, int index, bool[] settable, ISessionImplementor session) + public override void NullSafeSet(DbCommand st, object value, int index, bool[] settable, ISessionImplementor session) { GetIdentifierOrUniqueKeyType(session.Factory) .NullSafeSet(st, GetReferenceValue(value, session), index, settable, session); } - public override void NullSafeSet(IDbCommand cmd, object value, int index, ISessionImplementor session) + public override void NullSafeSet(DbCommand cmd, object value, int index, ISessionImplementor session) { GetIdentifierOrUniqueKeyType(session.Factory) .NullSafeSet(cmd, GetReferenceValue(value, session), index, session); @@ -74,16 +74,16 @@ public override ForeignKeyDirection ForeignKeyDirection } /// - /// Hydrates the Identifier from . + /// Hydrates the Identifier from . /// - /// The that contains the query results. + /// The that contains the query results. /// A string array of column names to read from. /// The this is occurring in. /// The object that this Entity will be a part of. /// /// An instantiated object that used as the identifier of the type. /// - public override object Hydrate(IDataReader rs, string[] names, ISessionImplementor session, object owner) + public override object Hydrate(DbDataReader rs, string[] names, ISessionImplementor session, object owner) { // return the (fully resolved) identifier value, but do not resolve // to the actual referenced entity instance diff --git a/src/NHibernate/Type/MetaType.cs b/src/NHibernate/Type/MetaType.cs index e8dc7037870..ef83dd0c71f 100644 --- a/src/NHibernate/Type/MetaType.cs +++ b/src/NHibernate/Type/MetaType.cs @@ -1,6 +1,6 @@ using System; using System.Collections.Generic; -using System.Data; +using System.Data.Common; using System.Xml; using NHibernate.Engine; using NHibernate.SqlTypes; @@ -40,24 +40,24 @@ public override System.Type ReturnedClass get { return typeof (string); } } - public override object NullSafeGet(IDataReader rs, string[] names, ISessionImplementor session, object owner) + public override object NullSafeGet(DbDataReader rs, string[] names, ISessionImplementor session, object owner) { object key = baseType.NullSafeGet(rs, names, session, owner); return key == null ? null : values[key]; } - public override object NullSafeGet(IDataReader rs,string name,ISessionImplementor session,object owner) + public override object NullSafeGet(DbDataReader rs,string name,ISessionImplementor session,object owner) { object key = baseType.NullSafeGet(rs, name, session, owner); return key == null ? null : values[key]; } - public override void NullSafeSet(IDbCommand st, object value, int index, bool[] settable, ISessionImplementor session) + public override void NullSafeSet(DbCommand st, object value, int index, bool[] settable, ISessionImplementor session) { if (settable[0]) NullSafeSet(st, value, index, session); } - public override void NullSafeSet(IDbCommand st,object value,int index,ISessionImplementor session) + public override void NullSafeSet(DbCommand st,object value,int index,ISessionImplementor session) { baseType.NullSafeSet(st, value == null ? null : keys[(string)value], index, session); } diff --git a/src/NHibernate/Type/NullableType.cs b/src/NHibernate/Type/NullableType.cs index 3f9353abb99..091116c45eb 100644 --- a/src/NHibernate/Type/NullableType.cs +++ b/src/NHibernate/Type/NullableType.cs @@ -1,5 +1,5 @@ using System; -using System.Data; +using System.Data.Common; using System.Xml; using NHibernate.Engine; @@ -47,39 +47,39 @@ protected NullableType(SqlType sqlType) /// /// When implemented by a class, put the value from the mapped - /// Property into to the . + /// Property into to the . /// - /// The to put the value into. + /// The to put the value into. /// The object that contains the value. - /// The index of the to start writing the values to. + /// The index of the to start writing the values to. /// /// Implementors do not need to handle possibility of null values because this will - /// only be called from after + /// only be called from after /// it has checked for nulls. /// - public abstract void Set(IDbCommand cmd, object value, int index); + public abstract void Set(DbCommand cmd, object value, int index); /// /// When implemented by a class, gets the object in the - /// for the Property. + /// for the Property. /// - /// The that contains the value. + /// The that contains the value. /// The index of the field to get the value from. /// An object with the value from the database. - public abstract object Get(IDataReader rs, int index); + public abstract object Get(DbDataReader rs, int index); /// /// When implemented by a class, gets the object in the - /// for the Property. + /// for the Property. /// - /// The that contains the value. + /// The that contains the value. /// The name of the field to get the value from. /// An object with the value from the database. /// - /// Most implementors just call the + /// Most implementors just call the /// overload of this method. /// - public abstract object Get(IDataReader rs, string name); + public abstract object Get(DbDataReader rs, string name); /// @@ -116,7 +116,7 @@ public override sealed string ToLoggableString(object value, ISessionFactoryImpl /// public abstract object FromStringValue(string xml); - public override void NullSafeSet(IDbCommand st, object value, int index, bool[] settable, ISessionImplementor session) + public override void NullSafeSet(DbCommand st, object value, int index, bool[] settable, ISessionImplementor session) { if (settable[0]) NullSafeSet(st, value, index); } @@ -126,36 +126,36 @@ public override void NullSafeSet(IDbCommand st, object value, int index, bool[] /// /> /// /// - /// This implementation forwards the call to . + /// This implementation forwards the call to . /// /// /// It has been "sealed" because the Types inheriting from /// do not need to and should not override this method. All of their implementation - /// should be in . + /// should be in . /// /// - public override sealed void NullSafeSet(IDbCommand st, object value, int index, ISessionImplementor session) + public override sealed void NullSafeSet(DbCommand st, object value, int index, ISessionImplementor session) { NullSafeSet(st, value, index); } /// - /// Puts the value from the mapped class into the . + /// Puts the value from the mapped class into the . /// - /// The to put the values into. + /// The to put the values into. /// The object that contains the values. - /// The index of the to write the value to. + /// The index of the to write the value to. /// /// /// This method checks to see if value is null, if it is then the value of - /// is written to the . + /// is written to the . /// /// - /// If the value is not null, then the method + /// If the value is not null, then the method /// is called and that method is responsible for setting the value. /// /// - public void NullSafeSet(IDbCommand cmd, object value, int index) + public void NullSafeSet(DbCommand cmd, object value, int index) { if (value == null) { @@ -168,7 +168,7 @@ public void NullSafeSet(IDbCommand cmd, object value, int index) // TODO: find out why a certain Parameter would not take a null value... // From reading the .NET SDK the default is to NOT accept a null value. // I definitely need to look into this more... - ((IDataParameter) cmd.Parameters[index]).Value = DBNull.Value; + cmd.Parameters[index].Value = DBNull.Value; } else { @@ -182,15 +182,15 @@ public void NullSafeSet(IDbCommand cmd, object value, int index) } /// /// /// This has been sealed because no other class should override it. This - /// method calls for a single value. + /// method calls for a single value. /// It only takes the first name from the string[] names parameter - that is a /// safe thing to do because a Nullable Type only has one field. /// - public override sealed object NullSafeGet(IDataReader rs, string[] names, ISessionImplementor session, object owner) + public override sealed object NullSafeGet(DbDataReader rs, string[] names, ISessionImplementor session, object owner) { return NullSafeGet(rs, names[0]); } @@ -210,15 +210,15 @@ public override sealed object NullSafeGet(IDataReader rs, string[] names, ISessi /// /// TODO: determine if this is needed /// - public virtual object NullSafeGet(IDataReader rs, string[] names) + public virtual object NullSafeGet(DbDataReader rs, string[] names) { return NullSafeGet(rs, names[0]); } /// - /// Gets the value of the field from the . + /// Gets the value of the field from the . /// - /// The positioned on the correct record. + /// The positioned on the correct record. /// The name of the field to get the value from. /// The value of the field. /// @@ -227,11 +227,11 @@ public virtual object NullSafeGet(IDataReader rs, string[] names) /// from this method. /// /// - /// If the value is not null, then the method + /// If the value is not null, then the method /// is called and that method is responsible for retrieving the value. /// /// - public virtual object NullSafeGet(IDataReader rs, string name) + public virtual object NullSafeGet(DbDataReader rs, string name) { int index = rs.GetOrdinal(name); @@ -270,19 +270,19 @@ public virtual object NullSafeGet(IDataReader rs, string name) } /// /// /// - /// This implementation forwards the call to . + /// This implementation forwards the call to . /// /// /// It has been "sealed" because the Types inheriting from /// do not need to and should not override this method. All of their implementation - /// should be in . + /// should be in . /// /// - public override sealed object NullSafeGet(IDataReader rs, string name, ISessionImplementor session, object owner) + public override sealed object NullSafeGet(DbDataReader rs, string name, ISessionImplementor session, object owner) { return NullSafeGet(rs, name); } diff --git a/src/NHibernate/Type/OneToOneType.cs b/src/NHibernate/Type/OneToOneType.cs index ab4a0eed4bf..d24e7533a3c 100644 --- a/src/NHibernate/Type/OneToOneType.cs +++ b/src/NHibernate/Type/OneToOneType.cs @@ -1,5 +1,5 @@ using System; -using System.Data; +using System.Data.Common; using NHibernate.Engine; using NHibernate.Persister.Entity; using NHibernate.SqlTypes; @@ -37,12 +37,12 @@ public OneToOneType(string referencedEntityName, ForeignKeyDirection foreignKeyT this.entityName = entityName; } - public override void NullSafeSet(IDbCommand st, object value, int index, bool[] settable, ISessionImplementor session) + public override void NullSafeSet(DbCommand st, object value, int index, bool[] settable, ISessionImplementor session) { //nothing to do } - public override void NullSafeSet(IDbCommand cmd, object value, int index, ISessionImplementor session) + public override void NullSafeSet(DbCommand cmd, object value, int index, ISessionImplementor session) { //nothing to do } @@ -89,7 +89,7 @@ public override ForeignKeyDirection ForeignKeyDirection get { return foreignKeyDirection; } } - public override object Hydrate(IDataReader rs, string[] names, ISessionImplementor session, object owner) + public override object Hydrate(DbDataReader rs, string[] names, ISessionImplementor session, object owner) { IType type = GetIdentifierOrUniqueKeyType(session.Factory); object identifier = session.GetContextEntityIdentifier(owner); diff --git a/src/NHibernate/Type/PersistentEnumType.cs b/src/NHibernate/Type/PersistentEnumType.cs index 18d541c6981..f5fab6876da 100644 --- a/src/NHibernate/Type/PersistentEnumType.cs +++ b/src/NHibernate/Type/PersistentEnumType.cs @@ -1,13 +1,11 @@ using System; using System.Collections.Generic; -using System.Data; +using System.Data.Common; using NHibernate.Engine; using NHibernate.SqlTypes; namespace NHibernate.Type { - using System.Runtime.Serialization; - /// /// PersistentEnumType /// @@ -179,7 +177,7 @@ public static IEnumConverter GetEnumCoverter(System.Type enumClass) return result; } - public override object Get(IDataReader rs, int index) + public override object Get(DbDataReader rs, int index) { object code = rs[index]; if (code == DBNull.Value || code == null) @@ -224,13 +222,12 @@ public virtual object GetValue(object code) } - public override void Set(IDbCommand cmd, object value, int index) + public override void Set(DbCommand cmd, object value, int index) { - IDataParameter par = (IDataParameter) cmd.Parameters[index]; - par.Value = value != null ? GetValue(value) : DBNull.Value; + cmd.Parameters[index].Value = value != null ? GetValue(value) : DBNull.Value; } - public override object Get(IDataReader rs, string name) + public override object Get(DbDataReader rs, string name) { return Get(rs, rs.GetOrdinal(name)); } diff --git a/src/NHibernate/Type/SByteType.cs b/src/NHibernate/Type/SByteType.cs index b0b4deb9de2..be6506e9c49 100644 --- a/src/NHibernate/Type/SByteType.cs +++ b/src/NHibernate/Type/SByteType.cs @@ -2,6 +2,7 @@ using System.Collections; using System.Collections.Generic; using System.Data; +using System.Data.Common; using NHibernate.Engine; using NHibernate.SqlTypes; @@ -26,7 +27,7 @@ public override string Name } private static readonly SByte ZERO = 0; - public override object Get(IDataReader rs, int index) + public override object Get(DbDataReader rs, int index) { try { @@ -38,7 +39,7 @@ public override object Get(IDataReader rs, int index) } } - public override object Get(IDataReader rs, string name) + public override object Get(DbDataReader rs, string name) { try { @@ -55,9 +56,9 @@ public override System.Type ReturnedClass get { return typeof(SByte); } } - public override void Set(IDbCommand rs, object value, int index) + public override void Set(DbCommand rs, object value, int index) { - ((IDataParameter)rs.Parameters[index]).Value = value; + rs.Parameters[index].Value = value; } public object StringToObject(string xml) diff --git a/src/NHibernate/Type/SerializableType.cs b/src/NHibernate/Type/SerializableType.cs index 68867d8ef85..5fe2f1deedb 100644 --- a/src/NHibernate/Type/SerializableType.cs +++ b/src/NHibernate/Type/SerializableType.cs @@ -1,5 +1,6 @@ using System; using System.Data; +using System.Data.Common; using System.IO; using System.Runtime.Serialization; using System.Runtime.Serialization.Formatters.Binary; @@ -46,17 +47,17 @@ internal SerializableType(System.Type serializableClass, BinarySqlType sqlType) binaryType = (BinaryType) TypeFactory.GetBinaryType(sqlType.Length); } - public override void Set(IDbCommand st, object value, int index) + public override void Set(DbCommand st, object value, int index) { binaryType.Set(st, ToBytes(value), index); } - public override object Get(IDataReader rs, string name) + public override object Get(DbDataReader rs, string name) { return Get(rs, rs.GetOrdinal(name)); } - public override object Get(IDataReader rs, int index) + public override object Get(DbDataReader rs, int index) { byte[] bytes = (byte[]) binaryType.Get(rs, index); if (bytes == null) diff --git a/src/NHibernate/Type/SingleType.cs b/src/NHibernate/Type/SingleType.cs index 4d6b6e0c458..0710e72c322 100644 --- a/src/NHibernate/Type/SingleType.cs +++ b/src/NHibernate/Type/SingleType.cs @@ -1,5 +1,6 @@ using System; using System.Data; +using System.Data.Common; using NHibernate.SqlTypes; namespace NHibernate.Type @@ -29,7 +30,7 @@ public override string Name } private static readonly Single ZERO = 0; - public override object Get(IDataReader rs, int index) + public override object Get(DbDataReader rs, int index) { try { @@ -41,7 +42,7 @@ public override object Get(IDataReader rs, int index) } } - public override object Get(IDataReader rs, string name) + public override object Get(DbDataReader rs, string name) { try { @@ -58,9 +59,9 @@ public override System.Type ReturnedClass get { return typeof(Single); } } - public override void Set(IDbCommand rs, object value, int index) + public override void Set(DbCommand rs, object value, int index) { - ((IDataParameter)rs.Parameters[index]).Value = value; + rs.Parameters[index].Value = value; } public object StringToObject(string xml) diff --git a/src/NHibernate/Type/SpecialOneToOneType.cs b/src/NHibernate/Type/SpecialOneToOneType.cs index b72c5ae00f4..120acff3913 100644 --- a/src/NHibernate/Type/SpecialOneToOneType.cs +++ b/src/NHibernate/Type/SpecialOneToOneType.cs @@ -1,4 +1,5 @@ using System; +using System.Data.Common; namespace NHibernate.Type { @@ -29,7 +30,7 @@ public override bool UseLHSPrimaryKey get { return false; } } - public override object Hydrate(System.Data.IDataReader rs, string[] names, Engine.ISessionImplementor session, object owner) + public override object Hydrate(DbDataReader rs, string[] names, Engine.ISessionImplementor session, object owner) { return GetIdentifierOrUniqueKeyType(session.Factory).NullSafeGet(rs, names, session, owner); } diff --git a/src/NHibernate/Type/StringClobType.cs b/src/NHibernate/Type/StringClobType.cs index 022f8252e22..135c4f05f9e 100644 --- a/src/NHibernate/Type/StringClobType.cs +++ b/src/NHibernate/Type/StringClobType.cs @@ -9,7 +9,7 @@ namespace NHibernate.Type /// /// /// This is only needed by DataProviders (SqlClient) that need to specify a Size for the - /// IDbDataParameter. Most DataProvider(Oralce) don't need to set the Size so a StringType + /// DbParameter. Most DataProvider(Oralce) don't need to set the Size so a StringType /// would work just fine. /// [Serializable] diff --git a/src/NHibernate/Type/TicksType.cs b/src/NHibernate/Type/TicksType.cs index 62a723f0b42..f566732ada0 100644 --- a/src/NHibernate/Type/TicksType.cs +++ b/src/NHibernate/Type/TicksType.cs @@ -2,6 +2,7 @@ using System.Collections; using System.Collections.Generic; using System.Data; +using System.Data.Common; using NHibernate.Engine; using NHibernate.SqlTypes; @@ -28,7 +29,7 @@ public TicksType() /// /// /// - public override object Get(IDataReader rs, int index) + public override object Get(DbDataReader rs, int index) { return new DateTime(Convert.ToInt64(rs[index])); } @@ -39,7 +40,7 @@ public override object Get(IDataReader rs, int index) /// /// /// - public override object Get(IDataReader rs, string name) + public override object Get(DbDataReader rs, string name) { return Get(rs, rs.GetOrdinal(name)); } @@ -56,9 +57,9 @@ public override System.Type ReturnedClass /// /// /// - public override void Set(IDbCommand st, object value, int index) + public override void Set(DbCommand st, object value, int index) { - ((IDataParameter)st.Parameters[index]).Value = ((DateTime)value).Ticks; + st.Parameters[index].Value = ((DateTime)value).Ticks; } /// diff --git a/src/NHibernate/Type/TimeAsTimeSpanType.cs b/src/NHibernate/Type/TimeAsTimeSpanType.cs index df6cbc97f2a..529ec8c3be8 100644 --- a/src/NHibernate/Type/TimeAsTimeSpanType.cs +++ b/src/NHibernate/Type/TimeAsTimeSpanType.cs @@ -1,9 +1,10 @@ using System; using System.Collections; -using System.Data; +using System.Data.Common; using NHibernate.Engine; using NHibernate.SqlTypes; using System.Collections.Generic; +using System.Data; namespace NHibernate.Type { @@ -27,7 +28,7 @@ public override string Name get { return "TimeAsTimeSpan"; } } - public override object Get(IDataReader rs, int index) + public override object Get(DbDataReader rs, int index) { try { @@ -43,7 +44,7 @@ public override object Get(IDataReader rs, int index) } } - public override object Get(IDataReader rs, string name) + public override object Get(DbDataReader rs, string name) { try { @@ -59,10 +60,10 @@ public override object Get(IDataReader rs, string name) } } - public override void Set(IDbCommand st, object value, int index) + public override void Set(DbCommand st, object value, int index) { DateTime date = BaseDateValue.AddTicks(((TimeSpan)value).Ticks); - ((IDataParameter) st.Parameters[index]).Value = date; + st.Parameters[index].Value = date; } public override System.Type ReturnedClass diff --git a/src/NHibernate/Type/TimeSpanType.cs b/src/NHibernate/Type/TimeSpanType.cs index 335269460fc..e15834a0853 100644 --- a/src/NHibernate/Type/TimeSpanType.cs +++ b/src/NHibernate/Type/TimeSpanType.cs @@ -1,9 +1,10 @@ using System; using System.Collections; -using System.Data; +using System.Data.Common; using NHibernate.Engine; using NHibernate.SqlTypes; using System.Collections.Generic; +using System.Data; namespace NHibernate.Type { @@ -25,7 +26,7 @@ public override string Name get { return "TimeSpan"; } } - public override object Get(IDataReader rs, int index) + public override object Get(DbDataReader rs, int index) { try { @@ -37,7 +38,7 @@ public override object Get(IDataReader rs, int index) } } - public override object Get(IDataReader rs, string name) + public override object Get(DbDataReader rs, string name) { try { @@ -61,9 +62,9 @@ public override System.Type ReturnedClass /// /// /// - public override void Set(IDbCommand st, object value, int index) + public override void Set(DbCommand st, object value, int index) { - ((IDataParameter)st.Parameters[index]).Value = ((TimeSpan)value).Ticks; + st.Parameters[index].Value = ((TimeSpan)value).Ticks; } public override string ToString(object val) diff --git a/src/NHibernate/Type/TimeType.cs b/src/NHibernate/Type/TimeType.cs index 4355ba510b4..dd74cae61b9 100644 --- a/src/NHibernate/Type/TimeType.cs +++ b/src/NHibernate/Type/TimeType.cs @@ -1,5 +1,6 @@ using System; using System.Data; +using System.Data.Common; using NHibernate.SqlTypes; namespace NHibernate.Type @@ -35,7 +36,7 @@ public override string Name get { return "Time"; } } - public override object Get(IDataReader rs, int index) + public override object Get(DbDataReader rs, int index) { try { @@ -54,7 +55,7 @@ public override object Get(IDataReader rs, int index) } } - public override object Get(IDataReader rs, string name) + public override object Get(DbDataReader rs, string name) { return Get(rs, rs.GetOrdinal(name)); } @@ -64,9 +65,9 @@ public override System.Type ReturnedClass get { return typeof(DateTime); } } - public override void Set(IDbCommand st, object value, int index) + public override void Set(DbCommand st, object value, int index) { - ((IDataParameter)st.Parameters[index]).Value = ((DateTime)value >= BaseDateValue) ? value : DBNull.Value; + st.Parameters[index].Value = ((DateTime)value >= BaseDateValue) ? value : DBNull.Value; } public override bool IsEqual(object x, object y) diff --git a/src/NHibernate/Type/TimestampType.cs b/src/NHibernate/Type/TimestampType.cs index 87bea1f9156..bd24650b718 100644 --- a/src/NHibernate/Type/TimestampType.cs +++ b/src/NHibernate/Type/TimestampType.cs @@ -1,6 +1,6 @@ using System; using System.Collections; -using System.Data; +using System.Data.Common; using NHibernate.Engine; using NHibernate.SqlTypes; @@ -34,12 +34,12 @@ public TimestampType() : base(SqlTypeFactory.DateTime) { } - public override object Get(IDataReader rs, int index) + public override object Get(DbDataReader rs, int index) { return Convert.ToDateTime(rs[index]); } - public override object Get(IDataReader rs, string name) + public override object Get(DbDataReader rs, string name) { return Get(rs, rs.GetOrdinal(name)); } @@ -50,17 +50,17 @@ public override System.Type ReturnedClass } /// - /// Sets the value of this Type in the IDbCommand. + /// Sets the value of this Type in the DbCommand. /// - /// The IDbCommand to add the Type's value to. + /// The DbCommand to add the Type's value to. /// The value of the Type. - /// The index of the IDataParameter in the IDbCommand. + /// The index of the DbParameter in the DbCommand. /// - /// No null values will be written to the IDbCommand for this Type. + /// No null values will be written to the DbCommand for this Type. /// - public override void Set(IDbCommand st, object value, int index) + public override void Set(DbCommand st, object value, int index) { - ((IDataParameter)st.Parameters[index]).Value = (value is DateTime) ? value:DateTime.Now; + st.Parameters[index].Value = (value is DateTime) ? value:DateTime.Now; } public override string Name diff --git a/src/NHibernate/Type/TypeType.cs b/src/NHibernate/Type/TypeType.cs index 5a9effd2cbe..cb323266868 100644 --- a/src/NHibernate/Type/TypeType.cs +++ b/src/NHibernate/Type/TypeType.cs @@ -1,5 +1,6 @@ using System; using System.Data; +using System.Data.Common; using NHibernate.SqlTypes; using NHibernate.Util; @@ -30,15 +31,15 @@ public override SqlType SqlType } /// - /// Gets the in the for the Property. + /// Gets the in the for the Property. /// - /// The that contains the value. + /// The that contains the value. /// The index of the field to get the value from. /// The from the database. /// /// Thrown when the value in the database can not be loaded as a /// - public override object Get(IDataReader rs, int index) + public override object Get(DbDataReader rs, int index) { string str = (string)NHibernateUtil.String.Get(rs, index); if (string.IsNullOrEmpty(str)) @@ -59,36 +60,36 @@ public override object Get(IDataReader rs, int index) } /// - /// Gets the in the for the Property. + /// Gets the in the for the Property. /// - /// The that contains the value. + /// The that contains the value. /// The name of the field to get the value from. /// The from the database. /// - /// This just calls gets the index of the name in the IDataReader - /// and calls the overloaded version - /// (IDataReader, Int32). + /// This just calls gets the index of the name in the DbDataReader + /// and calls the overloaded version + /// (DbDataReader, Int32). /// /// /// Thrown when the value in the database can not be loaded as a /// - public override object Get(IDataReader rs, string name) + public override object Get(DbDataReader rs, string name) { return Get(rs, rs.GetOrdinal(name)); } /// /// Puts the Assembly Qualified Name of the - /// Property into to the . + /// Property into to the . /// - /// The to put the value into. + /// The to put the value into. /// The that contains the value. - /// The index of the to start writing the value to. + /// The index of the to start writing the value to. /// - /// This uses the method of the + /// This uses the method of the /// object to do the work. /// - public override void Set(IDbCommand cmd, object value, int index) + public override void Set(DbCommand cmd, object value, int index) { NHibernateUtil.String.Set(cmd, ((System.Type)value).AssemblyQualifiedName, index); } diff --git a/src/NHibernate/Type/UInt16Type.cs b/src/NHibernate/Type/UInt16Type.cs index cfc3814e223..b7e6ab6295b 100644 --- a/src/NHibernate/Type/UInt16Type.cs +++ b/src/NHibernate/Type/UInt16Type.cs @@ -2,6 +2,7 @@ using System.Collections; using System.Collections.Generic; using System.Data; +using System.Data.Common; using NHibernate.Engine; using NHibernate.SqlTypes; @@ -26,7 +27,7 @@ public override string Name } private static readonly UInt16 ZERO = 0; - public override object Get(IDataReader rs, int index) + public override object Get(DbDataReader rs, int index) { try { @@ -38,7 +39,7 @@ public override object Get(IDataReader rs, int index) } } - public override object Get(IDataReader rs, string name) + public override object Get(DbDataReader rs, string name) { try { @@ -55,9 +56,9 @@ public override System.Type ReturnedClass get { return typeof(UInt16); } } - public override void Set(IDbCommand rs, object value, int index) + public override void Set(DbCommand rs, object value, int index) { - ((IDataParameter)rs.Parameters[index]).Value = value; + rs.Parameters[index].Value = value; } public object StringToObject(string xml) diff --git a/src/NHibernate/Type/UInt32Type.cs b/src/NHibernate/Type/UInt32Type.cs index 859f88c6534..8c0fc282508 100644 --- a/src/NHibernate/Type/UInt32Type.cs +++ b/src/NHibernate/Type/UInt32Type.cs @@ -2,6 +2,7 @@ using System.Collections; using System.Collections.Generic; using System.Data; +using System.Data.Common; using NHibernate.Engine; using NHibernate.SqlTypes; @@ -26,7 +27,7 @@ public override string Name } private static readonly UInt32 ZERO = 0; - public override object Get(IDataReader rs, int index) + public override object Get(DbDataReader rs, int index) { try { @@ -38,7 +39,7 @@ public override object Get(IDataReader rs, int index) } } - public override object Get(IDataReader rs, string name) + public override object Get(DbDataReader rs, string name) { try { @@ -55,9 +56,9 @@ public override System.Type ReturnedClass get { return typeof(UInt32); } } - public override void Set(IDbCommand rs, object value, int index) + public override void Set(DbCommand rs, object value, int index) { - ((IDataParameter)rs.Parameters[index]).Value = value; + rs.Parameters[index].Value = value; } public object StringToObject(string xml) diff --git a/src/NHibernate/Type/UInt64Type.cs b/src/NHibernate/Type/UInt64Type.cs index ad6e7124e98..b96d585909c 100644 --- a/src/NHibernate/Type/UInt64Type.cs +++ b/src/NHibernate/Type/UInt64Type.cs @@ -2,6 +2,7 @@ using System.Collections; using System.Collections.Generic; using System.Data; +using System.Data.Common; using NHibernate.Engine; using NHibernate.SqlTypes; @@ -25,7 +26,7 @@ public override string Name } private static readonly UInt32 ZERO = 0; - public override object Get(IDataReader rs, int index) + public override object Get(DbDataReader rs, int index) { try { @@ -37,7 +38,7 @@ public override object Get(IDataReader rs, int index) } } - public override object Get(IDataReader rs, string name) + public override object Get(DbDataReader rs, string name) { try { @@ -54,9 +55,9 @@ public override System.Type ReturnedClass get { return typeof(UInt64); } } - public override void Set(IDbCommand rs, object value, int index) + public override void Set(DbCommand rs, object value, int index) { - ((IDataParameter)rs.Parameters[index]).Value = value; + rs.Parameters[index].Value = value; } public object StringToObject(string xml) diff --git a/src/NHibernate/Type/UriType.cs b/src/NHibernate/Type/UriType.cs index 004241cdc08..716b9b8f6df 100644 --- a/src/NHibernate/Type/UriType.cs +++ b/src/NHibernate/Type/UriType.cs @@ -1,5 +1,5 @@ using System; -using System.Data; +using System.Data.Common; using NHibernate.SqlTypes; namespace NHibernate.Type @@ -31,17 +31,17 @@ public object StringToObject(string xml) return new Uri(xml, UriKind.RelativeOrAbsolute); } - public override void Set(IDbCommand cmd, object value, int index) + public override void Set(DbCommand cmd, object value, int index) { - ((IDataParameter)cmd.Parameters[index]).Value = ToString(value); + cmd.Parameters[index].Value = ToString(value); } - public override object Get(IDataReader rs, int index) + public override object Get(DbDataReader rs, int index) { return StringToObject(Convert.ToString(rs[index])); } - public override object Get(IDataReader rs, string name) + public override object Get(DbDataReader rs, string name) { return StringToObject(Convert.ToString(rs[name])); } diff --git a/src/NHibernate/Type/XDocType.cs b/src/NHibernate/Type/XDocType.cs index 52d483a91f6..25a103ba44f 100644 --- a/src/NHibernate/Type/XDocType.cs +++ b/src/NHibernate/Type/XDocType.cs @@ -1,5 +1,5 @@ using System; -using System.Data; +using System.Data.Common; using System.Xml.Linq; using NHibernate.SqlTypes; @@ -28,12 +28,12 @@ public override System.Type ReturnedClass get { return typeof (XDocument); } } - public override void Set(IDbCommand cmd, object value, int index) + public override void Set(DbCommand cmd, object value, int index) { - ((IDataParameter) cmd.Parameters[index]).Value = ((XDocument) value).ToString(SaveOptions.DisableFormatting); + cmd.Parameters[index].Value = ((XDocument) value).ToString(SaveOptions.DisableFormatting); } - public override object Get(IDataReader rs, int index) + public override object Get(DbDataReader rs, int index) { // according to documentation, GetValue should return a string, at list for MsSQL // hopefully all DataProvider has the same behaviour @@ -41,7 +41,7 @@ public override object Get(IDataReader rs, int index) return FromStringValue(xmlString); } - public override object Get(IDataReader rs, string name) + public override object Get(DbDataReader rs, string name) { return Get(rs, rs.GetOrdinal(name)); } diff --git a/src/NHibernate/Type/XmlDocType.cs b/src/NHibernate/Type/XmlDocType.cs index 99d55401286..e50ce7563a6 100644 --- a/src/NHibernate/Type/XmlDocType.cs +++ b/src/NHibernate/Type/XmlDocType.cs @@ -1,5 +1,5 @@ using System; -using System.Data; +using System.Data.Common; using System.Xml; using NHibernate.SqlTypes; @@ -28,12 +28,12 @@ public override System.Type ReturnedClass get { return typeof (XmlDocument); } } - public override void Set(IDbCommand cmd, object value, int index) + public override void Set(DbCommand cmd, object value, int index) { - ((IDataParameter) cmd.Parameters[index]).Value = ((XmlDocument) value).OuterXml; + cmd.Parameters[index].Value = ((XmlDocument) value).OuterXml; } - public override object Get(IDataReader rs, int index) + public override object Get(DbDataReader rs, int index) { // according to documentation, GetValue should return a string, at list for MsSQL // hopefully all DataProvider has the same behaviour @@ -41,7 +41,7 @@ public override object Get(IDataReader rs, int index) return FromStringValue(xmlString); } - public override object Get(IDataReader rs, string name) + public override object Get(DbDataReader rs, string name) { return Get(rs, rs.GetOrdinal(name)); } diff --git a/src/NHibernate/UserTypes/ICompositeUserType.cs b/src/NHibernate/UserTypes/ICompositeUserType.cs index d53d49fd6c6..6239b354d5f 100644 --- a/src/NHibernate/UserTypes/ICompositeUserType.cs +++ b/src/NHibernate/UserTypes/ICompositeUserType.cs @@ -1,5 +1,5 @@ using System; -using System.Data; +using System.Data.Common; using NHibernate.Engine; using NHibernate.Type; @@ -70,15 +70,15 @@ public interface ICompositeUserType int GetHashCode(object x); /// - /// Retrieve an instance of the mapped class from a IDataReader. Implementors + /// Retrieve an instance of the mapped class from a DbDataReader. Implementors /// should handle possibility of null values. /// - /// IDataReader + /// DbDataReader /// the column names /// /// the containing entity /// - object NullSafeGet(IDataReader dr, string[] names, ISessionImplementor session, object owner); + object NullSafeGet(DbDataReader dr, string[] names, ISessionImplementor session, object owner); /// /// Write an instance of the mapped class to a prepared statement. @@ -91,7 +91,7 @@ public interface ICompositeUserType /// /// /// - void NullSafeSet(IDbCommand cmd, object value, int index, bool[] settable, ISessionImplementor session); + void NullSafeSet(DbCommand cmd, object value, int index, bool[] settable, ISessionImplementor session); /// /// Return a deep copy of the persistent state, stopping at entities and at collections. diff --git a/src/NHibernate/UserTypes/IUserType.cs b/src/NHibernate/UserTypes/IUserType.cs index 4b700e1e275..ea8258066ce 100644 --- a/src/NHibernate/UserTypes/IUserType.cs +++ b/src/NHibernate/UserTypes/IUserType.cs @@ -1,4 +1,4 @@ -using System.Data; +using System.Data.Common; using NHibernate.SqlTypes; namespace NHibernate.UserTypes @@ -55,25 +55,25 @@ public interface IUserType /// Retrieve an instance of the mapped class from a JDBC resultset. /// Implementors should handle possibility of null values. /// - /// a IDataReader + /// a DbDataReader /// column names /// the containing entity /// /// HibernateException // /// SQLException - object NullSafeGet(IDataReader rs, string[] names, object owner); + object NullSafeGet(DbDataReader rs, string[] names, object owner); /// /// Write an instance of the mapped class to a prepared statement. /// Implementors should handle possibility of null values. /// A multi-column type should be written to parameters starting from index. /// - /// a IDbCommand + /// a DbCommand /// the object to write /// command parameter index /// HibernateException // /// SQLException - void NullSafeSet(IDbCommand cmd, object value, int index); + void NullSafeSet(DbCommand cmd, object value, int index); /// /// Return a deep copy of the persistent state, stopping at entities and at collections. From c9cf75ef6fd980277945d2f51f8d557f66d79df6 Mon Sep 17 00:00:00 2001 From: Alexander Zaytsev Date: Fri, 6 Dec 2013 13:12:56 +1300 Subject: [PATCH 2/3] NH-3431 - Fix implementation of DbDataReader inheritors --- src/NHibernate/AdoNet/ResultSetWrapper.cs | 109 +++++++------- .../Driver/BasicResultSetsCommand.cs | 84 +++++------ src/NHibernate/Driver/NDataReader.cs | 109 ++++++-------- src/NHibernate/Driver/NHybridDataReader.cs | 134 +++++++----------- 4 files changed, 193 insertions(+), 243 deletions(-) diff --git a/src/NHibernate/AdoNet/ResultSetWrapper.cs b/src/NHibernate/AdoNet/ResultSetWrapper.cs index f3a291e971e..75e03a3ef5e 100644 --- a/src/NHibernate/AdoNet/ResultSetWrapper.cs +++ b/src/NHibernate/AdoNet/ResultSetWrapper.cs @@ -1,4 +1,5 @@ using System; +using System.Collections; using System.Data; using System.Data.Common; @@ -12,7 +13,7 @@ namespace NHibernate.AdoNet /// public class ResultSetWrapper : DbDataReader { - private readonly DbDataReader rs; + private DbDataReader rs; private readonly ColumnNameCache columnNameCache; public ResultSetWrapper(DbDataReader resultSet, ColumnNameCache columnNameCache) @@ -26,206 +27,192 @@ internal DbDataReader Target get { return rs; } } - #region DbDataReader Members - - public void Close() + public override void Close() { rs.Close(); } - public DataTable GetSchemaTable() + public override DataTable GetSchemaTable() { return rs.GetSchemaTable(); } - public bool NextResult() + public override bool NextResult() { return rs.NextResult(); } - public bool Read() + public override bool Read() { return rs.Read(); } - public int Depth + public override int Depth { get { return rs.Depth; } } - public bool IsClosed + public override bool HasRows { - get { return rs.IsClosed; } + get { return rs.HasRows; } } - public int RecordsAffected + public override bool IsClosed { - get { return rs.RecordsAffected; } + get { return rs.IsClosed; } } - #endregion - - #region IDisposable Members - private bool disposed; - - ~ResultSetWrapper() + public override int RecordsAffected { - Dispose(false); + get { return rs.RecordsAffected; } } - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } + private bool disposed; - private void Dispose(bool disposing) + protected override void Dispose(bool disposing) { if (disposed) return; - if (disposing) + if (disposing && rs != null) { - if (rs != null) - { - if (!rs.IsClosed) rs.Close(); rs.Dispose(); + rs = null; } - } disposed = true; } - #endregion - - #region IDataRecord Members - public string GetName(int i) + public override string GetName(int i) { return rs.GetName(i); } - public string GetDataTypeName(int i) + public override string GetDataTypeName(int i) { return rs.GetDataTypeName(i); } - public System.Type GetFieldType(int i) + public override IEnumerator GetEnumerator() + { + return rs.GetEnumerator(); + } + + public override System.Type GetFieldType(int i) { return rs.GetFieldType(i); } - public object GetValue(int i) + public override object GetValue(int i) { return rs.GetValue(i); } - public int GetValues(object[] values) + public override int GetValues(object[] values) { return rs.GetValues(values); } - public int GetOrdinal(string name) + public override int GetOrdinal(string name) { return columnNameCache.GetIndexForColumnName(name, this); } - public bool GetBoolean(int i) + public override bool GetBoolean(int i) { return rs.GetBoolean(i); } - public byte GetByte(int i) + public override byte GetByte(int i) { return rs.GetByte(i); } - public long GetBytes(int i, long fieldOffset, byte[] buffer, int bufferoffset, int length) + public override long GetBytes(int i, long fieldOffset, byte[] buffer, int bufferoffset, int length) { return rs.GetBytes(i, fieldOffset, buffer, bufferoffset, length); } - public char GetChar(int i) + public override char GetChar(int i) { return rs.GetChar(i); } - public long GetChars(int i, long fieldoffset, char[] buffer, int bufferoffset, int length) + public override long GetChars(int i, long fieldoffset, char[] buffer, int bufferoffset, int length) { return rs.GetChars(i, fieldoffset, buffer, bufferoffset, length); } - public Guid GetGuid(int i) + public override Guid GetGuid(int i) { return rs.GetGuid(i); } - public short GetInt16(int i) + public override short GetInt16(int i) { return rs.GetInt16(i); } - public int GetInt32(int i) + public override int GetInt32(int i) { return rs.GetInt32(i); } - public long GetInt64(int i) + public override long GetInt64(int i) { return rs.GetInt64(i); } - public float GetFloat(int i) + public override float GetFloat(int i) { return rs.GetFloat(i); } - public double GetDouble(int i) + public override double GetDouble(int i) { return rs.GetDouble(i); } - public string GetString(int i) + public override string GetString(int i) { return rs.GetString(i); } - public decimal GetDecimal(int i) + public override decimal GetDecimal(int i) { return rs.GetDecimal(i); } - public DateTime GetDateTime(int i) + public override DateTime GetDateTime(int i) { return rs.GetDateTime(i); } - public DbDataReader GetData(int i) + protected override DbDataReader GetDbDataReader(int ordinal) { - return rs.GetData(i); + return rs.GetData(ordinal); } - public bool IsDBNull(int i) + public override bool IsDBNull(int i) { return rs.IsDBNull(i); } - public int FieldCount + public override int FieldCount { get { return rs.FieldCount; } } - public object this[int i] + public override object this[int i] { get { return rs[i]; } } - public object this[string name] + public override object this[string name] { get { return rs[columnNameCache.GetIndexForColumnName(name, this)]; } } - #endregion - public override bool Equals(object obj) { return rs.Equals(obj); diff --git a/src/NHibernate/Driver/BasicResultSetsCommand.cs b/src/NHibernate/Driver/BasicResultSetsCommand.cs index a67bee32280..aff389091c3 100644 --- a/src/NHibernate/Driver/BasicResultSetsCommand.cs +++ b/src/NHibernate/Driver/BasicResultSetsCommand.cs @@ -1,4 +1,5 @@ using System; +using System.Collections; using System.Collections.Generic; using System.Data; using System.Data.Common; @@ -100,140 +101,141 @@ public BatcherDataReaderWrapper(IBatcher batcher, DbCommand command) reader = batcher.ExecuteReader(command); } - public void Dispose() + public override string GetName(int i) { - batcher.CloseCommand(command, reader); + return reader.GetName(i); } - #region IDataRecord Members - - public string GetName(int i) + public override string GetDataTypeName(int i) { - return reader.GetName(i); + return reader.GetDataTypeName(i); } - public string GetDataTypeName(int i) + public override IEnumerator GetEnumerator() { - return reader.GetDataTypeName(i); + return reader.GetEnumerator(); } - public System.Type GetFieldType(int i) + public override System.Type GetFieldType(int i) { return reader.GetFieldType(i); } - public object GetValue(int i) + public override object GetValue(int i) { return reader.GetValue(i); } - public int GetValues(object[] values) + public override int GetValues(object[] values) { return reader.GetValues(values); } - public int GetOrdinal(string name) + public override int GetOrdinal(string name) { return reader.GetOrdinal(name); } - public bool GetBoolean(int i) + public override bool GetBoolean(int i) { return reader.GetBoolean(i); } - public byte GetByte(int i) + public override byte GetByte(int i) { return reader.GetByte(i); } - public long GetBytes(int i, long fieldOffset, byte[] buffer, int bufferoffset, int length) + public override long GetBytes(int i, long fieldOffset, byte[] buffer, int bufferoffset, int length) { return reader.GetBytes(i, fieldOffset, buffer, bufferoffset, length); } - public char GetChar(int i) + public override char GetChar(int i) { return reader.GetChar(i); } - public long GetChars(int i, long fieldoffset, char[] buffer, int bufferoffset, int length) + public override long GetChars(int i, long fieldoffset, char[] buffer, int bufferoffset, int length) { return reader.GetChars(i, fieldoffset, buffer, bufferoffset, length); } - public Guid GetGuid(int i) + public override Guid GetGuid(int i) { return reader.GetGuid(i); } - public short GetInt16(int i) + public override short GetInt16(int i) { return reader.GetInt16(i); } - public int GetInt32(int i) + public override int GetInt32(int i) { return reader.GetInt32(i); } - public long GetInt64(int i) + public override long GetInt64(int i) { return reader.GetInt64(i); } - public float GetFloat(int i) + public override float GetFloat(int i) { return reader.GetFloat(i); } - public double GetDouble(int i) + public override double GetDouble(int i) { return reader.GetDouble(i); } - public string GetString(int i) + public override string GetString(int i) { return reader.GetString(i); } - public decimal GetDecimal(int i) + public override decimal GetDecimal(int i) { return reader.GetDecimal(i); } - public DateTime GetDateTime(int i) + public override DateTime GetDateTime(int i) { return reader.GetDateTime(i); } - public DbDataReader GetData(int i) + protected override DbDataReader GetDbDataReader(int ordinal) { - return reader.GetData(i); + return reader.GetData(ordinal); } - public bool IsDBNull(int i) + public override bool IsDBNull(int i) { return reader.IsDBNull(i); } - public int FieldCount + public override int FieldCount { get { return reader.FieldCount; } } - public object this[int i] + public override bool HasRows + { + get { return reader.HasRows; } + } + + public override object this[int i] { get { return reader[i]; } } - public object this[string name] + public override object this[string name] { get { return reader[name]; } } - #endregion - public override bool Equals(object obj) { return reader.Equals(obj); @@ -244,37 +246,37 @@ public override int GetHashCode() return reader.GetHashCode(); } - public void Close() + public override void Close() { batcher.CloseCommand(command, reader); } - public DataTable GetSchemaTable() + public override DataTable GetSchemaTable() { return reader.GetSchemaTable(); } - public bool NextResult() + public override bool NextResult() { return reader.NextResult(); } - public bool Read() + public override bool Read() { return reader.Read(); } - public int Depth + public override int Depth { get { return reader.Depth; } } - public bool IsClosed + public override bool IsClosed { get { return reader.IsClosed; } } - public int RecordsAffected + public override int RecordsAffected { get { return reader.RecordsAffected; } } diff --git a/src/NHibernate/Driver/NDataReader.cs b/src/NHibernate/Driver/NDataReader.cs index 9f345bce966..d70e4c1a030 100644 --- a/src/NHibernate/Driver/NDataReader.cs +++ b/src/NHibernate/Driver/NDataReader.cs @@ -1,7 +1,8 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Data;using System.Data.Common; +using System.Data; +using System.Data.Common; using NHibernate.Util; namespace NHibernate.Driver @@ -19,7 +20,7 @@ public class NDataReader : DbDataReader { private NResult[] results; - private bool isClosed = false; + private bool isClosed; // a DataReader is positioned before the first valid record private int currentRowIndex = -1; @@ -99,22 +100,25 @@ private object GetValue(string name) return GetCurrentResult().GetValue(currentRowIndex, name); } - #region DbDataReader Members - /// - public int RecordsAffected + public override int RecordsAffected { get { throw new NotImplementedException("NDataReader should only be used for SELECT statements!"); } } + public override bool HasRows + { + get { return results.LongLength > 0; } + } + /// - public bool IsClosed + public override bool IsClosed { get { return isClosed; } } /// - public bool NextResult() + public override bool NextResult() { currentResultIndex++; currentRowIndex = -1; @@ -131,13 +135,13 @@ public bool NextResult() } /// - public void Close() + public override void Close() { isClosed = true; } /// - public bool Read() + public override bool Read() { currentRowIndex++; @@ -154,59 +158,42 @@ public bool Read() } /// - public int Depth + public override int Depth { get { return currentResultIndex; } } /// - public DataTable GetSchemaTable() + public override DataTable GetSchemaTable() { return GetCurrentResult().GetSchemaTable(); } - #endregion - - #region IDisposable Members - - /// - /// Takes care of freeing the managed and unmanaged resources that - /// this class is responsible for. - /// - /// - /// There are not any unmanaged resources or any disposable managed - /// resources that this class is holding onto. It is in here - /// to comply with the interface. - /// - public void Dispose() + protected override void Dispose(bool disposing) { isClosed = true; ClearCache(); results = null; } - #endregion - - #region IDataRecord Members - /// /// /// /// /// - public int GetInt32(int i) + public override int GetInt32(int i) { return Convert.ToInt32(GetValue(i)); } /// - public object this[string name] + public override object this[string name] { get { return GetValue(name); } } /// - public object this[int i] + public override object this[int i] { get { return GetValue(i); } } @@ -216,7 +203,7 @@ public object this[int i] /// /// /// - public object GetValue(int i) + public override object GetValue(int i) { return GetCurrentResult().GetValue(currentRowIndex, i); } @@ -226,7 +213,7 @@ public object GetValue(int i) /// /// /// - public bool IsDBNull(int i) + public override bool IsDBNull(int i) { return GetValue(i).Equals(DBNull.Value); } @@ -240,7 +227,7 @@ public bool IsDBNull(int i) /// /// /// - public long GetBytes(int i, long fieldOffset, byte[] buffer, int bufferOffset, int length) + public override long GetBytes(int i, long fieldOffset, byte[] buffer, int bufferOffset, int length) { if (cachedByteArray == null || cachedColIndex != i) { @@ -270,17 +257,22 @@ public long GetBytes(int i, long fieldOffset, byte[] buffer, int bufferOffset, i /// /// /// - public byte GetByte(int i) + public override byte GetByte(int i) { return Convert.ToByte(GetValue(i)); } + public override IEnumerator GetEnumerator() + { + throw new NotImplementedException(); + } + /// /// /// /// /// - public System.Type GetFieldType(int i) + public override System.Type GetFieldType(int i) { return GetCurrentResult().GetFieldType(i); } @@ -290,7 +282,7 @@ public System.Type GetFieldType(int i) /// /// /// - public decimal GetDecimal(int i) + public override decimal GetDecimal(int i) { return Convert.ToDecimal(GetValue(i)); } @@ -300,7 +292,7 @@ public decimal GetDecimal(int i) /// /// /// - public int GetValues(object[] values) + public override int GetValues(object[] values) { return GetCurrentResult().GetValues(currentRowIndex, values); } @@ -310,13 +302,13 @@ public int GetValues(object[] values) /// /// /// - public string GetName(int i) + public override string GetName(int i) { return GetCurrentResult().GetName(i); } /// - public int FieldCount + public override int FieldCount { get { return GetCurrentResult().GetFieldCount(); } } @@ -326,7 +318,7 @@ public int FieldCount /// /// /// - public long GetInt64(int i) + public override long GetInt64(int i) { return Convert.ToInt64(GetValue(i)); } @@ -336,7 +328,7 @@ public long GetInt64(int i) /// /// /// - public double GetDouble(int i) + public override double GetDouble(int i) { return Convert.ToDouble(GetValue(i)); } @@ -346,7 +338,7 @@ public double GetDouble(int i) /// /// /// - public bool GetBoolean(int i) + public override bool GetBoolean(int i) { return Convert.ToBoolean(GetValue(i)); } @@ -356,7 +348,7 @@ public bool GetBoolean(int i) /// /// /// - public Guid GetGuid(int i) + public override Guid GetGuid(int i) { return (Guid) GetValue(i); } @@ -366,7 +358,7 @@ public Guid GetGuid(int i) /// /// /// - public DateTime GetDateTime(int i) + public override DateTime GetDateTime(int i) { return Convert.ToDateTime(GetValue(i)); } @@ -376,7 +368,7 @@ public DateTime GetDateTime(int i) /// /// /// - public int GetOrdinal(string name) + public override int GetOrdinal(string name) { return GetCurrentResult().GetOrdinal(name); } @@ -386,7 +378,7 @@ public int GetOrdinal(string name) /// /// /// - public string GetDataTypeName(int i) + public override string GetDataTypeName(int i) { return GetCurrentResult().GetDataTypeName(i); } @@ -396,19 +388,14 @@ public string GetDataTypeName(int i) /// /// /// - public float GetFloat(int i) + public override float GetFloat(int i) { return Convert.ToSingle(GetValue(i)); } - /// - /// - /// - /// - /// - public DbDataReader GetData(int i) + protected override DbDataReader GetDbDataReader(int ordinal) { - throw new NotImplementedException("GetData(int) has not been implemented."); + throw new NotImplementedException("GetDbDataReader(int) has not been implemented."); } /// @@ -420,7 +407,7 @@ public DbDataReader GetData(int i) /// /// /// - public long GetChars(int i, long fieldOffset, char[] buffer, int bufferOffset, int length) + public override long GetChars(int i, long fieldOffset, char[] buffer, int bufferOffset, int length) { if (cachedCharArray == null || cachedColIndex != i) { @@ -445,7 +432,7 @@ public long GetChars(int i, long fieldOffset, char[] buffer, int bufferOffset, i /// /// /// - public string GetString(int i) + public override string GetString(int i) { return Convert.ToString(GetValue(i)); } @@ -455,7 +442,7 @@ public string GetString(int i) /// /// /// - public char GetChar(int i) + public override char GetChar(int i) { return Convert.ToChar(GetValue(i)); } @@ -465,13 +452,11 @@ public char GetChar(int i) /// /// /// - public short GetInt16(int i) + public override short GetInt16(int i) { return Convert.ToInt16(GetValue(i)); } - #endregion - /// /// Stores a Result from a DataReader in memory. /// diff --git a/src/NHibernate/Driver/NHybridDataReader.cs b/src/NHibernate/Driver/NHybridDataReader.cs index 94cffd14d09..a168e46fd2a 100644 --- a/src/NHibernate/Driver/NHybridDataReader.cs +++ b/src/NHibernate/Driver/NHybridDataReader.cs @@ -1,6 +1,7 @@ using System; -using System.Data;using System.Data.Common; - +using System.Collections; +using System.Data; +using System.Data.Common; namespace NHibernate.Driver { @@ -22,10 +23,10 @@ namespace NHibernate.Driver ///
public class NHybridDataReader : DbDataReader { - private IInternalLogger log = LoggerProvider.LoggerFor(typeof(NHybridDataReader)); + private readonly IInternalLogger log = LoggerProvider.LoggerFor(typeof(NHybridDataReader)); private DbDataReader _reader; - private bool _isMidstream = false; + private bool _isMidstream; public DbDataReader Target { get { return _reader; } } @@ -82,22 +83,25 @@ public bool IsMidstream get { return _isMidstream; } } - #region DbDataReader Members - /// - public int RecordsAffected + public override int RecordsAffected { get { return _reader.RecordsAffected; } } + public override bool HasRows + { + get { return _reader.HasRows; } + } + /// - public bool IsClosed + public override bool IsClosed { get { return _reader.IsClosed; } } /// - public bool NextResult() + public override bool NextResult() { // we are not in middle of a result _isMidstream = false; @@ -105,38 +109,34 @@ public bool NextResult() } /// - public void Close() + public override void Close() { _reader.Close(); } /// - public bool Read() + public override bool Read() { _isMidstream = _reader.Read(); return _isMidstream; } /// - public int Depth + public override int Depth { get { return _reader.Depth; } } /// - public DataTable GetSchemaTable() + public override DataTable GetSchemaTable() { return _reader.GetSchemaTable(); } - #endregion - - #region IDisposable Members - /// /// A flag to indicate if Disose() has been called. /// - private bool _isAlreadyDisposed; + private bool disposed; /// /// Finalizer that ensures the object is correctly disposed of. @@ -150,65 +150,43 @@ public DataTable GetSchemaTable() /// Takes care of freeing the managed and unmanaged resources that /// this class is responsible for. /// - public void Dispose() - { - log.Debug("running NHybridDataReader.Dispose()"); - Dispose(true); - } - - /// - /// Takes care of freeing the managed and unmanaged resources that - /// this class is responsible for. - /// - /// Indicates if this NHybridDataReader is being Disposed of or Finalized. + /// Indicates if this NHybridDataReader is being Disposed of or Finalized. /// /// If this NHybridDataReader is being Finalized (isDisposing==false) then make sure not /// to call any methods that could potentially bring this NHybridDataReader back to life. /// - protected virtual void Dispose(bool isDisposing) + protected override void Dispose(bool disposing) { - if (_isAlreadyDisposed) - { - // don't dispose of multiple times. + if (disposed) return; - } - // free managed resources that are being managed by the NHybridDataReader if we - // know this call came through Dispose() - if (isDisposing) + if (disposing && _reader != null) { _reader.Dispose(); + _reader = null; } - // free unmanaged resources here - - _isAlreadyDisposed = true; - // nothing for Finalizer to do - so tell the GC to ignore it - GC.SuppressFinalize(this); + disposed = true; } - #endregion - - #region IDataRecord Members - /// /// /// /// /// - public int GetInt32(int i) + public override int GetInt32(int i) { return _reader.GetInt32(i); } /// - public object this[string name] + public override object this[string name] { get { return _reader[name]; } } /// - object IDataRecord.this[int i] + public override object this[int i] { get { return _reader[i]; } } @@ -218,7 +196,7 @@ object IDataRecord.this[int i] /// /// /// - public object GetValue(int i) + public override object GetValue(int i) { return _reader.GetValue(i); } @@ -228,7 +206,7 @@ public object GetValue(int i) /// /// /// - public bool IsDBNull(int i) + public override bool IsDBNull(int i) { return _reader.IsDBNull(i); } @@ -242,7 +220,7 @@ public bool IsDBNull(int i) /// /// /// - public long GetBytes(int i, long fieldOffset, byte[] buffer, int bufferoffset, int length) + public override long GetBytes(int i, long fieldOffset, byte[] buffer, int bufferoffset, int length) { return _reader.GetBytes(i, fieldOffset, buffer, bufferoffset, length); } @@ -252,17 +230,22 @@ public long GetBytes(int i, long fieldOffset, byte[] buffer, int bufferoffset, i /// /// /// - public byte GetByte(int i) + public override byte GetByte(int i) { return _reader.GetByte(i); } + public override IEnumerator GetEnumerator() + { + return _reader.GetEnumerator(); + } + /// /// /// /// /// - public System.Type GetFieldType(int i) + public override System.Type GetFieldType(int i) { return _reader.GetFieldType(i); } @@ -272,7 +255,7 @@ public System.Type GetFieldType(int i) /// /// /// - public decimal GetDecimal(int i) + public override decimal GetDecimal(int i) { return _reader.GetDecimal(i); } @@ -282,7 +265,7 @@ public decimal GetDecimal(int i) /// /// /// - public int GetValues(object[] values) + public override int GetValues(object[] values) { return _reader.GetValues(values); } @@ -292,13 +275,13 @@ public int GetValues(object[] values) /// /// /// - public string GetName(int i) + public override string GetName(int i) { return _reader.GetName(i); } /// - public int FieldCount + public override int FieldCount { get { return _reader.FieldCount; } } @@ -308,7 +291,7 @@ public int FieldCount /// /// /// - public long GetInt64(int i) + public override long GetInt64(int i) { return _reader.GetInt64(i); } @@ -318,7 +301,7 @@ public long GetInt64(int i) /// /// /// - public double GetDouble(int i) + public override double GetDouble(int i) { return _reader.GetDouble(i); } @@ -328,7 +311,7 @@ public double GetDouble(int i) /// /// /// - public bool GetBoolean(int i) + public override bool GetBoolean(int i) { return _reader.GetBoolean(i); } @@ -338,7 +321,7 @@ public bool GetBoolean(int i) /// /// /// - public Guid GetGuid(int i) + public override Guid GetGuid(int i) { return _reader.GetGuid(i); } @@ -348,7 +331,7 @@ public Guid GetGuid(int i) /// /// /// - public DateTime GetDateTime(int i) + public override DateTime GetDateTime(int i) { return _reader.GetDateTime(i); } @@ -358,7 +341,7 @@ public DateTime GetDateTime(int i) /// /// /// - public int GetOrdinal(string name) + public override int GetOrdinal(string name) { return _reader.GetOrdinal(name); } @@ -368,7 +351,7 @@ public int GetOrdinal(string name) /// /// /// - public string GetDataTypeName(int i) + public override string GetDataTypeName(int i) { return _reader.GetDataTypeName(i); } @@ -378,19 +361,14 @@ public string GetDataTypeName(int i) /// /// /// - public float GetFloat(int i) + public override float GetFloat(int i) { return _reader.GetFloat(i); } - /// - /// - /// - /// - /// - public DbDataReader GetData(int i) + protected override DbDataReader GetDbDataReader(int ordinal) { - return _reader.GetData(i); + return _reader.GetData(ordinal); } /// @@ -402,7 +380,7 @@ public DbDataReader GetData(int i) /// /// /// - public long GetChars(int i, long fieldoffset, char[] buffer, int bufferoffset, int length) + public override long GetChars(int i, long fieldoffset, char[] buffer, int bufferoffset, int length) { return _reader.GetChars(i, fieldoffset, buffer, bufferoffset, length); } @@ -412,7 +390,7 @@ public long GetChars(int i, long fieldoffset, char[] buffer, int bufferoffset, i /// /// /// - public string GetString(int i) + public override string GetString(int i) { return _reader.GetString(i); } @@ -422,7 +400,7 @@ public string GetString(int i) /// /// /// - public char GetChar(int i) + public override char GetChar(int i) { return _reader.GetChar(i); } @@ -432,11 +410,9 @@ public char GetChar(int i) /// /// /// - public short GetInt16(int i) + public override short GetInt16(int i) { return _reader.GetInt16(i); } - - #endregion } } \ No newline at end of file From f209c2b08cdcb02abe15fb1e86a82d7f03cdcf45 Mon Sep 17 00:00:00 2001 From: Alexander Zaytsev Date: Fri, 6 Dec 2013 13:59:18 +1300 Subject: [PATCH 3/3] NH-3431 - Fix AbstractBatcher.CloseReader method which tried to use reader after it was disposed. --- src/NHibernate/AdoNet/AbstractBatcher.cs | 25 ++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/NHibernate/AdoNet/AbstractBatcher.cs b/src/NHibernate/AdoNet/AbstractBatcher.cs index 851f6cf3e12..e295c4f5bfe 100644 --- a/src/NHibernate/AdoNet/AbstractBatcher.cs +++ b/src/NHibernate/AdoNet/AbstractBatcher.cs @@ -359,6 +359,8 @@ public void CloseReader(DbDataReader reader) var actualReader = rsw == null ? reader : rsw.Target; _readersToClose.Remove(actualReader); + var duration = GetReaderStopwatch(actualReader); + try { reader.Dispose(); @@ -370,17 +372,24 @@ public void CloseReader(DbDataReader reader) } LogCloseReader(); + LogDuration(duration); + } - if (!Log.IsDebugEnabled) - return; - - var nhReader = actualReader as NHybridDataReader; - actualReader = nhReader == null ? actualReader : nhReader.Target; + private Stopwatch GetReaderStopwatch(DbDataReader reader) + { + var nhReader = reader as NHybridDataReader; + var actualReader = nhReader == null ? reader : nhReader.Target; Stopwatch duration; - if (_readersDuration.TryGetValue(actualReader, out duration) == false) - return; - _readersDuration.Remove(actualReader); + if (_readersDuration.TryGetValue(actualReader, out duration)) + _readersDuration.Remove(actualReader); + return duration; + } + + private static void LogDuration(Stopwatch duration) + { + if (!Log.IsDebugEnabled || duration == null) return; + Log.DebugFormat("DataReader was closed after {0} ms", duration.ElapsedMilliseconds); }