本文整理汇总了C#中Microsoft.SqlServer.Server.SmiTypedGetterSetter.SetBytesLength方法的典型用法代码示例。如果您正苦于以下问题:C# SmiTypedGetterSetter.SetBytesLength方法的具体用法?C# SmiTypedGetterSetter.SetBytesLength怎么用?C# SmiTypedGetterSetter.SetBytesLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.SqlServer.Server.SmiTypedGetterSetter
的用法示例。
在下文中一共展示了SmiTypedGetterSetter.SetBytesLength方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetBytes_FromReader
private static void SetBytes_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 = __maxByteChunkSize;
byte[] buffer = new byte[ chunkSize ];
long bytesRead;
long bytesWritten = 1; // prime value to get into write loop
long currentOffset = offset;
long lengthWritten = 0;
while ((length < 0 || lengthWritten < length) &&
0 != (bytesRead = reader.GetBytes(ordinal, currentOffset, buffer, 0, chunkSize)) &&
0 != bytesWritten) {
bytesWritten = setters.SetBytes(sink, ordinal, currentOffset, buffer, 0, checked((int) bytesRead));
sink.ProcessMessagesAndThrow();
checked{ currentOffset += bytesWritten; }
checked{ lengthWritten += bytesWritten; }
}
// Make sure to trim any left-over data (remember to trim at end of offset, not just the amount written
setters.SetBytesLength(sink, ordinal, currentOffset);
sink.ProcessMessagesAndThrow();
}
示例2: SetBytes_FromReader
private static void SetBytes_FromReader(SmiEventSink_Default sink, SmiTypedGetterSetter setters, int ordinal, SmiMetaData metaData, DbDataReader reader, int offset)
{
long num6;
int num4 = 0;
num4 = CheckXetParameters(metaData.SqlDbType, metaData.MaxLength, -1L, 0L, -1, offset, -1);
int length = 0x1f40;
byte[] buffer = new byte[length];
long num2 = 1L;
long dataOffset = offset;
for (long i = 0L; ((num4 < 0) || (i < num4)) && ((0L != (num6 = reader.GetBytes(ordinal, dataOffset, buffer, 0, length))) && (0L != num2)); i += num2)
{
num2 = setters.SetBytes(sink, ordinal, dataOffset, buffer, 0, (int) num6);
sink.ProcessMessagesAndThrow();
dataOffset += num2;
}
setters.SetBytesLength(sink, ordinal, dataOffset);
sink.ProcessMessagesAndThrow();
}