• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# IDataReader类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IDataReader的典型用法代码示例。如果您正苦于以下问题:C# IDataReader类的具体用法?C# IDataReader怎么用?C# IDataReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IDataReader类属于命名空间,在下文中一共展示了IDataReader类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: StupidDataReader

 public StupidDataReader(IDataReader dr, Type returnType)
 {
     this.DataReader = dr;
     if (returnType != null)
     {
         _indexType = new Dictionary<int, Type>();
         _nameType = new Dictionary<string, Type>();
         var ctx = ModelContext.GetInstance(returnType);
         int n = 0;
         foreach (MemberHandler mh in ctx.Info.SimpleMembers)
         {
             _indexType.Add(n++, mh.MemberType);
             if (!_nameType.ContainsKey(mh.Name))
             {
                 _nameType.Add(mh.Name, mh.MemberType);
             }
         }
         foreach (MemberHandler mh in ctx.Info.RelationMembers)
         {
             if (mh.Is.BelongsTo)
             {
                 var ctx1 = ModelContext.GetInstance(mh.MemberType.GetGenericArguments()[0]);
                 _indexType.Add(n++, ctx1.Info.KeyMembers[0].MemberType);
                 _nameType.Add(mh.Name, ctx1.Info.KeyMembers[0].MemberType);
             }
         }
     }
 }
开发者ID:991899783,项目名称:DbEntry,代码行数:28,代码来源:StupidDataReader.cs


示例17: PopulateTree

		/// <summary>
		/// 
		/// </summary>
		/// <param name="root"></param>
		/// <param name="reader"></param>
		/// <param name="prefix"></param>
		public void PopulateTree(CompositeNode root, IDataReader reader, String prefix)
		{
			string[] fields = GetFields(reader);

			int[] indexesToSkip = FindDuplicateFields(fields);
			
			IndexedNode indexNode = new IndexedNode(prefix);
			
			int row = 0;

			while(reader.Read())
			{
				CompositeNode node = new CompositeNode(row.ToString());

				for(int i=0; i<reader.FieldCount; i++)
				{
					// Is in the skip list?
					if (Array.IndexOf(indexesToSkip, i) >= 0) continue;
					
					// Is null?
					if (reader.IsDBNull(i)) continue;
					
					Type fieldType = reader.GetFieldType(i);
					
					node.AddChildNode(new LeafNode(fieldType, fields[i], reader.GetValue(i)));
				}

				indexNode.AddChildNode(node);
			
				row++;
			}
			
			root.AddChildNode(indexNode);
		}
开发者ID:nats,项目名称:castle-1.0.3-mono,代码行数:40,代码来源:DataReaderTreeBuilder.cs


示例18: GetOptionCollectionFromReader

 /// <summary>
 /// Returns a collection of PollOptionDetails objects with the data read from the input DataReader
 /// </summary>
 protected virtual List<PollOptionDetails> GetOptionCollectionFromReader(IDataReader reader)
 {
     List<PollOptionDetails> options = new List<PollOptionDetails>();
      while (reader.Read())
     options.Add(GetOptionFromReader(reader));
      return options;
 }
开发者ID:BGCX261,项目名称:zqerpjohnny-svn-to-git,代码行数:10,代码来源:PollsProvider.cs


示例19: NullSafeGet

 public object NullSafeGet(IDataReader dr, string[] names, object owner)
 {
     var obj = NHibernateUtil.Decimal.NullSafeGet(dr, names[0]);
      if (obj == null) return null;
      var valueInUSD = (decimal)obj;
      return new Money().SetInitialAmount(valueInUSD);
 }
开发者ID:bsimser,项目名称:xeva,代码行数:7,代码来源:MoneyUserType.cs


示例20: DisposeCommandAndReader

 private static void DisposeCommandAndReader(IDbConnection connection, IDbCommand command, IDataReader reader)
 {
     using (connection)
     using (command)
     using (reader)
     { /* NoOp */ }
 }
开发者ID:ToJans,项目名称:Simple.Data,代码行数:7,代码来源:DbCommandExtensions.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IDataRecord类代码示例发布时间:2022-05-24
下一篇:
C# IDataProvider类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap