diff --git a/src/System.Data.Common/src/System/Data/DataReaderExtensions.cs b/src/System.Data.Common/src/System/Data/DataReaderExtensions.cs index 05ec669ba14b..cff7b3804c5d 100644 --- a/src/System.Data.Common/src/System/Data/DataReaderExtensions.cs +++ b/src/System.Data.Common/src/System/Data/DataReaderExtensions.cs @@ -88,7 +88,7 @@ public static T GetFieldValue(this DbDataReader reader, string name) public static Task GetFieldValueAsync(this DbDataReader reader, string name, CancellationToken cancellationToken = default(CancellationToken)) { AssertNotNull(reader); - return reader.GetFieldValueAsync(reader.GetOrdinal(name)); + return reader.GetFieldValueAsync(reader.GetOrdinal(name), cancellationToken); } public static float GetFloat(this DbDataReader reader, string name) @@ -168,7 +168,7 @@ public static bool IsDBNull(this DbDataReader reader, string name) public static Task IsDBNullAsync(this DbDataReader reader, string name, CancellationToken cancellationToken = default(CancellationToken)) { AssertNotNull(reader); - return reader.IsDBNullAsync(reader.GetOrdinal(name)); + return reader.IsDBNullAsync(reader.GetOrdinal(name), cancellationToken); } private static void AssertNotNull(DbDataReader reader) diff --git a/src/System.Data.Common/tests/System/Data/Common/DbDataReaderTest.netcoreapp.cs b/src/System.Data.Common/tests/System/Data/Common/DbDataReaderTest.netcoreapp.cs index 74863b5d0ba7..d78b7b3e7657 100644 --- a/src/System.Data.Common/tests/System/Data/Common/DbDataReaderTest.netcoreapp.cs +++ b/src/System.Data.Common/tests/System/Data/Common/DbDataReaderTest.netcoreapp.cs @@ -2,6 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using System.Threading; +using System.Threading.Tasks; using Xunit; namespace System.Data.Tests.Common @@ -319,6 +321,18 @@ public void IsDBNullByColumnNameTest() Assert.True(_dataReader.IsDBNull("dbnull_col")); } + [Fact] + public Task GetValueAsyncByColumnNameCanceledTest() + { + return Assert.ThrowsAsync(() => _dataReader.GetFieldValueAsync("text_col", new CancellationToken(true))); + } + + [Fact] + public Task IsDbNullAsyncByColumnNameCanceledTest() + { + return Assert.ThrowsAsync(() => _dataReader.IsDBNullAsync("dbnull_col", new CancellationToken(true))); + } + private void SkipRows(int rowsToSkip) { var i = 0;