Imported Upstream version 4.2.2.10

Former-commit-id: 925376e1db46149d14f7949fcd7b08805ea8aba9
This commit is contained in:
Xamarin Public Jenkins
2015-12-18 19:40:30 -05:00
parent d11e8b35fd
commit 8cb7d04924
45 changed files with 399 additions and 122 deletions

View File

@@ -1263,20 +1263,29 @@ namespace System.Data.SqlClient
throw new ArgumentNullException ("values");
int len = values.Length;
int bigDecimalIndex = command.Tds.ColumnValues.BigDecimalIndex;
var tds = command.Tds;
int columns = Math.Min (len, tds.Columns.Count);
// If a four-byte decimal is stored, then we can't convert to
// a native type. Throw an OverflowException.
if (bigDecimalIndex >= 0 && bigDecimalIndex < len)
throw new OverflowException ();
try {
command.Tds.ColumnValues.CopyTo (0, values, 0,
len > command.Tds.ColumnValues.Count ? command.Tds.ColumnValues.Count : len);
} catch (TdsInternalException ex) {
command.Connection.Close ();
throw SqlException.FromTdsInternalException ((TdsInternalException) ex);
if ((command.CommandBehavior & CommandBehavior.SequentialAccess) != 0) {
for (int i = 0; i < columns; ++i) {
values [i] = tds.GetSequentialColumnValue (i);
}
} else {
int bigDecimalIndex = tds.ColumnValues.BigDecimalIndex;
// If a four-byte decimal is stored, then we can't convert to
// a native type. Throw an OverflowException.
if (bigDecimalIndex >= 0 && bigDecimalIndex < len)
throw new OverflowException ();
try {
tds.ColumnValues.CopyTo (0, values, 0, columns);
} catch (TdsInternalException ex) {
command.Connection.Close ();
throw SqlException.FromTdsInternalException ((TdsInternalException)ex);
}
}
return (len < FieldCount ? len : FieldCount);
return columns;
}