本文整理汇总了C#中IDataReader类的典型用法代码示例。如果您正苦于以下问题:C# IDataReader类的具体用法?C# IDataReader怎么用?C# IDataReader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IDataReader类属于命名空间,在下文中一共展示了IDataReader类的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: ChatMessage
public ChatMessage(IDataReader idr, Int32 offsetHours)
{
SentBy = idr.GetValueByName<String>("SentByUserName").HTMLDecode();
Message = idr.GetValueByName<String>("Message").HTMLDecode();
SentDate = idr.GetValueByName<DateTime>("DateSent").AddHours(offsetHours);
DateSent = SentDate.ToShortDateString() + " " + SentDate.ToLongTimeString();
}
示例3: Deserialize
public override void Deserialize(IDataReader reader)
{
byte flag1 = reader.ReadByte();
enabled = BooleanByteWrapper.GetFlag(flag1, 0);
abandonnedPaddock = BooleanByteWrapper.GetFlag(flag1, 1);
level = reader.ReadByte();
if ( level < 0 || level > 255 )
{
throw new Exception("Forbidden value on level = " + level + ", it doesn't respect the following condition : level < 0 || level > 255");
}
expLevelFloor = reader.ReadDouble();
if ( expLevelFloor < 0 )
{
throw new Exception("Forbidden value on expLevelFloor = " + expLevelFloor + ", it doesn't respect the following condition : expLevelFloor < 0");
}
experience = reader.ReadDouble();
if ( experience < 0 )
{
throw new Exception("Forbidden value on experience = " + experience + ", it doesn't respect the following condition : experience < 0");
}
expNextLevelFloor = reader.ReadDouble();
if ( expNextLevelFloor < 0 )
{
throw new Exception("Forbidden value on expNextLevelFloor = " + expNextLevelFloor + ", it doesn't respect the following condition : expNextLevelFloor < 0");
}
}
示例4: GetEnumerable
public IEnumerable<dynamic> GetEnumerable(IDataReader dr)
{
while (dr.Read())
{
yield return GetObject(dr);
}
}
示例5: Deserialize
public virtual void Deserialize(IDataReader reader)
{
playerInfo = new Types.JobCrafterDirectoryEntryPlayerInfo();
playerInfo.Deserialize(reader);
jobInfo = new Types.JobCrafterDirectoryEntryJobInfo();
jobInfo.Deserialize(reader);
}
示例6: Deserialize
public override void Deserialize(IDataReader reader)
{
base.Deserialize(reader);
targetId = reader.ReadInt();
entityLook = new Types.EntityLook();
entityLook.Deserialize(reader);
}
示例7: BuildSampleEntity
/// <summary>
/// 从读取器向完整实例对象赋值
/// </summary>/// <param name="reader">数据读取器</param>
/// <returns>返回本对象实例</returns>
public ProProductionType BuildSampleEntity(IDataReader reader)
{
this.PTypeId = DBConvert.ToInt32(reader["p_type_id"]);
this.PTypeName = DBConvert.ToString(reader["p_type_name"]);
this.UserId = DBConvert.ToInt32(reader["user_id"]);
return this;
}
示例8: Deserialize
public override void Deserialize(IDataReader reader)
{
base.Deserialize(reader);
targetId = reader.ReadInt();
stateId = reader.ReadShort();
active = reader.ReadBoolean();
}
示例9: Deserialize
public override void Deserialize(IDataReader reader)
{
mapId = reader.ReadInt();
if (mapId < 0)
throw new Exception("Forbidden value on mapId = " + mapId + ", it doesn't respect the following condition : mapId < 0");
mapKey = reader.ReadUTF();
}
示例10: Deserialize
public override void Deserialize(IDataReader reader)
{
id = reader.ReadInt();
if (id < 0)
throw new Exception("Forbidden value on id = " + id + ", it doesn't respect the following condition : id < 0");
ready = reader.ReadBoolean();
}
示例11: Process
/// <summary>
/// Processes the specified <see cref="IDataReader"/>
/// when a ResultMap is specified on the statement.
/// </summary>
/// <param name="request">The request.</param>
/// <param name="reader">The reader.</param>
/// <param name="resultObject">The result object.</param>
public object Process(RequestScope request, ref IDataReader reader, object resultObject)
{
object outObject = resultObject;
IResultMap resultMap = request.CurrentResultMap.ResolveSubMap(reader);
if (outObject == null)
{
object[] parameters = null;
if (resultMap.Parameters.Count > 0)
{
parameters = new object[resultMap.Parameters.Count];
// Fill parameters array
for (int index = 0; index < resultMap.Parameters.Count; index++)
{
ResultProperty resultProperty = resultMap.Parameters[index];
parameters[index] = resultProperty.ArgumentStrategy.GetValue(request, resultProperty, ref reader, null);
}
}
outObject = resultMap.CreateInstanceOfResult(parameters);
}
// For each Property in the ResultMap, set the property in the object
for (int index = 0; index < resultMap.Properties.Count; index++)
{
ResultProperty property = resultMap.Properties[index];
property.PropertyStrategy.Set(request, resultMap, property, ref outObject, reader, null);
}
return outObject;
}
示例12: Process
/// <summary>
/// Processes the specified <see cref="IDataReader"/>
/// when a 'resultClass' attribute is specified on the statement and
/// the 'resultClass' attribute is a <see cref="IDictionary"/>.
/// </summary>
/// <param name="request">The request.</param>
/// <param name="reader">The reader.</param>
/// <param name="resultObject">The result object.</param>
public object Process(RequestScope request, ref IDataReader reader, object resultObject)
{
object outObject = resultObject;
AutoResultMap resultMap = request.CurrentResultMap as AutoResultMap;
if (outObject == null)
{
outObject = resultMap.CreateInstanceOfResultClass();
}
int count = reader.FieldCount;
IDictionary dictionary = (IDictionary) outObject;
for (int i = 0; i < count; i++)
{
ResultProperty property = new ResultProperty();
property.PropertyName = "value";
property.ColumnIndex = i;
property.TypeHandler = request.DataExchangeFactory.TypeHandlerFactory.GetTypeHandler(reader.GetFieldType(i));
dictionary.Add(
reader.GetName(i),
property.GetDataBaseValue(reader));
}
return outObject;
}
示例13: 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;
}
示例14: NullSafeGet
public object NullSafeGet(IDataReader rs, string[] names, object owner)
{
var obj = NHibernateUtil.String.NullSafeGet(rs, names[0]);
if (obj == null) return null;
var colorString = (string)obj;
return ColorTranslator.FromHtml(colorString);
}
示例15: Deserialize
public override void Deserialize(IDataReader reader)
{
dungeonId = reader.ReadShort();
if (dungeonId < 0)
throw new Exception("Forbidden value on dungeonId = " + dungeonId + ", it doesn't respect the following condition : dungeonId < 0");
available = reader.ReadBoolean();
}