本文整理汇总了C#中IDataReader.NextResult方法的典型用法代码示例。如果您正苦于以下问题:C# IDataReader.NextResult方法的具体用法?C# IDataReader.NextResult怎么用?C# IDataReader.NextResult使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDataReader
的用法示例。
在下文中一共展示了IDataReader.NextResult方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: NDataReader
/// <summary>
/// Creates a NDataReader from a <see cref="IDataReader" />
/// </summary>
/// <param name="reader">The <see cref="IDataReader" /> to get the records from the Database.</param>
/// <param name="isMidstream"><see langword="true" /> if we are loading the <see cref="IDataReader" /> in the middle of reading it.</param>
/// <remarks>
/// NHibernate attempts to not have to read the contents of an <see cref="IDataReader"/> into memory until it absolutely
/// has to. What that means is that it might have processed some records from the <see cref="IDataReader"/> and will
/// pick up the <see cref="IDataReader"/> midstream so that the underlying <see cref="IDataReader"/> can be closed
/// so a new one can be opened.
/// </remarks>
public NDataReader(IDataReader reader, bool isMidstream)
{
ArrayList resultList = new ArrayList(2);
try
{
// if we are in midstream of processing a DataReader then we are already
// positioned on the first row (index=0)
if (isMidstream)
{
currentRowIndex = 0;
}
// there will be atleast one result
resultList.Add(new NResult(reader, isMidstream));
while (reader.NextResult())
{
// the second, third, nth result is not processed midstream
resultList.Add(new NResult(reader, false));
}
results = (NResult[]) resultList.ToArray(typeof(NResult));
}
catch (Exception e)
{
throw new ADOException("There was a problem converting an IDataReader to NDataReader", e);
}
finally
{
reader.Close();
}
}
示例2: FillEmailCollection
private static List<EmailInfo> FillEmailCollection(IDataReader reader, out int totalRecords)
{
List<EmailInfo> retVal;
totalRecords = 0;
try
{
retVal = ObjectHelper.FillCollection<EmailInfo>(reader, false);
//Get the next result (containing the total)
reader.NextResult();
//Get the total no of records from the second result
if (reader.Read())
{
totalRecords = Convert.ToInt32(reader[0]);
}
}
finally
{
//close datareader
ObjectHelper.CloseDataReader(reader, true);
}
return retVal;
}
示例3: InMemoryDataReader
/// <summary>
/// Creates an InMemoryDataReader from a <see cref="IDataReader" />
/// </summary>
/// <param name="reader">The <see cref="IDataReader" /> which holds the records from the Database.</param>
public InMemoryDataReader(IDataReader reader)
{
ArrayList resultList = new ArrayList();
try
{
_currentResultIndex = 0;
_currentRowIndex = 0;
resultList.Add( new InMemoryResultSet( reader, true ) );
while( reader.NextResult() )
{
resultList.Add( new InMemoryResultSet( reader, false ) );
}
_results = ( InMemoryResultSet[ ] ) resultList.ToArray( typeof( InMemoryResultSet ) );
}
catch( Exception e )
{
throw new DataMapperException( "There was a problem converting an IDataReader to an InMemoryDataReader", e );
}
finally
{
reader.Close();
reader.Dispose();
}
}
示例4: GetTotais
/**
* Assume que o result set em IDataReader reader contem na coluna 0 um ID (long), na coluna 1 a designacao (string),
* na coluna 2 um valor (long) e, opcionalmente, na coluna 3 um outro valor (long).
*
* Se existirem mais colunas, estas sao ignoradas.
*/
protected List<TotalTipo> GetTotais(IDataReader reader) {
List<TotalTipo> results = new List<TotalTipo>();
TotalTipo tt;
long total = 0;
long total_editadas = 0;
long total_eliminadas = 0;
do {
while (reader.Read()) {
tt = new TotalTipo();
tt.ID = System.Convert.ToInt64(reader.GetValue(0));
tt.Designacao = reader.GetValue(1).ToString();
tt.Contador = System.Convert.ToInt64(reader.GetValue(2));
// Quarta coluna (se existir) contem o valor de 'Editadas':
if (reader.FieldCount > 3) {
tt.Contador_Editadas = System.Convert.ToInt64(reader.GetValue(3));
total_editadas += tt.Contador_Editadas;
tt.Contador_Eliminadas = System.Convert.ToInt64(reader.GetValue(4));
total_eliminadas += tt.Contador_Eliminadas;
}
results.Add(tt);
total += tt.Contador;
}
} while (reader.NextResult());
tt = new TotalTipo();
tt.ID = -1;
tt.Designacao = "Total";
tt.Contador = total;
tt.Contador_Editadas = total_editadas;
tt.Contador_Eliminadas = total_eliminadas;
results.Add(tt);
return results;
}
示例5: DataReaderToDataSet
public static DataSet DataReaderToDataSet(IDataReader reader)
{
var ds = new DataSet();
DataTable table;
do
{
int fieldCount = reader.FieldCount;
table = new DataTable();
for (int i = 0; i < fieldCount; i++)
{
table.Columns.Add(reader.GetName(i), reader.GetFieldType(i));
}
table.BeginLoadData();
var values = new Object[fieldCount];
while (reader.Read())
{
reader.GetValues(values);
table.LoadDataRow(values, true);
}
table.EndLoadData();
ds.Tables.Add(table);
} while (reader.NextResult());
reader.Close();
return ds;
}
示例6: FillGroupCollection
private static List<GroupInfo> FillGroupCollection(IDataReader reader, out int totalRecords)
{
var retVal = ObjectHelper.FillCollection<GroupInfo>(reader, false);
totalRecords = 0;
try
{
//Get the next result (containing the total)
reader.NextResult();
//Get the total no of records from the second result
if (reader.Read())
{
totalRecords = Convert.ToInt32(reader[0]);
}
}
catch
{
//DotNetNuke.Services.Exceptions.Exceptions.LogException(exc);
}
finally
{
//close datareader
ObjectHelper.CloseDataReader(reader, true);
}
return retVal;
}
示例7: MapReader
/// <summary>
/// Creates one instance of Type T
/// </summary>
/// <param name="reader">Reader with the query result</param>
/// <param name="prefix">Optional prefix to identify relevant rows in the query results</param>
/// <returns>Instance of object type.</returns>
internal static RoomInformation MapReader(IDataReader reader, string prefix = "")
{
var roomInfo = new RoomInformation
{
RoomTypes = new List<RoomType>(),
};
//get all room types associated with the business
while (reader.Read())
{
roomInfo.RoomTypes.Add(RoomTypeMapper.MapRecordWithCode(reader));
}
// Populate rooms, nested inside the room types
if (reader.NextResult())
{
while (reader.Read())
{
//get all rooms and combined rooms associated with the business
var room = RoomMapper.MapRecord(reader);
roomInfo.RoomTypes.Find(rt => rt.Id == room.RoomTypeId).Rooms.Add(room);
}
}
if (roomInfo.RoomTypes.Count == 0)
{
roomInfo = null;
}
return roomInfo;
}
示例8: ToMultipleDictionariesImpl
private static IEnumerable<IEnumerable<IDictionary<string,object>>> ToMultipleDictionariesImpl(IDataReader reader)
{
do
{
yield return ToDictionariesImpl(reader).ToArray().AsEnumerable();
} while (reader.NextResult());
}
示例9: SimpleIDValueRetrieve
public static object SimpleIDValueRetrieve(int? id, IDataReader data, String columnName)
{
object result = null;
while (data.NextResult())
{
int rowID = (int)data["ID"];
if (rowID == id.Value)
{
return data[columnName];
}
}
return result;
}
示例10: DataReaderToExcelFile
public static void DataReaderToExcelFile(IDataReader reader, string saveFileName, List<SheetOptions> optionsList)
{
if (reader == null) throw new ArgumentNullException("reader");
if (string.IsNullOrWhiteSpace(saveFileName)) throw new ArgumentException("字符串参数不允许为null或者空值.", saveFileName);
// 创建一个空Xls文档
XlsDocument xls = new XlsDocument();
int sheetIndex = 0;
int sheetDefaultNameIndex = 1;
do
{
// 创建一个工作表
SheetOptions options = (optionsList == null || sheetIndex >= optionsList.Count)
? options = new SheetOptions() { SheetName = SheetOptions.DefaultSheetName + (sheetDefaultNameIndex++).ToString() }
: optionsList[sheetIndex];
Worksheet sheet = xls.Workbook.Worksheets.Add(options.SheetName);
// 创建表格数据
if (reader.Read())
{
// 标题
ushort rowNo = 1,
columnNo = 1;
int fieldCnt = reader.FieldCount;
for (int i = 0; i < fieldCnt; i++, columnNo++)
{
sheet.Cells.Add(rowNo, columnNo, reader.GetName(i));
}
// 正文数据
do
{
rowNo++;
columnNo = 1;
for (int i = 0; i < fieldCnt; i++, columnNo++)
{
string value = Convert.ToString(reader[i]); // null值将显示为空
sheet.Cells.Add(rowNo, columnNo, value);
}
} while (reader.Read());
}
sheetIndex++;
} while (reader.NextResult());
trySaveXlsFile(xls, saveFileName);
}
示例11: GetTableSet
public static IEnumerable<Table> GetTableSet(IDataReader reader){
var wasnextresult = true;
Table t = null;
while (reader.Read() || (wasnextresult = (reader.NextResult() && reader.Read()))){
if (wasnextresult){
if (null != t) yield return t;
t = initNewTable(reader);
wasnextresult = false;
}
var r = new Row();
for (var i = 0; i < reader.FieldCount; i++)
r.Values.Add(reader[i]);
t.Rows.Add(r);
}
if (null != t) yield return t;
}
示例12: GetDataFromDb
protected void GetDataFromDb(IDataReader dataReader)
{
int i = 0;
do
{
switch (i)
{
case 0:
AllRolesFromDb(dataReader);
break;
case 1:
MaxIdFromId(dataReader);
break;
}
i++;
} while (dataReader.NextResult());
}
示例13: FillAppointmentInterviewCollection
private static List<AppointmentInterviewInfo> FillAppointmentInterviewCollection(IDataReader reader, out int totalRecords)
{
var retVal = new List<AppointmentInterviewInfo>();
totalRecords = 0;
try
{
while (reader.Read())
{
//fill business object
var info = new AppointmentInterviewInfo();
/*
info.ContactId = ConvertHelper.ToInt32(reader["ContactId"]);
info.UserId = ConvertHelper.ToInt32(reader["UserId"]);
info.TimeSlotId = ConvertHelper.ToInt32(reader["TimeSlotId"]);
info.Notes = ConvertHelper.ToString(reader["Notes"]);
info.StatusInterviewId = ConvertHelper.ToInt32(reader["StatusInterviewId"]);
info.TeacherTypeId = ConvertHelper.ToInt32(reader["TeacherTypeId"]);
info.CasecAccountId = ConvertHelper.ToInt32(reader["CasecAccountId"]);
*/
retVal.Add(info);
}
//Get the next result (containing the total)
reader.NextResult();
//Get the total no of records from the second result
if (reader.Read())
{
totalRecords = Convert.ToInt32(reader[0]);
}
}
finally
{
//close datareader
ObjectHelper.CloseDataReader(reader, true);
}
return retVal;
}
示例14: FillSourceTypCollection
private static List<SourceTypeInfo> FillSourceTypCollection(IDataReader reader, out int totalRecords)
{
List<SourceTypeInfo> retVal;
totalRecords = 0;
try
{
retVal = ObjectHelper.FillCollection<SourceTypeInfo>(reader, false);
reader.NextResult();
if (reader.Read()) totalRecords = reader[0].ToInt32();
}
finally
{
ObjectHelper.CloseDataReader(reader, true);
}
return retVal;
}
示例15: DisconnectedReader
/// <summary>
/// Caches a data reader to enable disconnected data access via the IDataReader interface.
/// </summary>
/// <param name="reader">The IDataReader to cache.</param>
public DisconnectedReader(IDataReader reader)
{
// Cache field information
this.fields = new FieldInfo[reader.FieldCount];
this.ordinals = new Hashtable(StringComparer.OrdinalIgnoreCase);
for (int index = 0; index < fields.Length; index++)
{
FieldInfo field = new FieldInfo();
field.Name = reader.GetName(index);
field.Type = reader.GetFieldType(index);
field.DataTypeName = reader.GetDataTypeName(index);
fields[index] = field;
if (!ordinals.Contains(field.Name))
ordinals.Add(field.Name, index);
}
// Cache schema info
schema = reader.GetSchemaTable();
// Cache row data
rows = new ArrayList();
while (reader.Read())
{
object[] values = new object[fields.Length];
reader.GetValues(values);
rows.Add(values);
}
// Cache additional results
if (reader.NextResult())
nextResult = new DisconnectedReader(reader);
// Close the reader once all data has been cached
else
reader.Dispose();
// Set the record index before the first record;
this.recordIndex = -1;
this.lastIndex = rows.Count - 1;
}