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


C# IDataReader.GetBytes方法代码示例

本文整理汇总了C#中IDataReader.GetBytes方法的典型用法代码示例。如果您正苦于以下问题:C# IDataReader.GetBytes方法的具体用法?C# IDataReader.GetBytes怎么用?C# IDataReader.GetBytes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IDataReader的用法示例。


在下文中一共展示了IDataReader.GetBytes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Get

		public override object Get(IDataReader rs, int index)
		{
			int length = (int)rs.GetBytes(index, 0, null, 0, 0);
			byte[] buffer = new byte[length];
			rs.GetBytes(index, 0, buffer, 0, length);
			return ToExternalFormat(buffer);
		}
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:7,代码来源:AbstractBinaryType.cs

示例2: ReadBytesFromBlob

        //---------------------------------------------------------------------------
        // protected methods that can be overridden by subclasses
        //---------------------------------------------------------------------------
        protected override byte[] ReadBytesFromBlob(IDataReader dr, int colIndex)
        {
            if (dr.IsDBNull(colIndex))
            {
                return null;
            }

            // PostgreSQL reads all data at once

            long dataLength = dr.GetBytes(colIndex, 0, null, 0, 0);
            byte[] data = new byte[dataLength];
            dr.GetBytes(colIndex, 0, data, 0, 0);
            return data;
        }
开发者ID:Leftyx,项目名称:quartznet,代码行数:17,代码来源:PostgreSQLDelegate.cs

示例3: GetValueByIndex

        /// <summary>
        /// Gets a column value by the index
        /// </summary>
        /// <param name="mapping"></param>
        /// <param name="dataReader"></param>
        /// <returns></returns>
		public override object GetValueByIndex(ResultProperty mapping, IDataReader dataReader)
        {
            if (dataReader.IsDBNull(mapping.ColumnIndex) || dataReader.GetBytes(mapping.ColumnIndex, 0, null, 0, 0) == 0)
            {
                return DBNull.Value;
            }
            return GetValueByIndex(mapping.ColumnIndex, dataReader);
        }
开发者ID:techvenky,项目名称:mybatisnet,代码行数:14,代码来源:ByteArrayTypeHandler.cs

示例4: GetValueByName

        /// <summary>
        /// Gets a column value by the name
        /// </summary>
        /// <param name="mapping"></param>
        /// <param name="dataReader"></param>
        /// <returns></returns>
		public override object GetValueByName(ResultProperty mapping, IDataReader dataReader)
		{
            int index = dataReader.GetOrdinal(mapping.ColumnName);

            if (dataReader.IsDBNull(index) || dataReader.GetBytes(index, 0, null, 0, 0) == 0)
            {
                return DBNull.Value;
            }
            return GetValueByIndex(index, dataReader);
		}
开发者ID:techvenky,项目名称:mybatisnet,代码行数:16,代码来源:ByteArrayTypeHandler.cs

示例5: Get

        public override object Get(IDataReader rs, int index)
        {
            int length = (int) rs.GetBytes(index, 0, null, 0, 0);
            byte[] bytes = new byte[length];

            int offset = 0;

            while (offset < length)
            {
                int count = (int) rs.GetBytes(index, offset, bytes, offset, length - offset);
                offset += count;

                if (count == 0)
                {
                    throw new AssertionFailure("IDataRecord.GetBytes returned 0");
                }
            }

            return new SqlBinary(bytes);
        }
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:20,代码来源:SqlBinaryType.cs

示例6: Get

		public override object Get(IDataReader rs, int index)
		{
			int length = (int)rs.GetBytes(index, 0, null, 0, 0);
			byte[] buffer = new byte[length];
			if (length > 0)
			{
				// The "if" is to make happy MySQL NH-2096
				rs.GetBytes(index, 0, buffer, 0, length);
			}
			return ToExternalFormat(buffer);
		}
开发者ID:juanplopes,项目名称:nhibernate,代码行数:11,代码来源:AbstractBinaryType.cs

示例7: Get

		/// <summary>
		/// 
		/// </summary>
		/// <param name="rs"></param>
		/// <param name="index"></param>
		/// <returns></returns>
		public override object Get( IDataReader rs, int index )
		{
			int length = ( int ) rs.GetBytes( index, 0, null, 0, 0 );
			byte[ ] buffer = new byte[ length ];

			int offset = 0;

			while( length - offset > 0 )
			{
				int countRead = ( int ) rs.GetBytes( index, offset, buffer, offset, length - offset );
				offset += countRead;

				if( countRead == 0 )
				{
					// Should never happen
					throw new AssertionFailure( "Error in BinaryType.Get, IDataRecord.GetBytes read zero bytes" );
				}
			}

			return buffer;
		}
