本文整理汇总了C#中Microsoft.SqlServer.Server.SqlDataRecord.SetGuid方法的典型用法代码示例。如果您正苦于以下问题:C# SqlDataRecord.SetGuid方法的具体用法?C# SqlDataRecord.SetGuid怎么用?C# SqlDataRecord.SetGuid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.SqlServer.Server.SqlDataRecord
的用法示例。
在下文中一共展示了SqlDataRecord.SetGuid方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateGuidRecord
private static SqlDataRecord CreateGuidRecord(Guid? value)
{
var record = new SqlDataRecord(new SqlMetaData("Value", SqlDbType.UniqueIdentifier));
if (value.HasValue)
record.SetGuid(0, value.Value);
else
record.SetDBNull(0);
return record;
}
示例2: PushLeaseBlobResponse
public static void PushLeaseBlobResponse(Responses.LeaseBlobResponse lbr)
{
SqlDataRecord record = new SqlDataRecord(new SqlMetaData[] {
new SqlMetaData("LeaseId", System.Data.SqlDbType.UniqueIdentifier),
new SqlMetaData("Date", System.Data.SqlDbType.DateTime),
new SqlMetaData("LeaseBreakTimeSeconds", System.Data.SqlDbType.Int),
new SqlMetaData("RequestId", System.Data.SqlDbType.UniqueIdentifier),
new SqlMetaData("Version", System.Data.SqlDbType.NVarChar, 4000)
});
if (lbr.LeaseId.HasValue)
record.SetGuid(0, lbr.LeaseId.Value);
record.SetDateTime(1, lbr.Date);
if (lbr.LeaseTimeSeconds.HasValue)
record.SetInt32(2, lbr.LeaseTimeSeconds.Value);
record.SetGuid(3, lbr.RequestID);
record.SetString(4, lbr.Version);
SqlContext.Pipe.SendResultsStart(record);
SqlContext.Pipe.SendResultsRow(record);
SqlContext.Pipe.SendResultsEnd();
}
示例3: CopyBlob
public static void CopyBlob(
SqlString destinationAccount, SqlString destinationSharedKey, SqlBoolean useHTTPS,
SqlString sourceAccountName,
SqlString sourceContainerName, SqlString sourceBlobName,
SqlGuid sourceLeaseId, SqlGuid destinationLeaseId,
SqlString destinationContainerName, SqlString destinationBlobName,
SqlString xmsclientrequestId)
{
AzureBlobService absDest = new AzureBlobService(destinationAccount.Value, destinationSharedKey.Value, useHTTPS.Value);
Container contDest = absDest.GetContainer(destinationContainerName.Value);
ITPCfSQL.Azure.Blob bbDest = new Azure.Blob(contDest, destinationBlobName.Value);
AzureBlobService absSrc = new AzureBlobService(sourceAccountName.Value, "", useHTTPS.Value);
Container contSrc = absSrc.GetContainer(sourceContainerName.Value);
ITPCfSQL.Azure.Blob bbSrc = new Azure.Blob(contSrc, sourceBlobName.Value);
Responses.CopyBlobResponse resp = bbSrc.Copy(bbDest,
sourceLeaseID: sourceLeaseId.IsNull ? (Guid?)null : sourceLeaseId.Value,
destinationLeaseID: destinationLeaseId.IsNull ? (Guid?)null : destinationLeaseId.Value,
xmsclientrequestId: xmsclientrequestId.IsNull ? null : xmsclientrequestId.Value);
SqlDataRecord record = new SqlDataRecord(
new SqlMetaData[]
{
new SqlMetaData("BlobCopyStatus", System.Data.SqlDbType.NVarChar, 255),
new SqlMetaData("CopyId", System.Data.SqlDbType.NVarChar, 255),
new SqlMetaData("Date", System.Data.SqlDbType.DateTime),
new SqlMetaData("ETag", System.Data.SqlDbType.NVarChar, 255),
new SqlMetaData("LastModified", System.Data.SqlDbType.DateTime),
new SqlMetaData("RequestID", System.Data.SqlDbType.UniqueIdentifier),
new SqlMetaData("Version", System.Data.SqlDbType.NVarChar, 255)
});
SqlContext.Pipe.SendResultsStart(record);
record.SetString(0, resp.BlobCopyStatus.ToString());
record.SetString(1, resp.CopyId);
record.SetDateTime(2, resp.Date);
record.SetString(3, resp.ETag);
record.SetDateTime(4, resp.LastModified);
record.SetGuid(5, resp.RequestID);
record.SetString(6, resp.Version);
SqlContext.Pipe.SendResultsRow(record);
SqlContext.Pipe.SendResultsEnd();
}
示例4: CreateGuidIdRecord
private static SqlDataRecord CreateGuidIdRecord(Guid id)
{
var record = new SqlDataRecord(new SqlMetaData("Id", SqlDbType.UniqueIdentifier));
record.SetGuid(0, id);
return record;
}
示例5: ToSqlDataRecord
private SqlDataRecord ToSqlDataRecord(Guid aggregateId, int expectedVersion, int snapshotVersion, object @event, ref int currentVersion)
{
using (var serializedData = this.serializationMethod.Serialize(@event))
{
var record = new SqlDataRecord(
new SqlMetaData("EventStreamId", SqlDbType.UniqueIdentifier),
new SqlMetaData("ExpectedVersion", SqlDbType.Int),
new SqlMetaData("SnapshotVersion", SqlDbType.Int),
new SqlMetaData("Version", SqlDbType.Int),
new SqlMetaData("EventTypeId", SqlDbType.UniqueIdentifier),
new SqlMetaData("Payload", SqlDbType.Xml));
var column = 0;
record.SetGuid(column++, aggregateId);
record.SetInt32(column++, expectedVersion);
record.SetInt32(column++, snapshotVersion);
record.SetInt32(column++, ++currentVersion);
record.SetGuid(column++, serializedData.TypeId);
record.SetSqlXml(column++, new SqlXml(((XmlSerializedData)serializedData).Reader)); // TODO: May be a memory leak here.
return record;
}
}
示例6: SetValue
//.........这里部分代码省略.........
case SqlDbType.VarBinary:
var bytes = value as byte[];
if (bytes == null)
{
throw new Exception("Value is not byte array");
}
sqlDataRecord.SetBytes(ordinal, 0, bytes, 0, bytes.Length);
break;
case SqlDbType.Int:
var integer = value as int?;
if (integer == null)
{
var ushortValue = (value as ushort?);
if (ushortValue == null)
{
throw new Exception("Value is not int or ushort");
}
integer = ushortValue.Value;
}
sqlDataRecord.SetInt32(ordinal, integer.Value);
break;
case SqlDbType.NText:
case SqlDbType.NVarChar:
case SqlDbType.VarChar:
case SqlDbType.Text:
case SqlDbType.Xml:
var str = value as string;
if (str == null)
{
var chars = value as char[];
if (chars == null)
{
throw new Exception("Value is not string or char array");
}
str = new string(chars);
}
sqlDataRecord.SetString(ordinal, str);
break;
case SqlDbType.Real:
var f = value as float?;
if (f == null)
{
throw new Exception("Value is not float");
}
sqlDataRecord.SetFloat(ordinal, f.Value);
break;
case SqlDbType.UniqueIdentifier:
var guid = value as Guid?;
if (guid == null)
{
throw new Exception("Value is not Guid");
}
sqlDataRecord.SetGuid(ordinal, guid.Value);
break;
case SqlDbType.SmallInt:
var sh = value as short?;
if (sh == null)
{
var uByte = value as sbyte?;
if (uByte == null)
{
throw new Exception("Value is not short or sbyte");
}
sh = uByte.Value;
}
sqlDataRecord.SetInt16(ordinal, sh.Value);
break;
case SqlDbType.TinyInt:
var b = value as byte?;
if (b == null)
{
throw new Exception("Value is not byte");
}
sqlDataRecord.SetByte(ordinal, b.Value);
break;
case SqlDbType.Time:
var timeSpan = value as TimeSpan?;
if (timeSpan == null)
{
throw new Exception("Value is not TimeSpan");
}
sqlDataRecord.SetTimeSpan(ordinal, timeSpan.Value);
break;
case SqlDbType.DateTimeOffset:
var dateTimeOffset = value as DateTimeOffset?;
if (dateTimeOffset == null)
{
throw new Exception("Value is not DateTimeOffset");
}
sqlDataRecord.SetDateTimeOffset(ordinal, dateTimeOffset.Value);
break;
case SqlDbType.Structured:
case SqlDbType.Udt:
case SqlDbType.Timestamp:
case SqlDbType.Variant:
throw new NotImplementedException();
default:
throw new ArgumentOutOfRangeException();
}
}
示例7: AddParameter
public void AddParameter(IDbCommand command, string name)
{
var sqlCommand = (SqlCommand)command;
var number_list = new List<SqlDataRecord>();
var tvp_definition = new[] { new SqlMetaData("Value", SqlDbType.UniqueIdentifier) };
foreach (Guid n in _ids)
{
var rec = new SqlDataRecord(tvp_definition);
rec.SetGuid(0, n);
number_list.Add(rec);
}
var p = sqlCommand.Parameters.Add(name, SqlDbType.Structured);
p.Direction = ParameterDirection.Input;
p.TypeName = "[work].IdList";
p.Value = number_list;
}