}// FetchMultipleRowStoreResultSets() #endregion #region FetchSingleRowStoreResultSet() internal static List<RowStore> FetchSingleRowStoreResultSet(SqlDataReader reader, int resultSetId = 0) { var rowStoreList = new List<RowStore>(capacity: 8); unchecked { if (reader.Read()) { int fieldCount = reader.FieldCount; int fieldCountPlusOne = fieldCount + 1; var fieldMap = new Dictionary<string, int>(fieldCount, Util.FastStringComparer.Instance); var fieldNames = new string[fieldCount]; for (int i = 0; i < fieldNames.Length; ++i) { var fieldName = reader.GetName(i); fieldMap.Add(fieldName, i); fieldNames[i] = fieldName; } var resultSchema = new ResultSetSchema(resultSetId, fieldMap, fieldNames); var rowValues = new object[fieldCountPlusOne]; rowValues[fieldCount] = resultSchema; reader.GetValues(rowValues); rowStoreList.Add(new RowStore(rowValues)); while (reader.Read()) { rowValues = new object[fieldCountPlusOne]; rowValues[fieldCount] = resultSchema; reader.GetValues(rowValues); rowStoreList.Add(new RowStore(rowValues)); } }// if 1st read }// unchecked return rowStoreList; }// FetchSingleRowStoreResultSet()
}// InternalQueryAsync<TParamType>() #endregion #region FetchResultSets() internal static List<List<RowStore>> FetchResultSets(SqlDataReader reader) { var resultSetList = new List<List<RowStore>>(1); // optimizing for a single result set int resultSetId = 0, fieldCount = 0; object[] rowValues; do { var rowStoreList = new List<RowStore>(4); ResultSetSchema resultSchema = null; while (reader.Read()/*await reader.ReadAsync(cancellationToken).ConfigureAwait(false) */) { if (resultSchema == null) { fieldCount = reader.FieldCount; var fieldMap = new Dictionary<string, int>(fieldCount, Util.FastStringComparer.Instance); for (int i = 0; i < fieldCount; ++i) { fieldMap.Add(reader.GetName(i), i); } resultSchema = new ResultSetSchema(resultSetId, fieldMap); } rowValues = new object[fieldCount]; reader.GetValues(rowValues); rowStoreList.Add(new RowStore(resultSchema, rowValues)); } ++resultSetId; resultSetList.Add(rowStoreList); } while (reader.NextResult()); return resultSetList; }// FetchResultSets()
internal RowStore(ref ResultSetSchema schema, ref object[] rowValues) { this.Schema = schema; this.RowValues = rowValues; }