开发者ID:rcarrillopadron,项目名称:nhibernate-1.0.2.0,代码行数:27,代码来源:BinaryType.cs

示例8: GetByte

        public static byte[] GetByte(IDataReader dr, string columnName, int length)
        {
            int ordinal = dr.GetOrdinal(columnName);
            bool isDbNull = dr.IsDBNull(ordinal);

            byte[] buffer = null;

            if (!isDbNull)
            {
                buffer = new byte[length];
                dr.GetBytes(ordinal, 0, buffer, 0, length);
            }

            return buffer;
        }
开发者ID:aserdaray,项目名称:Projects,代码行数:15,代码来源:DataExtractor.cs

示例9: Get

		protected virtual object Get(IDataReader rs, int ordinal)
		{
			int bufferSize = 0x1000;
			byte[] buffer = new byte[bufferSize];

			int readBytes = (int)rs.GetBytes(ordinal, 0L, buffer, 0, bufferSize);
			long position = readBytes;
			using (MemoryStream data = new MemoryStream(readBytes))
			{
				if (readBytes >= bufferSize)
					while (readBytes > 0)
					{
						data.Write(buffer, 0, readBytes);
						position += (readBytes = (int)rs.GetBytes(ordinal, position, buffer, 0, bufferSize));
					}

				data.Write(buffer, 0, readBytes);
				data.Flush();
				if (data.Length == 0)
					return GetValue(new byte[0]);

				return GetValue(data.ToArray());
			}
		}
开发者ID:sebmarkbage,项目名称:calyptus.lob,代码行数:24,代码来源:AbstractLobType.cs

示例10: NullSafeGet

		public override object NullSafeGet(IDataReader rs, string name, ISessionImplementor session, object owner)
		{
			int index = rs.GetOrdinal(name);

			if (rs.IsDBNull(index)) return null;

			IExternalBlobConnection conn = GetExternalBlobConnection(session);

			byte[] identifier = new byte[conn.BlobIdentifierLength];

			int i = (int)rs.GetBytes(index, 0, identifier, 0, identifier.Length);
			if (i != identifier.Length) throw new Exception("Unknown identifier length. Recieved " + i.ToString() + " but expected " + identifier.Length.ToString() + " bytes");

			return CreateLobInstance(conn, identifier);
		}
开发者ID:sebmarkbage,项目名称:calyptus.lob,代码行数:15,代码来源:AbstractExternalBlobType.cs

示例11: fetchWordList

        public bool fetchWordList(ref WorldList wl)
        {
            // Doesnt exist by default
            wl.setExistance(false);

            string sqlQuery = "select * from users where username='"+wl.getUsername()+"' and passwordmd5='"+wl.getPassword()+"';";
            queryExecuter= conn.CreateCommand();
            queryExecuter.CommandText = sqlQuery;
            dr= queryExecuter.ExecuteReader();

            while(dr.Read()){
                // Player is on the DB
                wl.setExistance(true);
                wl.setUserID((int) dr.GetDecimal(0));
                dr.GetBytes(6,0,wl.getPrivateExponent(),0,96);
                dr.GetBytes(5,0,wl.getPublicModulus(),0,96);
                wl.setTimeCreated((int)dr.GetDecimal(7));
            }

            dr.Close();

            // If doesnt exist... should not do more things
            if (!wl.getExistance()){
                Output.writeToLogForConsole("[WORLD DB ACCESS] fetchWordList : Player not found on DB with #" + wl.getUsername() + "# and #" + wl.getPassword() + "#");
                conn.Close();
                return false;
            }
            return true;
        }
开发者ID:hdneo,项目名称:mxo-hd,代码行数:29,代码来源:MyWorldDbAccess.cs

示例12: GenParameterText

        //将 DataReader 中的数据打包为报表需要的参数数据包形式
        public static string GenParameterText(IDataReader drParamer)
        {
            StringBuilder sbJSONText = new StringBuilder();
            if (drParamer.Read())
            {
                for (int i = 0; i < drParamer.FieldCount; ++i)
                {
                    if (drParamer.IsDBNull(i))
                        continue;

                    string Value;
                    if (drParamer.GetFieldType(i).IsArray)
                    {
                        long DataSize = drParamer.GetBytes(i, 0, null, 0, int.MaxValue);
                        byte[] buffer = new byte[DataSize];
                        drParamer.GetBytes(i, 0, buffer, 0, (int)DataSize);
                        Value = Convert.ToBase64String(buffer);
                    }
                    else
                    {
                        Value = drParamer.GetValue(i).ToString();
                        PrepareValueText(ref Value);
                    }

                    sbJSONText.AppendFormat("\"{0}\":\"{1}\",", drParamer.GetName(i), Value);
                }
            }
            sbJSONText.Remove(sbJSONText.Length - 1, 1); //去掉最后一个字段后面的","
            return sbJSONText.ToString();
        }
开发者ID:keep01,项目名称:efwplus_winformframe,代码行数:31,代码来源:ReportData.cs

示例13: ReadBytesFromBlob

        protected virtual byte[] ReadBytesFromBlob(IDataReader dr, int colIndex)
        {
            if (dr.IsDBNull(colIndex))
            {
                return null;
            }

            int bufferSize = 1024;
            MemoryStream stream = new MemoryStream();

            // can read the data
            byte[] outbyte = new byte[bufferSize];

            // Reset the starting byte for the new BLOB.
            int startIndex;
            startIndex = 0;

            // Read the bytes into outbyte[] and retain the number of bytes returned.

            int retval; // The bytes returned from GetBytes.
            retval = (int)dr.GetBytes(colIndex, startIndex, outbyte, 0, bufferSize);

            // Continue reading and writing while there are bytes beyond the size of the buffer.
            while (retval == bufferSize)
            {
                stream.Write(outbyte, 0, retval);

                // Reposition the start index to the end of the last buffer and fill the buffer.
                startIndex += bufferSize;
                retval = (int)dr.GetBytes(colIndex, startIndex, outbyte, 0, bufferSize);
            }

            // Write the remaining buffer.
            stream.Write(outbyte, 0, retval);

            return stream.GetBuffer();
        }
开发者ID:kisflying,项目名称:kion,代码行数:37,代码来源:StdAdoDelegate.cs

示例14: GetBytes

 public int GetBytes(IDataReader reader, long dataOffset, byte[] buffer, int bufferIndex, int length)
 {
     InitColumn(reader);
     return (int)reader.GetBytes(Ordinal, dataOffset, buffer, bufferIndex, length);
 }
开发者ID:ylux587,项目名称:FindHomeMadeFoodNearMe,代码行数:5,代码来源:SqlColumnBinder.cs

示例15: NullSafeGet

        public override object NullSafeGet(IDataReader rs, string name, ISessionImplementor session, object owner)
        {
            int index = rs.GetOrdinal(name);

            if (rs.IsDBNull(index)) return null;

            IExternalBlobConnection conn = GetExternalBlobConnection(session);

            byte[] payload;

            if (conn.BlobIdentifierLength == Int32.MaxValue)
            {
                var length = (int) rs.GetBytes(index, 0L, null, 0, 0);
                payload = new byte[length];
                // The if here makes MySql happy (See https://nhibernate.jira.com/browse/NH-2096 for details)
                if (length > 0)
                {
                    rs.GetBytes(index, 0L, payload, 0, length);
                }
            }
            else
            {
                payload = new byte[conn.BlobIdentifierLength];

                // The if here makes MySql happy (See https://nhibernate.jira.com/browse/NH-2096 for details)
                if (payload.Length > 0)
                {
                    var i = (int) rs.GetBytes(index, 0, payload, 0, payload.Length);

                    if (i != payload.Length)
                    {
                        if (Logger.IsErrorEnabled) Logger.ErrorFormat("Unknown payload (identifier) length. Recieved {0} but expected {1} bytes for owner: {2}", i, payload.Length, owner);
                        return null;
                    }
                }
                else
                {
                    if (Logger.IsErrorEnabled) Logger.ErrorFormat("Unknown payload (identifier) length. Recieved 0 but expected {0} bytes for owner: {1}", payload.Length, owner);
                    return null;
                }
            }

            return CreateLobInstance(conn, payload);
        }
开发者ID:bittercoder,项目名称:Lob,代码行数:44,代码来源:AbstractExternalBlobType.cs


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