You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With SequentialAccess, calling GetFieldValueAsync<Stream> on its own returns a readable stream. If IsDBNullAsync is called first then the stream will have no data.
Using GetStream instead returns a readable stream in both cases.
To reproduce
Based on GetFieldValueAsync_OfStream unit test
using(SqlDataReaderreader=awaitcommand.ExecuteReaderAsync(CommandBehavior.SequentialAccess)){if(awaitreader.ReadAsync()&&!awaitreader.IsDBNullAsync(1)){usingvarbuffer=newMemoryStream(originalData.Length);// Doesn't have any bytes to readusing(Streamstream=awaitreader.GetFieldValueAsync<Stream>(1)){awaitstream.CopyToAsync(buffer);outputData=buffer.ToArray();}// Works//using (Stream stream = reader.GetStream(1))//{// await stream.CopyToAsync(buffer);// outputData = buffer.ToArray();//}}}Debug.Assert(originalData.SequenceEqual(outputData));
Expected behavior
Expect GetFieldValueAsync<Stream> to work the same as GetStream in that IsDBNullAsync doesn't consume the column
Further technical details
Microsoft.Data.SqlClient version: 5.2.2
.NET target: .NET 8
SQL Server version: 2022
Operating system: Windows 11
The text was updated successfully, but these errors were encountered:
Describe the bug
With SequentialAccess, calling
GetFieldValueAsync<Stream>
on its own returns a readable stream. IfIsDBNullAsync
is called first then the stream will have no data.Using
GetStream
instead returns a readable stream in both cases.To reproduce
Based on
GetFieldValueAsync_OfStream
unit testExpected behavior
Expect
GetFieldValueAsync<Stream>
to work the same asGetStream
in thatIsDBNullAsync
doesn't consume the columnFurther technical details
Microsoft.Data.SqlClient version: 5.2.2
.NET target: .NET 8
SQL Server version: 2022
Operating system: Windows 11
The text was updated successfully, but these errors were encountered: