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


C# DbDataReader.GetChars方法代码示例

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


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

示例1: SetChars_FromReader

        // Use chunking via SetChars to transfer a value from a reader to a gettersetter
        private static void SetChars_FromReader(SmiEventSink_Default sink, SmiTypedGetterSetter setters, int ordinal, SmiMetaData metaData, DbDataReader reader, int offset) {
            int length = 0;

            // Deal with large values by sending bufferLength of NoLengthLimit (== assume 
            //  CheckXetParameters will ignore requested-length checks in this case)
            length = CheckXetParameters(metaData.SqlDbType, metaData.MaxLength, NoLengthLimit /* actual */, 0, NoLengthLimit /* buffer length */, offset, NoLengthLimit /* requested length */ );

            // Use fixed chunk size for all cases to avoid inquiring from reader.
            int chunkSize;
            if (MetaDataUtilsSmi.IsAnsiType(metaData.SqlDbType)) {
                chunkSize = __maxByteChunkSize;
            } else {
                chunkSize = __maxCharChunkSize;
            }

            char[] buffer = new char[ chunkSize ];
            long charsRead;
            long charsWritten = 1;  // prime value to get into write loop
            long currentOffset = offset;
            long lengthWritten = 0;

            while ((length < 0  || lengthWritten < length) &&
                    0 != (charsRead = reader.GetChars(ordinal, currentOffset, buffer, 0, chunkSize)) &&
                    0 != charsWritten) {
                charsWritten = setters.SetChars(sink, ordinal, currentOffset, buffer, 0, checked((int) charsRead));
                sink.ProcessMessagesAndThrow();
                checked{ currentOffset += charsWritten; }
                checked{ lengthWritten += charsWritten; }
            }

            // Make sure to trim any left-over data (remember to trim at end of offset, not just the amount written
            setters.SetCharsLength(sink, ordinal, currentOffset);
            sink.ProcessMessagesAndThrow();
        }
开发者ID:uQr,项目名称:referencesource,代码行数:35,代码来源:ValueUtilsSmi.cs

示例2: SetChars_FromReader

 private static void SetChars_FromReader(SmiEventSink_Default sink, SmiTypedGetterSetter setters, int ordinal, SmiMetaData metaData, DbDataReader reader, int offset)
 {
     int num4;
     long num6;
     int num5 = 0;
     num5 = CheckXetParameters(metaData.SqlDbType, metaData.MaxLength, -1L, 0L, -1, offset, -1);
     if (MetaDataUtilsSmi.IsAnsiType(metaData.SqlDbType))
     {
         num4 = 0x1f40;
     }
     else
     {
         num4 = 0xfa0;
     }
     char[] buffer = new char[num4];
     long num2 = 1L;
     long dataOffset = offset;
     for (long i = 0L; ((num5 < 0) || (i < num5)) && ((0L != (num6 = reader.GetChars(ordinal, dataOffset, buffer, 0, num4))) && (0L != num2)); i += num2)
     {
         num2 = setters.SetChars(sink, ordinal, dataOffset, buffer, 0, (int) num6);
         sink.ProcessMessagesAndThrow();
         dataOffset += num2;
     }
     setters.SetCharsLength(sink, ordinal, dataOffset);
     sink.ProcessMessagesAndThrow();
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:26,代码来源:ValueUtilsSmi.cs


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