Change SqlParameter to allow empty IEnumerable<SqlDataRecord>? #2971
Labels
Enhancement 💡
Issues that are feature requests for the drivers we maintain.
Good First Issue ✨
Issues that are simple enough for newcomers
Triage Done ✔️
Issues that are triaged by dev team and are in investigation.
Up-for-Grabs 🙌
Issues that are ready to be picked up for anyone interested. Please self-assign and remove the label
At the beginning of the
GetActualFieldsAndProperties
branch forIEnumerable<SqlDataRecord>
, this comment suggests it will set the value tonull
when the enumerable is empty:SqlClient/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlParameter.cs
Lines 1291 to 1292 in 9d5ca32
However, at the end, it throws an exception:
SqlClient/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlParameter.cs
Lines 1413 to 1416 in 9d5ca32
This means I have to check for an empty
IEnumerable<SqlDataRecord>
before settingSqlParameter.Value
, which means I have to materialize and/or enumerate the source. For efficiency, I would like to avoid that. ConsideringSqlParameter
is already peeking at the enumeration to initialize the metadata, could it be changed to handle an empty enumerable the same as the valuenull
?The text was updated successfully, but these errors were encountered: