本文整理汇总了C#中Microsoft.SqlServer.Server.SqlDataRecord.GetBytes方法的典型用法代码示例。如果您正苦于以下问题:C# SqlDataRecord.GetBytes方法的具体用法?C# SqlDataRecord.GetBytes怎么用?C# SqlDataRecord.GetBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.SqlServer.Server.SqlDataRecord
的用法示例。
在下文中一共展示了SqlDataRecord.GetBytes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetBytes_FromRecord
private static void SetBytes_FromRecord( SmiEventSink_Default sink, ITypedSettersV3 setters, int ordinal, SmiMetaData metaData, SqlDataRecord record, int offset ) {
int length = 0;
// Deal with large values by sending bufferLength of NoLengthLimit (== assume
// CheckXetParameters will ignore requested-length checks in this case
long bufferLength = record.GetBytes(ordinal, 0, null, 0, 0);
if ( bufferLength > Int32.MaxValue ) {
bufferLength = NoLengthLimit;
}
length = CheckXetParameters( metaData.SqlDbType, metaData.MaxLength, NoLengthLimit /* actual */, 0, checked( (int) bufferLength ), offset, checked( (int) bufferLength ) );
int chunkSize;
if ( length > __maxByteChunkSize || length < 0 ) {
chunkSize = __maxByteChunkSize;
}
else {
chunkSize = checked( (int)length );
}
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 = record.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
setters.SetBytesLength( sink, ordinal, currentOffset );
sink.ProcessMessagesAndThrow();
}
示例2: SetBytes_FromRecord
private static void SetBytes_FromRecord(SmiEventSink_Default sink, ITypedSettersV3 setters, int ordinal, SmiMetaData metaData, SqlDataRecord record, int offset)
{
int num6;
long num7;
int num = 0;
long num4 = record.GetBytes(ordinal, 0L, null, 0, 0);
if (num4 > 0x7fffffffL)
{
num4 = -1L;
}
num = CheckXetParameters(metaData.SqlDbType, metaData.MaxLength, -1L, 0L, (int) num4, offset, (int) num4);
if ((num > 0x1f40) || (num < 0))
{
num6 = 0x1f40;
}
else
{
num6 = num;
}
byte[] buffer = new byte[num6];
long num3 = 1L;
long fieldOffset = offset;
for (long i = 0L; ((num < 0) || (i < num)) && ((0L != (num7 = record.GetBytes(ordinal, fieldOffset, buffer, 0, num6))) && (0L != num3)); i += num3)
{
num3 = setters.SetBytes(sink, ordinal, fieldOffset, buffer, 0, (int) num7);
sink.ProcessMessagesAndThrow();
fieldOffset += num3;
}
setters.SetBytesLength(sink, ordinal, fieldOffset);
sink.ProcessMessagesAndThrow();
}