当前位置: 首页>>代码示例>>C#>>正文


C# IDataReader类代码示例

本文整理汇总了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();
			}
		}
开发者ID:tkellogg,项目名称:NHibernate3-withProxyHooks,代码行数:44,代码来源:NDataReader.cs

示例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();
 }
开发者ID:kwmcrell,项目名称:ArmedCards,代码行数:7,代码来源:ChatMessage.cs

示例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");
     }
 }
开发者ID:Geraff,项目名称:BehaviorIsManaged,代码行数:26,代码来源:GuildInformationsGeneralMessage.cs

示例4: GetEnumerable

		public IEnumerable<dynamic> GetEnumerable(IDataReader dr)
		{
			while (dr.Read())
			{
				yield return GetObject(dr);
			}
		}
开发者ID:kannan-ar,项目名称:MariGold.Data.Database,代码行数:7,代码来源:DynamicDataConverter.cs

示例5: Deserialize

 public virtual void Deserialize(IDataReader reader)
 {
     playerInfo = new Types.JobCrafterDirectoryEntryPlayerInfo();
     playerInfo.Deserialize(reader);
     jobInfo = new Types.JobCrafterDirectoryEntryJobInfo();
     jobInfo.Deserialize(reader);
 }
开发者ID:clapette,项目名称:BehaviorIsManaged,代码行数:7,代码来源:JobCrafterDirectoryListEntry.cs

示例6: Deserialize

 public override void Deserialize(IDataReader reader)
 {
     base.Deserialize(reader);
     targetId = reader.ReadInt();
     entityLook = new Types.EntityLook();
     entityLook.Deserialize(reader);
 }
开发者ID:Guiedo,项目名称:BehaviorIsManaged,代码行数:7,代码来源:GameActionFightChangeLookMessage.cs

示例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;
 }
开发者ID:kbtyc,项目名称:microassistant,代码行数:11,代码来源:ProProductionType.cs

示例8: Deserialize

 public override void Deserialize(IDataReader reader)
 {
     base.Deserialize(reader);
     targetId = reader.ReadInt();
     stateId = reader.ReadShort();
     active = reader.ReadBoolean();
 }
开发者ID:clapette,项目名称:BehaviorIsManaged,代码行数:7,代码来源:GameActionFightStateChangeMessage.cs

示例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();
 }
开发者ID:Torf,项目名称:BehaviorIsManaged,代码行数:7,代码来源:CurrentMapMessage.cs

示例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();
 }
开发者ID:Torf,项目名称:BehaviorIsManaged,代码行数:7,代码来源:ExchangeIsReadyMessage.cs

示例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;
        }
开发者ID:zuifengke,项目名称:windy-ibatisnet,代码行数:39,代码来源:ResultMapStrategy.cs

示例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;
        }
开发者ID:zuifengke,项目名称:windy-ibatisnet,代码行数:33,代码来源:DictionaryStrategy.cs

示例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;
        }
开发者ID:aureliopires,项目名称:gisa,代码行数:40,代码来源:EstatisticasRule.cs

示例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);
 }
开发者ID:ToJans,项目名称:MVCExtensions,代码行数:7,代码来源:ColorUserType.cs

示例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();
 }
开发者ID:Guiedo,项目名称:BehaviorIsManaged,代码行数:7,代码来源:DungeonKeyRingUpdateMessage.cs


注:本文中的IDataReader类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。