From 8e070ddca5dde5a3ffc94377c68ddd9cbccf68d0 Mon Sep 17 00:00:00 2001 From: Nick Craver Date: Mon, 23 May 2016 20:43:30 -0400 Subject: [PATCH] Interfaces are back, simplifying code. Related issue: #520 --- Dapper.Contrib/SqlMapperExtensions.Async.cs | 8 +- Dapper.Contrib/SqlMapperExtensions.cs | 2 - Dapper.Rainbow/Database.Async.cs | 4 - Dapper.Rainbow/Database.cs | 4 - Dapper.Tests.Contrib/TestSuite.cs | 5 +- Dapper.Tests.Contrib/TestSuites.cs | 1 - Dapper.Tests/Tests.Async.cs | 4 - Dapper.Tests/Tests.Constructors.cs | 8 -- Dapper.Tests/Tests.Enums.cs | 8 -- Dapper.Tests/Tests.MultiMap.cs | 8 -- Dapper.Tests/Tests.Parameters.cs | 8 -- Dapper.Tests/Tests.QueryMultiple.cs | 9 -- Dapper.Tests/Tests.cs | 63 ---------- Dapper/CommandDefinition.cs | 6 - Dapper/DbString.cs | 4 - Dapper/DefaultTypeMap.cs | 3 + Dapper/DynamicParameters.ParamInfo.cs | 3 - Dapper/DynamicParameters.cs | 2 - Dapper/FeatureSupport.cs | 3 - Dapper/SqlMapper.Async.cs | 7 -- Dapper/SqlMapper.CacheInfo.cs | 5 - Dapper/SqlMapper.DeserializerState.cs | 4 - Dapper/SqlMapper.GridReader.Async.cs | 5 +- Dapper/SqlMapper.GridReader.cs | 5 - Dapper/SqlMapper.ICustomQueryParameter.cs | 3 - Dapper/SqlMapper.IDataReader.cs | 4 - Dapper/SqlMapper.IDynamicParameters.cs | 4 - Dapper/SqlMapper.ITypeHandler.cs | 3 - Dapper/SqlMapper.Identity.cs | 4 - Dapper/SqlMapper.TypeDeserializerCache.cs | 6 +- Dapper/SqlMapper.TypeHandler.cs | 4 - Dapper/SqlMapper.TypeHandlerCache.cs | 4 - Dapper/SqlMapper.cs | 16 +-- Dapper/WrappedDataReader.cs | 23 ---- Dapper/WrappedReader.cs | 124 -------------------- Dapper/XmlHandlers.cs | 3 - 36 files changed, 11 insertions(+), 366 deletions(-) diff --git a/Dapper.Contrib/SqlMapperExtensions.Async.cs b/Dapper.Contrib/SqlMapperExtensions.Async.cs index 972c641a8..f4c320680 100644 --- a/Dapper.Contrib/SqlMapperExtensions.Async.cs +++ b/Dapper.Contrib/SqlMapperExtensions.Async.cs @@ -1,19 +1,13 @@ #if ASYNC using System; using System.Collections.Generic; +using System.Data; using System.Linq; using System.Reflection; using System.Text; using System.Threading.Tasks; using Dapper; -#if COREFX -using IDbTransaction = System.Data.Common.DbTransaction; -using IDbConnection = System.Data.Common.DbConnection; -using DataException = System.InvalidOperationException; -#else -using System.Data; -#endif namespace Dapper.Contrib.Extensions { diff --git a/Dapper.Contrib/SqlMapperExtensions.cs b/Dapper.Contrib/SqlMapperExtensions.cs index 1362e1a54..11c947b26 100644 --- a/Dapper.Contrib/SqlMapperExtensions.cs +++ b/Dapper.Contrib/SqlMapperExtensions.cs @@ -10,8 +10,6 @@ using Dapper; #if COREFX -using IDbTransaction = System.Data.Common.DbTransaction; -using IDbConnection = System.Data.Common.DbConnection; using DataException = System.InvalidOperationException; #else using System.Threading; diff --git a/Dapper.Rainbow/Database.Async.cs b/Dapper.Rainbow/Database.Async.cs index 6b94ba59d..f7c6a4b29 100644 --- a/Dapper.Rainbow/Database.Async.cs +++ b/Dapper.Rainbow/Database.Async.cs @@ -6,10 +6,6 @@ using System.Text; using System.Threading.Tasks; -#if COREFX -using IDbTransaction = System.Data.Common.DbTransaction; -#endif - namespace Dapper { public abstract partial class Database where TDatabase : Database, new() diff --git a/Dapper.Rainbow/Database.cs b/Dapper.Rainbow/Database.cs index ee46db094..109089f8b 100644 --- a/Dapper.Rainbow/Database.cs +++ b/Dapper.Rainbow/Database.cs @@ -8,10 +8,6 @@ using System.Data.Common; using System.Reflection.Emit; -#if COREFX -using IDbTransaction = System.Data.Common.DbTransaction; -#endif - namespace Dapper { /// diff --git a/Dapper.Tests.Contrib/TestSuite.cs b/Dapper.Tests.Contrib/TestSuite.cs index 7fdd7d201..02e179182 100644 --- a/Dapper.Tests.Contrib/TestSuite.cs +++ b/Dapper.Tests.Contrib/TestSuite.cs @@ -5,10 +5,7 @@ using Dapper.Contrib.Extensions; -#if COREFX -using System.Reflection; -using IDbConnection = System.Data.Common.DbConnection; -#else +#if !COREFX using System.Data.SqlServerCe; using System.Transactions; #endif diff --git a/Dapper.Tests.Contrib/TestSuites.cs b/Dapper.Tests.Contrib/TestSuites.cs index 647f5725e..320d20eb0 100644 --- a/Dapper.Tests.Contrib/TestSuites.cs +++ b/Dapper.Tests.Contrib/TestSuites.cs @@ -6,7 +6,6 @@ using Xunit.Sdk; #if COREFX using Microsoft.Data.Sqlite; -using IDbConnection = System.Data.Common.DbConnection; #else using System.Data.SQLite; using System.Data.SqlServerCe; diff --git a/Dapper.Tests/Tests.Async.cs b/Dapper.Tests/Tests.Async.cs index 167524867..4994855a2 100644 --- a/Dapper.Tests/Tests.Async.cs +++ b/Dapper.Tests/Tests.Async.cs @@ -8,10 +8,6 @@ using System.Data.SqlClient; using Xunit; -#if COREFX -using IDbConnection = System.Data.Common.DbConnection; -#endif - namespace Dapper.Tests { public partial class TestSuite diff --git a/Dapper.Tests/Tests.Constructors.cs b/Dapper.Tests/Tests.Constructors.cs index 98aff86ec..bfa1280e8 100644 --- a/Dapper.Tests/Tests.Constructors.cs +++ b/Dapper.Tests/Tests.Constructors.cs @@ -4,14 +4,6 @@ using System.Linq; using Xunit; -#if COREFX -using IDbCommand = System.Data.Common.DbCommand; -using IDbDataParameter = System.Data.Common.DbParameter; -using IDbConnection = System.Data.Common.DbConnection; -using IDbTransaction = System.Data.Common.DbTransaction; -using IDataReader = System.Data.Common.DbDataReader; -#endif - namespace Dapper.Tests { public partial class TestSuite diff --git a/Dapper.Tests/Tests.Enums.cs b/Dapper.Tests/Tests.Enums.cs index 80f27bc38..7026505f9 100644 --- a/Dapper.Tests/Tests.Enums.cs +++ b/Dapper.Tests/Tests.Enums.cs @@ -4,14 +4,6 @@ using System.Linq; using Xunit; -#if COREFX -using IDbCommand = System.Data.Common.DbCommand; -using IDbDataParameter = System.Data.Common.DbParameter; -using IDbConnection = System.Data.Common.DbConnection; -using IDbTransaction = System.Data.Common.DbTransaction; -using IDataReader = System.Data.Common.DbDataReader; -#endif - namespace Dapper.Tests { public partial class TestSuite diff --git a/Dapper.Tests/Tests.MultiMap.cs b/Dapper.Tests/Tests.MultiMap.cs index 67bc5b3b6..05b8b1dc2 100644 --- a/Dapper.Tests/Tests.MultiMap.cs +++ b/Dapper.Tests/Tests.MultiMap.cs @@ -5,14 +5,6 @@ using System.Linq; using Xunit; -#if COREFX -using IDbCommand = System.Data.Common.DbCommand; -using IDbDataParameter = System.Data.Common.DbParameter; -using IDbConnection = System.Data.Common.DbConnection; -using IDbTransaction = System.Data.Common.DbTransaction; -using IDataReader = System.Data.Common.DbDataReader; -#endif - namespace Dapper.Tests { public partial class TestSuite diff --git a/Dapper.Tests/Tests.Parameters.cs b/Dapper.Tests/Tests.Parameters.cs index 4e942f269..d5873be7c 100644 --- a/Dapper.Tests/Tests.Parameters.cs +++ b/Dapper.Tests/Tests.Parameters.cs @@ -14,14 +14,6 @@ using Microsoft.SqlServer.Types; #endif -#if COREFX -using IDbCommand = System.Data.Common.DbCommand; -using IDbDataParameter = System.Data.Common.DbParameter; -using IDbConnection = System.Data.Common.DbConnection; -using IDbTransaction = System.Data.Common.DbTransaction; -using IDataReader = System.Data.Common.DbDataReader; -#endif - namespace Dapper.Tests { public partial class TestSuite diff --git a/Dapper.Tests/Tests.QueryMultiple.cs b/Dapper.Tests/Tests.QueryMultiple.cs index 64b939543..deef2eddc 100644 --- a/Dapper.Tests/Tests.QueryMultiple.cs +++ b/Dapper.Tests/Tests.QueryMultiple.cs @@ -4,14 +4,6 @@ using System.Linq; using Xunit; -#if COREFX -using IDbCommand = System.Data.Common.DbCommand; -using IDbDataParameter = System.Data.Common.DbParameter; -using IDbConnection = System.Data.Common.DbConnection; -using IDbTransaction = System.Data.Common.DbTransaction; -using IDataReader = System.Data.Common.DbDataReader; -#endif - namespace Dapper.Tests { public partial class TestSuite @@ -48,7 +40,6 @@ public void TestQueryMultipleNonBufferedIncorrectOrder() { // that's expected } - } } diff --git a/Dapper.Tests/Tests.cs b/Dapper.Tests/Tests.cs index ffbf2b2de..eb0631d14 100644 --- a/Dapper.Tests/Tests.cs +++ b/Dapper.Tests/Tests.cs @@ -1,13 +1,5 @@ //#define POSTGRESQL // uncomment to run postgres tests -#if COREFX -using IDbCommand = System.Data.Common.DbCommand; -using IDbDataParameter = System.Data.Common.DbParameter; -using IDbConnection = System.Data.Common.DbConnection; -using IDbTransaction = System.Data.Common.DbTransaction; -using IDataReader = System.Data.Common.DbDataReader; -#endif - #if SQLITE && (NET40 || NET45) using SqliteConnection = System.Data.SQLite.SQLiteConnection; #endif @@ -1847,60 +1839,6 @@ public void TestChangingDefaultStringTypeMappingToAnsiStringFirstOrDefault() Dapper.SqlMapper.AddTypeMap(typeof(string), DbType.String); // Restore Default to Unicode String } -#if COREFX - class TransactedConnection : IDbConnection - { - IDbConnection _conn; - IDbTransaction _tran; - - public TransactedConnection(IDbConnection conn, IDbTransaction tran) - { - _conn = conn; - _tran = tran; - } - - public override string ConnectionString { get { return _conn.ConnectionString; } set { _conn.ConnectionString = value; } } - public override int ConnectionTimeout => _conn.ConnectionTimeout; - public override string Database => _conn.Database; - public override ConnectionState State => _conn.State; - - protected override IDbTransaction BeginDbTransaction(IsolationLevel isolationLevel) - { - return _tran; - } - - public override void ChangeDatabase(string databaseName) - { - _conn.ChangeDatabase(databaseName); - } - public override string DataSource => _conn.DataSource; - - public override string ServerVersion => _conn.ServerVersion; - - public override void Close() - { - _conn.Close(); - } - protected override IDbCommand CreateDbCommand() - { - // The command inherits the "current" transaction. - var command = _conn.CreateCommand(); - command.Transaction = _tran; - return command; - } - - protected override void Dispose(bool disposing) - { - if(disposing) _conn.Dispose(); - base.Dispose(disposing); - } - - public override void Open() - { - _conn.Open(); - } - } -#else class TransactedConnection : IDbConnection { IDbConnection _conn; @@ -1955,7 +1893,6 @@ public void Open() _conn.Open(); } } -#endif [Fact] public void TestDapperTableMetadataRetrieval() diff --git a/Dapper/CommandDefinition.cs b/Dapper/CommandDefinition.cs index b6c991129..1d65e0885 100644 --- a/Dapper/CommandDefinition.cs +++ b/Dapper/CommandDefinition.cs @@ -4,12 +4,6 @@ using System.Reflection.Emit; using System.Threading; -#if COREFX -using IDbTransaction = System.Data.Common.DbTransaction; -using IDbConnection = System.Data.Common.DbConnection; -using IDbCommand = System.Data.Common.DbCommand; -#endif - namespace Dapper { /// diff --git a/Dapper/DbString.cs b/Dapper/DbString.cs index f6195bec4..cd573472e 100644 --- a/Dapper/DbString.cs +++ b/Dapper/DbString.cs @@ -1,10 +1,6 @@ using System; using System.Data; -#if COREFX -using IDbCommand = System.Data.Common.DbCommand; -#endif - namespace Dapper { /// diff --git a/Dapper/DefaultTypeMap.cs b/Dapper/DefaultTypeMap.cs index 4341a3f83..cca3baba2 100644 --- a/Dapper/DefaultTypeMap.cs +++ b/Dapper/DefaultTypeMap.cs @@ -195,6 +195,9 @@ public SqlMapper.IMemberMap GetMember(string columnName) /// public static bool MatchNamesWithUnderscores { get; set; } + /// + /// The settable properties for this typemap + /// public List Properties { get; } } } diff --git a/Dapper/DynamicParameters.ParamInfo.cs b/Dapper/DynamicParameters.ParamInfo.cs index 72834608b..e323cae0a 100644 --- a/Dapper/DynamicParameters.ParamInfo.cs +++ b/Dapper/DynamicParameters.ParamInfo.cs @@ -1,9 +1,6 @@ using System; using System.Data; -#if COREFX -using IDbDataParameter = System.Data.Common.DbParameter; -#endif namespace Dapper { partial class DynamicParameters diff --git a/Dapper/DynamicParameters.cs b/Dapper/DynamicParameters.cs index 151cbf6e6..901388ea1 100644 --- a/Dapper/DynamicParameters.cs +++ b/Dapper/DynamicParameters.cs @@ -7,8 +7,6 @@ using System.Reflection.Emit; #if COREFX -using IDbDataParameter = System.Data.Common.DbParameter; -using IDbCommand = System.Data.Common.DbCommand; using ApplicationException = System.InvalidOperationException; #endif diff --git a/Dapper/FeatureSupport.cs b/Dapper/FeatureSupport.cs index 03ee470af..41338600b 100644 --- a/Dapper/FeatureSupport.cs +++ b/Dapper/FeatureSupport.cs @@ -1,9 +1,6 @@ using System; using System.Data; -#if COREFX -using IDbConnection = System.Data.Common.DbConnection; -#endif namespace Dapper { /// diff --git a/Dapper/SqlMapper.Async.cs b/Dapper/SqlMapper.Async.cs index dbcce5d41..b75043573 100644 --- a/Dapper/SqlMapper.Async.cs +++ b/Dapper/SqlMapper.Async.cs @@ -9,13 +9,6 @@ using System.Threading; using System.Threading.Tasks; -#if COREFX -using IDbTransaction = System.Data.Common.DbTransaction; -using IDbConnection = System.Data.Common.DbConnection; -using IDbCommand = System.Data.Common.DbCommand; -using IDataReader = System.Data.Common.DbDataReader; -#endif - namespace Dapper { public static partial class SqlMapper diff --git a/Dapper/SqlMapper.CacheInfo.cs b/Dapper/SqlMapper.CacheInfo.cs index fae83abeb..1207d251f 100644 --- a/Dapper/SqlMapper.CacheInfo.cs +++ b/Dapper/SqlMapper.CacheInfo.cs @@ -2,11 +2,6 @@ using System.Data; using System.Threading; -#if COREFX -using IDbCommand = System.Data.Common.DbCommand; -using IDataReader = System.Data.Common.DbDataReader; -#endif - namespace Dapper { partial class SqlMapper diff --git a/Dapper/SqlMapper.DeserializerState.cs b/Dapper/SqlMapper.DeserializerState.cs index 005d1071b..ccf11ebcf 100644 --- a/Dapper/SqlMapper.DeserializerState.cs +++ b/Dapper/SqlMapper.DeserializerState.cs @@ -1,10 +1,6 @@ using System; using System.Data; -#if COREFX -using IDataReader = System.Data.Common.DbDataReader; -#endif - namespace Dapper { partial class SqlMapper diff --git a/Dapper/SqlMapper.GridReader.Async.cs b/Dapper/SqlMapper.GridReader.Async.cs index a890d9873..d0deb0bc8 100644 --- a/Dapper/SqlMapper.GridReader.Async.cs +++ b/Dapper/SqlMapper.GridReader.Async.cs @@ -6,10 +6,7 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; -#if COREFX -using IDbCommand = System.Data.Common.DbCommand; -using IDataReader = System.Data.Common.DbDataReader; -#endif + namespace Dapper { partial class SqlMapper diff --git a/Dapper/SqlMapper.GridReader.cs b/Dapper/SqlMapper.GridReader.cs index 0a3ecee05..0721ed7d7 100644 --- a/Dapper/SqlMapper.GridReader.cs +++ b/Dapper/SqlMapper.GridReader.cs @@ -3,11 +3,6 @@ using System.Data; using System.Linq; -#if COREFX -using IDbCommand = System.Data.Common.DbCommand; -using IDataReader = System.Data.Common.DbDataReader; -#endif - namespace Dapper { partial class SqlMapper diff --git a/Dapper/SqlMapper.ICustomQueryParameter.cs b/Dapper/SqlMapper.ICustomQueryParameter.cs index 95eebf194..6ea5782ea 100644 --- a/Dapper/SqlMapper.ICustomQueryParameter.cs +++ b/Dapper/SqlMapper.ICustomQueryParameter.cs @@ -1,8 +1,5 @@ using System.Data; -#if COREFX -using IDbCommand = System.Data.Common.DbCommand; -#endif namespace Dapper { partial class SqlMapper diff --git a/Dapper/SqlMapper.IDataReader.cs b/Dapper/SqlMapper.IDataReader.cs index 8ed861c73..a6616ca60 100644 --- a/Dapper/SqlMapper.IDataReader.cs +++ b/Dapper/SqlMapper.IDataReader.cs @@ -2,10 +2,6 @@ using System.Collections.Generic; using System.Data; -#if COREFX -using IDataReader = System.Data.Common.DbDataReader; -#endif - namespace Dapper { partial class SqlMapper diff --git a/Dapper/SqlMapper.IDynamicParameters.cs b/Dapper/SqlMapper.IDynamicParameters.cs index fbb0829ae..37e55142a 100644 --- a/Dapper/SqlMapper.IDynamicParameters.cs +++ b/Dapper/SqlMapper.IDynamicParameters.cs @@ -1,9 +1,5 @@ using System.Data; -#if COREFX -using IDbCommand = System.Data.Common.DbCommand; -#endif - namespace Dapper { partial class SqlMapper diff --git a/Dapper/SqlMapper.ITypeHandler.cs b/Dapper/SqlMapper.ITypeHandler.cs index 9e74a96be..4bb0df75c 100644 --- a/Dapper/SqlMapper.ITypeHandler.cs +++ b/Dapper/SqlMapper.ITypeHandler.cs @@ -1,9 +1,6 @@ using System; using System.Data; -#if COREFX -using IDbDataParameter = System.Data.Common.DbParameter; -#endif namespace Dapper { partial class SqlMapper diff --git a/Dapper/SqlMapper.Identity.cs b/Dapper/SqlMapper.Identity.cs index 29a5ffe11..f151615b3 100644 --- a/Dapper/SqlMapper.Identity.cs +++ b/Dapper/SqlMapper.Identity.cs @@ -1,10 +1,6 @@ using System; using System.Data; -#if COREFX -using IDbConnection = System.Data.Common.DbConnection; -#endif - namespace Dapper { partial class SqlMapper diff --git a/Dapper/SqlMapper.TypeDeserializerCache.cs b/Dapper/SqlMapper.TypeDeserializerCache.cs index c9fd88dba..c50bd319a 100644 --- a/Dapper/SqlMapper.TypeDeserializerCache.cs +++ b/Dapper/SqlMapper.TypeDeserializerCache.cs @@ -1,8 +1,4 @@ -#if COREFX -using IDataReader = System.Data.Common.DbDataReader; -#endif - -using System; +using System; using System.Data; using System.Collections; using System.Collections.Generic; diff --git a/Dapper/SqlMapper.TypeHandler.cs b/Dapper/SqlMapper.TypeHandler.cs index 47f409089..5570f3b86 100644 --- a/Dapper/SqlMapper.TypeHandler.cs +++ b/Dapper/SqlMapper.TypeHandler.cs @@ -1,10 +1,6 @@ using System; using System.Data; -#if COREFX -using IDbDataParameter = System.Data.Common.DbParameter; -#endif - namespace Dapper { partial class SqlMapper diff --git a/Dapper/SqlMapper.TypeHandlerCache.cs b/Dapper/SqlMapper.TypeHandlerCache.cs index 0ea399373..a7437954f 100644 --- a/Dapper/SqlMapper.TypeHandlerCache.cs +++ b/Dapper/SqlMapper.TypeHandlerCache.cs @@ -2,10 +2,6 @@ using System.ComponentModel; using System.Data; -#if COREFX -using IDbDataParameter = System.Data.Common.DbParameter; -#endif - namespace Dapper { partial class SqlMapper diff --git a/Dapper/SqlMapper.cs b/Dapper/SqlMapper.cs index 058309ca6..917bf6ef9 100644 --- a/Dapper/SqlMapper.cs +++ b/Dapper/SqlMapper.cs @@ -3,18 +3,6 @@ Home page: https://github.com/StackExchange/dapper-dot-net */ -#if COREFX -using IDbDataParameter = System.Data.Common.DbParameter; -using IDataParameter = System.Data.Common.DbParameter; -using IDbTransaction = System.Data.Common.DbTransaction; -using IDbConnection = System.Data.Common.DbConnection; -using IDbCommand = System.Data.Common.DbCommand; -using IDataReader = System.Data.Common.DbDataReader; -using IDataRecord = System.Data.Common.DbDataReader; -using IDataParameterCollection = System.Data.Common.DbParameterCollection; -using DataException = System.InvalidOperationException; -#endif - using System; using System.Collections; using System.Collections.Generic; @@ -31,6 +19,10 @@ using System.Xml; using System.Xml.Linq; +#if COREFX +using DataException = System.InvalidOperationException; +#endif + namespace Dapper { diff --git a/Dapper/WrappedDataReader.cs b/Dapper/WrappedDataReader.cs index d3f98f4b8..93c4bf03d 100644 --- a/Dapper/WrappedDataReader.cs +++ b/Dapper/WrappedDataReader.cs @@ -1,29 +1,7 @@ using System.Data; -#if COREFX -using IDbCommand = System.Data.Common.DbCommand; -using IDataReader = System.Data.Common.DbDataReader; -#endif - namespace Dapper { -#if COREFX - /// - /// Describes a reader that controls the lifetime of both a command and a reader, - /// exposing the downstream command/reader as properties. - /// - public abstract class WrappedDataReader : IDataReader - { - /// - /// Obtain the underlying reader - /// - public abstract IDataReader Reader { get; } - /// - /// Obtain the underlying command - /// - public abstract IDbCommand Command { get; } - } -#else /// /// Describes a reader that controls the lifetime of both a command and a reader, /// exposing the downstream command/reader as properties. @@ -39,5 +17,4 @@ public interface IWrappedDataReader : IDataReader /// IDbCommand Command { get; } } -#endif } diff --git a/Dapper/WrappedReader.cs b/Dapper/WrappedReader.cs index ea4356953..65002fa17 100644 --- a/Dapper/WrappedReader.cs +++ b/Dapper/WrappedReader.cs @@ -1,131 +1,8 @@ using System; using System.Data; -using System.Collections; - -#if COREFX -using IDbCommand = System.Data.Common.DbCommand; -using IDataReader = System.Data.Common.DbDataReader; -#endif namespace Dapper { -#if COREFX - internal class WrappedReader : WrappedDataReader - { - private IDbCommand cmd; - private IDataReader reader; - - public override IEnumerator GetEnumerator() - { - return Reader.GetEnumerator(); - } - public WrappedReader(IDbCommand cmd, IDataReader reader) - { - this.cmd = cmd; - this.reader = reader; - } - public override IDataReader Reader - { - get - { - var tmp = reader; - if (tmp == null) throw new ObjectDisposedException(this.GetType().Name); - return tmp; - } - } - public override IDbCommand Command - { - get - { - var tmp = cmd; - if (tmp == null) throw new ObjectDisposedException(this.GetType().Name); - return tmp; - } - } - - public override int Depth => Reader.Depth; - - public override bool IsClosed => reader?.IsClosed ?? true; - - public override bool HasRows => Reader.HasRows; - - public override bool NextResult() => Reader.NextResult(); - - public override bool Read() => Reader.Read(); - - public override int RecordsAffected => Reader.RecordsAffected; - - - protected override void Dispose(bool disposing) - { - if (disposing) - { - reader?.Dispose(); - reader = null; - cmd?.Dispose(); - cmd = null; - } - base.Dispose(disposing); - } - - public override int FieldCount => Reader.FieldCount; - - public override bool GetBoolean(int i) => Reader.GetBoolean(i); - - public override byte GetByte(int i) => Reader.GetByte(i); - - public override long GetBytes(int i, long fieldOffset, byte[] buffer, int bufferoffset, int length) - { - return Reader.GetBytes(i, fieldOffset, buffer, bufferoffset, length); - } - - public override char GetChar(int i) => Reader.GetChar(i); - - public override long GetChars(int i, long fieldoffset, char[] buffer, int bufferoffset, int length) - { - return Reader.GetChars(i, fieldoffset, buffer, bufferoffset, length); - } - - protected override IDataReader GetDbDataReader(int ordinal) => Reader.GetData(ordinal); - - public override string GetDataTypeName(int i) => Reader.GetDataTypeName(i); - - public override DateTime GetDateTime(int i) => Reader.GetDateTime(i); - - public override decimal GetDecimal(int i) => Reader.GetDecimal(i); - - public override double GetDouble(int i) => Reader.GetDouble(i); - - public override Type GetFieldType(int i) => Reader.GetFieldType(i); - - public override float GetFloat(int i) => Reader.GetFloat(i); - - public override Guid GetGuid(int i) => Reader.GetGuid(i); - - public override short GetInt16(int i) => Reader.GetInt16(i); - - public override int GetInt32(int i) => Reader.GetInt32(i); - - public override long GetInt64(int i) => Reader.GetInt64(i); - - public override string GetName(int i) => Reader.GetName(i); - - public override int GetOrdinal(string name) => Reader.GetOrdinal(name); - - public override string GetString(int i) => Reader.GetString(i); - - public override object GetValue(int i) => Reader.GetValue(i); - - public override int GetValues(object[] values) => Reader.GetValues(values); - - public override bool IsDBNull(int i) => Reader.IsDBNull(i); - - public override object this[string name] => Reader[name]; - - public override object this[int i] => Reader[i]; - } -#else - internal class WrappedReader : IDataReader, IWrappedDataReader { private IDataReader reader; @@ -306,5 +183,4 @@ bool IDataRecord.IsDBNull(int i) object IDataRecord.this[int i] => Reader[i]; } -#endif } diff --git a/Dapper/XmlHandlers.cs b/Dapper/XmlHandlers.cs index d5051f165..12c172342 100644 --- a/Dapper/XmlHandlers.cs +++ b/Dapper/XmlHandlers.cs @@ -1,9 +1,6 @@ using System.Data; using System.Xml; using System.Xml.Linq; -#if COREFX -using IDbDataParameter = System.Data.Common.DbParameter; -#endif namespace Dapper {