本文整理汇总了C#中System.Data.SqlClient.SqlDataReader.GetSqlBytes方法的典型用法代码示例。如果您正苦于以下问题:C# SqlDataReader.GetSqlBytes方法的具体用法?C# SqlDataReader.GetSqlBytes怎么用?C# SqlDataReader.GetSqlBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.SqlClient.SqlDataReader
的用法示例。
在下文中一共展示了SqlDataReader.GetSqlBytes方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Load
internal static Message Load(SqlDataReader reader) {
var message = new Message
{
ConversationGroupId = reader.GetGuid(0),
ConversationHandle = reader.GetGuid(1),
MessageSequenceNumber = reader.GetInt64(2),
ServiceName = reader.GetString(3),
ServiceContractName = reader.GetString(4),
MessageTypeName = reader.GetString(5),
Body = reader.IsDBNull(7) ? new byte[0] : reader.GetSqlBytes(7).Buffer
};
return message;
}
示例2: ServiceBrokerMessage
private ServiceBrokerMessage(SqlDataReader reader)
{
ConversationHandle = reader.GetGuid(0);
ServiceName = reader.GetString(1);
ServiceContractName = reader.GetString(2);
MessageTypeName = reader.GetString(3);
if (!reader.IsDBNull(4))
{
Body = reader.GetSqlBytes(4).Buffer;
}
else
{
Body = new byte[0];
}
}
示例3: Load
public static ServiceBrokerMessage Load(SqlDataReader reader)
{
var message = new ServiceBrokerMessage();
message.ConversationHandle = reader.GetGuid(0);
message.ServiceName = reader.GetString(1);
message.ServiceContractName = reader.GetString(2);
message.MessageTypeName = reader.GetString(3);
if (!reader.IsDBNull(4))
{
message.Body = reader.GetSqlBytes(4).Buffer;
}
else
{
message.Body = new byte[0];
}
return message;
}
示例4: Load
internal static Message Load(SqlDataReader reader) {
var message = new Message();
// RECEIVE conversation_group_id, conversation_handle,
// message_sequence_number, service_name, service_contract_name,
// message_type_name, validation, message_body
// FROM Queue
message.ConversationGroupId = reader.GetGuid(0);
message.ConversationHandle = reader.GetGuid(1);
message.MessageSequenceNumber = reader.GetInt64(2);
message.ServiceName = reader.GetString(3);
message.ServiceContractName = reader.GetString(4);
message.MessageTypeName = reader.GetString(5);
//m_validation = reader.GetString(6);
if (!reader.IsDBNull(7)) {
message.Body = reader.GetSqlBytes(7).Buffer;
} else
message.Body = new byte[0];
return message;
}
示例5: FillCompatibleITypedSettersFromReader
// Copy multiple fields from reader to ITypedSettersV3
// Assumes caller enforces that reader and setter metadata are compatible
internal static void FillCompatibleITypedSettersFromReader( SmiEventSink_Default sink, ITypedSettersV3 setters, SmiMetaData[] metaData, SqlDataReader reader ) {
for ( int i = 0; i < metaData.Length; i++ ) {
if ( reader.IsDBNull(i) ) {
ValueUtilsSmi.SetDBNull_Unchecked( sink, setters, i );
}
else {
switch ( metaData[i].SqlDbType ) {
case SqlDbType.BigInt:
Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.Int64 ) );
ValueUtilsSmi.SetInt64_Unchecked( sink, setters, i, reader.GetInt64(i) );
break;
case SqlDbType.Binary:
Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.SqlBytes ) );
ValueUtilsSmi.SetSqlBytes_LengthChecked( sink, setters, i, metaData[i], reader.GetSqlBytes(i), 0 );
break;
case SqlDbType.Bit:
Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.Boolean ) );
SetBoolean_Unchecked( sink, setters, i, reader.GetBoolean(i) );
break;
case SqlDbType.Char:
Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.SqlChars ) );
SetSqlChars_LengthChecked( sink, setters, i, metaData[i], reader.GetSqlChars(i), 0 );
break;
case SqlDbType.DateTime:
Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.DateTime ) );
SetDateTime_Checked( sink, setters, i, metaData[i], reader.GetDateTime(i) );
break;
case SqlDbType.Decimal:
Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.SqlDecimal ) );
SetSqlDecimal_Unchecked( sink, setters, i, reader.GetSqlDecimal(i) );
break;
case SqlDbType.Float:
Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.Double ) );
SetDouble_Unchecked( sink, setters, i, reader.GetDouble(i) );
break;
case SqlDbType.Image:
Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.SqlBytes ) );
SetSqlBytes_LengthChecked( sink, setters, i, metaData[i], reader.GetSqlBytes(i), 0 );
break;
case SqlDbType.Int:
Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.Int32 ) );
SetInt32_Unchecked( sink, setters, i, reader.GetInt32(i) );
break;
case SqlDbType.Money:
Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.SqlMoney ) );
SetSqlMoney_Unchecked( sink, setters, i, metaData[i], reader.GetSqlMoney(i) );
break;
case SqlDbType.NChar:
case SqlDbType.NText:
case SqlDbType.NVarChar:
Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.SqlChars ) );
SetSqlChars_LengthChecked( sink, setters, i, metaData[i], reader.GetSqlChars(i), 0 );
break;
case SqlDbType.Real:
Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.Single ) );
SetSingle_Unchecked( sink, setters, i, reader.GetFloat(i) );
break;
case SqlDbType.UniqueIdentifier:
Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.Guid ) );
SetGuid_Unchecked( sink, setters, i, reader.GetGuid(i) );
break;
case SqlDbType.SmallDateTime:
Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.DateTime ) );
SetDateTime_Checked( sink, setters, i, metaData[i], reader.GetDateTime(i) );
break;
case SqlDbType.SmallInt:
Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.Int16 ) );
SetInt16_Unchecked( sink, setters, i, reader.GetInt16(i) );
break;
case SqlDbType.SmallMoney:
Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.SqlMoney ) );
SetSqlMoney_Checked( sink, setters, i, metaData[i], reader.GetSqlMoney(i) );
break;
case SqlDbType.Text:
Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.SqlChars ) );
SetSqlChars_LengthChecked( sink, setters, i, metaData[i], reader.GetSqlChars(i), 0 );
break;
case SqlDbType.Timestamp:
Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.SqlBytes ) );
SetSqlBytes_LengthChecked( sink, setters, i, metaData[i], reader.GetSqlBytes(i), 0 );
break;
case SqlDbType.TinyInt:
Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.Byte ) );
SetByte_Unchecked( sink, setters, i, reader.GetByte(i) );
break;
case SqlDbType.VarBinary:
Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.SqlBytes ) );
SetSqlBytes_LengthChecked( sink, setters, i, metaData[i], reader.GetSqlBytes(i), 0 );
break;
case SqlDbType.VarChar:
Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.String ) );
SetSqlChars_LengthChecked( sink, setters, i, metaData[i], reader.GetSqlChars(i), 0 );
break;
case SqlDbType.Xml:
Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.SqlXml ) );
SetSqlXml_Unchecked( sink, setters, i, reader.GetSqlXml(i) );
break;
case SqlDbType.Variant:
//.........这里部分代码省略.........
示例6: FillCompatibleITypedSettersFromReader
internal static void FillCompatibleITypedSettersFromReader(SmiEventSink_Default sink, ITypedSettersV3 setters, SmiMetaData[] metaData, SqlDataReader reader)
{
for (int i = 0; i < metaData.Length; i++)
{
if (reader.IsDBNull(i))
{
SetDBNull_Unchecked(sink, setters, i);
continue;
}
switch (metaData[i].SqlDbType)
{
case SqlDbType.BigInt:
{
SetInt64_Unchecked(sink, setters, i, reader.GetInt64(i));
continue;
}
case SqlDbType.Binary:
{
SetSqlBytes_LengthChecked(sink, setters, i, metaData[i], reader.GetSqlBytes(i), 0);
continue;
}
case SqlDbType.Bit:
{
SetBoolean_Unchecked(sink, setters, i, reader.GetBoolean(i));
continue;
}
case SqlDbType.Char:
{
SetSqlChars_LengthChecked(sink, setters, i, metaData[i], reader.GetSqlChars(i), 0);
continue;
}
case SqlDbType.DateTime:
{
SetDateTime_Checked(sink, setters, i, metaData[i], reader.GetDateTime(i));
continue;
}
case SqlDbType.Decimal:
{
SetSqlDecimal_Unchecked(sink, setters, i, reader.GetSqlDecimal(i));
continue;
}
case SqlDbType.Float:
{
SetDouble_Unchecked(sink, setters, i, reader.GetDouble(i));
continue;
}
case SqlDbType.Image:
{
SetSqlBytes_LengthChecked(sink, setters, i, metaData[i], reader.GetSqlBytes(i), 0);
continue;
}
case SqlDbType.Int:
{
SetInt32_Unchecked(sink, setters, i, reader.GetInt32(i));
continue;
}
case SqlDbType.Money:
{
SetSqlMoney_Unchecked(sink, setters, i, metaData[i], reader.GetSqlMoney(i));
continue;
}
case SqlDbType.NChar:
case SqlDbType.NText:
case SqlDbType.NVarChar:
{
SetSqlChars_LengthChecked(sink, setters, i, metaData[i], reader.GetSqlChars(i), 0);
continue;
}
case SqlDbType.Real:
{
SetSingle_Unchecked(sink, setters, i, reader.GetFloat(i));
continue;
}
case SqlDbType.UniqueIdentifier:
{
SetGuid_Unchecked(sink, setters, i, reader.GetGuid(i));
continue;
}
case SqlDbType.SmallDateTime:
{
SetDateTime_Checked(sink, setters, i, metaData[i], reader.GetDateTime(i));
continue;
}
case SqlDbType.SmallInt:
{
SetInt16_Unchecked(sink, setters, i, reader.GetInt16(i));
continue;
}
case SqlDbType.SmallMoney:
{
SetSqlMoney_Checked(sink, setters, i, metaData[i], reader.GetSqlMoney(i));
continue;
}
case SqlDbType.Text:
{
SetSqlChars_LengthChecked(sink, setters, i, metaData[i], reader.GetSqlChars(i), 0);
continue;
}
case SqlDbType.Timestamp:
{
//.........这里部分代码省略.........
示例7: BuildRecordInfo
internal static RecordInfo BuildRecordInfo(SqlDataReader reader, ITableInfoProvider tableInfoProvider)
{
RecordInfo record = new RecordInfo();
record._Operation = GetOperation((string)reader["Operation"]);
record._LogSequenceNumber = new LogSequenceNumber(reader);
if (!reader.IsDBNull(reader.GetOrdinal("AllocUnitName")))
{
record._AllocationUnitName = AllocationUnitName.FromString((string)reader["AllocUnitName"]);
if (record._AllocationUnitName != null)
{
record._Table = tableInfoProvider.GetTable(record._AllocationUnitName.ObjectName,
"sys".Equals(record._AllocationUnitName.SchemaName));
}
}
if (!reader.IsDBNull(reader.GetOrdinal("RowLog Contents 0")))
{
record._RowLogContents0 = reader.GetSqlBytes(reader.GetOrdinal("RowLog Contents 0")).Buffer;
}
if (!reader.IsDBNull(reader.GetOrdinal("RowLog Contents 1")))
{
record._RowLogContents1 = reader.GetSqlBytes(reader.GetOrdinal("RowLog Contents 1")).Buffer;
}
if (!reader.IsDBNull(reader.GetOrdinal("Offset in Row")))
{
record._RowOffset = (short)reader["Offset in Row"];
}
return record;
}
示例8: GetByteArrayColumn
private byte[] GetByteArrayColumn(SqlDataReader reader, string column)
{
SqlBytes bytes = reader.GetSqlBytes(reader.GetOrdinal(column));
return bytes.Buffer;
}