DapperLib / DapperAOT

Build time tools in the flavor of Dapper
Other
349 stars 19 forks source link

AsyncAccessorDataReader never sets Current #90

Closed felixcicatt closed 7 months ago

felixcicatt commented 8 months ago

Describe the bug

The AsyncAccessorDataReader never seems to take the Current value from the IAsyncEnumerator and set it's own Current value with it, when ReadAsync is called. This means that as soon as the SqlBulkCopy tries to get a value for the first row, it encounters a null value, triggering a NullReferenceException.

Where are you seeing this?

To Reproduce

IAsyncEnumerable<Customer> customers = ...
var reader = TypeAccessor.CreateDataReader(customers);
using var table = new SqlBulkCopy(connection);
table.EnableStreaming = true;
table.WriteToServer(TypeAccessor.CreateDataReader(customers,
    [nameof(Customer.Name), nameof(Customer.CustomerNumber)]));
mgravell commented 7 months ago

you are quite correct, thanks; working