本文整理汇总了C#中System.Data.SqlClient.SqlParameterCollection.Add方法的典型用法代码示例。如果您正苦于以下问题:C# SqlParameterCollection.Add方法的具体用法?C# SqlParameterCollection.Add怎么用?C# SqlParameterCollection.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.SqlClient.SqlParameterCollection
的用法示例。
在下文中一共展示了SqlParameterCollection.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddSerializedProperty
private static void AddSerializedProperty(ArraySegment<byte> source, SqlParameterCollection parameters, string parameterName)
{
int num = (source.Count > 0x1f40) ? source.Count : -1;
object obj2 = ((num == -1) ? ((bool) GenerateByteArray(source)) : ((bool) source.Array)) ?? DBNull.Value;
SqlParameter parameter = new SqlParameter {
ParameterName = parameterName,
SqlDbType = SqlDbType.VarBinary,
Size = num,
Value = obj2
};
parameters.Add(parameter);
}
示例2: AddSerializedProperty
static void AddSerializedProperty(ArraySegment<byte> source, SqlParameterCollection parameters, string parameterName)
{
int parameterSize = source.Count > 8000 ? source.Count : -1;
object parameterValue = (parameterSize == -1 ? SaveWorkflowAsyncResult.GenerateByteArray(source) : source.Array) ?? (object)DBNull.Value;
parameters.Add(new SqlParameter { ParameterName = parameterName, SqlDbType = SqlDbType.VarBinary, Size = parameterSize, Value = parameterValue });
}
示例3: AddWithValue
internal static SqlParameter AddWithValue(SqlParameterCollection parameters, string paramName, string paramValue)
{
#if NETv2_0
return parameters.AddWithValue(paramName, paramValue);
#else
return parameters.Add(paramName, paramValue);
#endif
}
示例4: Append
internal void Append(SqlCommand command) {
ADP.CheckArgumentNull(command, "command");
Bid.Trace("<sc.SqlCommandSet.Append|API> %d#, command=%d, parameterCount=%d\n", ObjectID, command.ObjectID, command.Parameters.Count);
string cmdText = command.CommandText;
if (ADP.IsEmpty(cmdText)) {
throw ADP.CommandTextRequired(ADP.Append);
}
CommandType commandType = command.CommandType;
switch(commandType) {
case CommandType.Text:
case CommandType.StoredProcedure:
break;
case CommandType.TableDirect:
Debug.Assert(false, "command.CommandType");
throw System.Data.SqlClient.SQL.NotSupportedCommandType(commandType);
default:
Debug.Assert(false, "command.CommandType");
throw ADP.InvalidCommandType(commandType);
}
SqlParameterCollection parameters = null;
SqlParameterCollection collection = command.Parameters;
if (0 < collection.Count) {
parameters = new SqlParameterCollection();
// clone parameters so they aren't destroyed
for(int i = 0; i < collection.Count; ++i) {
SqlParameter p = new SqlParameter();
collection[i].CopyTo(p);
parameters.Add(p);
// SQL Injection awarene
if (!SqlIdentifierParser.IsMatch(p.ParameterName)) {
throw ADP.BadParameterName(p.ParameterName);
}
}
foreach(SqlParameter p in parameters) {
// deep clone the parameter value if byte[] or char[]
object obj = p.Value;
byte[] byteValues = (obj as byte[]);
if (null != byteValues) {
int offset = p.Offset;
int size = p.Size;
int countOfBytes = byteValues.Length - offset;
if ((0 != size) && (size < countOfBytes)) {
countOfBytes = size;
}
byte[] copy = new byte[Math.Max(countOfBytes, 0)];
Buffer.BlockCopy(byteValues, offset, copy, 0, copy.Length);
p.Offset = 0;
p.Value = copy;
}
else {
char[] charValues = (obj as char[]);
if (null != charValues) {
int offset = p.Offset;
int size = p.Size;
int countOfChars = charValues.Length - offset;
if ((0 != size) && (size < countOfChars)) {
countOfChars = size;
}
char[] copy = new char[Math.Max(countOfChars, 0)];
Buffer.BlockCopy(charValues, offset, copy, 0, copy.Length*2);
p.Offset = 0;
p.Value = copy;
}
else {
ICloneable cloneable = (obj as ICloneable);
if (null != cloneable) {
p.Value = cloneable.Clone();
}
}
}
}
}
int returnParameterIndex = -1;
if (null != parameters) {
for(int i = 0; i < parameters.Count; ++i) {
if (ParameterDirection.ReturnValue == parameters[i].Direction) {
returnParameterIndex = i;
break;
}
}
}
LocalCommand cmd = new LocalCommand(cmdText, parameters, returnParameterIndex, command.CommandType);
CommandList.Add(cmd);
}
示例5: AssignSpParams
/// <summary>
/// With a MSSQL Stored Proc there is no way of knowing what, if any, kind of dataset
/// will be returned. This is inteneded as a heuristic solution and is expected to
/// be called prior to actually invoking the stored proc on a SqlClient connection\command.
/// </summary>
/// <param name="sqlParams"></param>
public void AssignSpParams(SqlParameterCollection sqlParams)
{
if(string.IsNullOrWhiteSpace(ProcName))
throw new RahRowRagee("This instance does not have a ProcName assigned.");
var myRand = new Random(Convert.ToInt32(string.Format("{0:ffffff}", DateTime.Now)));
foreach (var param in Parameters)
{
if (param.IsDataTable())
{
sqlParams.Add(new SqlParameter(param.ParamName, null));
continue;
}
var randStr = new StringBuilder();
var llen = param.StringLength > MAX_STR_LEN || param.StringLength < 0
? MAX_STR_LEN
: param.StringLength;
//assign some lower-case letters
for (var i = 0; i < llen; i++)
{
randStr.Append(Convert.ToChar((byte)myRand.Next(0x61, 0x7A)));
}
if (param.IsOpenToSqlInj)
{
randStr.Clear();
//we just want the schema not the data...
randStr.Append(" AND 1 = 0");
}
SqlParameter sqlParam;
var sqlParamType = param.GetSqlDataType();
switch (sqlParamType)
{
case SqlDbType.NText:
case SqlDbType.NVarChar:
case SqlDbType.Text:
case SqlDbType.VarChar:
sqlParam = new SqlParameter(param.ParamName, param.GetSqlDataType())
{
IsNullable = param.IsNullable,
Direction = param.IsOutput ? ParameterDirection.Output : ParameterDirection.Input,
Value = randStr.ToString()
};
break;
case SqlDbType.Xml:
sqlParam = new SqlParameter(param.ParamName, param.GetSqlDataType())
{
IsNullable = param.IsNullable,
Direction = param.IsOutput ? ParameterDirection.Output : ParameterDirection.Input,
Value = "<my-node>" + randStr + "</my-node>"
};
break;
case SqlDbType.NChar:
case SqlDbType.Char:
sqlParam = new SqlParameter(param.ParamName, param.GetSqlDataType())
{
IsNullable = param.IsNullable,
Direction = param.IsOutput ? ParameterDirection.Output : ParameterDirection.Input,
Value = Convert.ToChar((byte)myRand.Next(0x61, 0x7A))
};
break;
case SqlDbType.BigInt:
case SqlDbType.Decimal:
case SqlDbType.Float:
case SqlDbType.Int:
case SqlDbType.Money:
case SqlDbType.Real:
case SqlDbType.SmallInt:
case SqlDbType.SmallMoney:
case SqlDbType.TinyInt:
sqlParam = new SqlParameter(param.ParamName, param.GetSqlDataType())
{
IsNullable = param.IsNullable,
Direction = param.IsOutput ? ParameterDirection.Output : ParameterDirection.Input,
Value = myRand.Next(1,255)//should fit all types
};
break;
case SqlDbType.Bit:
sqlParam = new SqlParameter(param.ParamName, param.GetSqlDataType())
{
IsNullable = param.IsNullable,
Direction = param.IsOutput ? ParameterDirection.Output : ParameterDirection.Input,
Value = 1
};
break;
case SqlDbType.Date:
case SqlDbType.DateTime:
case SqlDbType.DateTime2:
case SqlDbType.DateTimeOffset:
case SqlDbType.SmallDateTime:
case SqlDbType.Time:
sqlParam = new SqlParameter(param.ParamName, param.GetSqlDataType())
{
//.........这里部分代码省略.........
示例6: keyToWhere
private static string keyToWhere(IDataStoreKey key, SqlParameterCollection parameters)
{
string where = null;
if (key is CounterDataStoreKey)
{
where = "T1.COUNTER = @CTR";
var par = new SqlParameter();
par.ParameterName = "@CTR";
par.Value = ((CounterDataStoreKey)key).Counter;
parameters.Add(par);
}
else
if (key is NameValueDataStoreKey)
{
var dict = key as NameValueDataStoreKey;
var s = new StringBuilder();
var idx = 0;
foreach (var e in dict)
{
s.AppendFormat(" (T1.[{0}] = @P{1}) AND", e.Key, idx);
var par = new SqlParameter();
par.ParameterName = "@P" + idx.ToString();
par.Value = e.Value;
parameters.Add(par);
idx++;
}
if (s.Length > 0) s.Remove(s.Length - 3, 3);//cut "AND"
where = s.ToString();
}
else
throw new MsSQLDataAccessException(StringConsts.INVALID_KEY_TYPE_ERROR);
return where;
}
示例7: AddParentParameters
private static void AddParentParameters(SqlParameterCollection parameters, WorkItem workItem)
{
if (workItem.Parent != null)
{
parameters.Add(new SqlParameter("@ParentId", workItem.Parent.Id));
parameters.Add(new SqlParameter("@ParentType", (int) workItem.Parent.Type));
}
else
{
parameters.Add(new SqlParameter("@ParentId", DBNull.Value));
parameters.Add(new SqlParameter("@ParentType", DBNull.Value));
}
}
示例8: SerializePromotedProperties
void SerializePromotedProperties(SqlParameterCollection parameters, StringBuilder commandTextBuilder, SaveWorkflowCommand saveWorkflowCommand)
{
const int SqlVariantStartColumn = 1;
const string promotionNameParameter = "@promotionName=";
const string instanceIdParameter = "@instanceId=";
int promotionNumber = 0;
foreach (KeyValuePair<string, Tuple<List<XName>, List<XName>>> promotion in base.Store.Promotions)
{
StringBuilder storedProcInvocationBuilder = new StringBuilder(SqlWorkflowInstanceStoreConstants.DefaultStringBuilderCapacity);
int column = SqlVariantStartColumn;
bool addPromotion = false;
string promotionNameArgument = string.Format(CultureInfo.InvariantCulture, "@promotionName{0}", promotionNumber);
string instanceIdArgument = string.Format(CultureInfo.InvariantCulture, "@instanceId{0}", promotionNumber);
storedProcInvocationBuilder.Append(string.Format(CultureInfo.InvariantCulture, "exec {0}.[InsertPromotedProperties] ", SqlWorkflowInstanceStoreConstants.DefaultSchema));
storedProcInvocationBuilder.Append(promotionNameParameter);
storedProcInvocationBuilder.Append(promotionNameArgument);
storedProcInvocationBuilder.Append(",");
storedProcInvocationBuilder.Append(instanceIdParameter);
storedProcInvocationBuilder.Append(instanceIdArgument);
foreach (XName name in promotion.Value.Item1)
{
InstanceValue propertyValue;
if (saveWorkflowCommand.InstanceData.TryGetValue(name, out propertyValue))
{
if (!SerializationUtilities.IsPropertyTypeSqlVariantCompatible(propertyValue))
{
throw FxTrace.Exception.AsError(new InstancePersistenceException(SR.CannotPromoteAsSqlVariant(propertyValue.Value.GetType().ToString(), name.ToString())));
}
string parameterName = string.Format(CultureInfo.InvariantCulture, "@value{0}=", column);
string argumentName = string.Format(CultureInfo.InvariantCulture, "@value{0}_promotion{1}", column, promotionNumber);
parameters.Add(new SqlParameter() { SqlDbType = SqlDbType.Variant, ParameterName = argumentName, Value = propertyValue.Value ?? DBNull.Value });
storedProcInvocationBuilder.Append(", ");
storedProcInvocationBuilder.Append(parameterName);
storedProcInvocationBuilder.Append(argumentName);
addPromotion = true;
}
column++;
}
column = SqlVariantStartColumn + SqlWorkflowInstanceStoreConstants.MaximumPropertiesPerPromotion;
foreach (XName name in promotion.Value.Item2)
{
InstanceValue propertyValue;
IObjectSerializer serializer = ObjectSerializerFactory.GetObjectSerializer(base.Store.InstanceEncodingOption);
if (saveWorkflowCommand.InstanceData.TryGetValue(name, out propertyValue))
{
string parameterName = string.Format(CultureInfo.InvariantCulture, "@value{0}=", column);
string argumentName = string.Format(CultureInfo.InvariantCulture, "@value{0}_promotion{1}", column, promotionNumber);
SaveWorkflowAsyncResult.AddSerializedProperty(serializer.SerializeValue(propertyValue.Value), parameters, argumentName);
storedProcInvocationBuilder.Append(", ");
storedProcInvocationBuilder.Append(parameterName);
storedProcInvocationBuilder.Append(argumentName);
addPromotion = true;
}
column++;
}
if (addPromotion)
{
parameters.Add(new SqlParameter() { SqlDbType = SqlDbType.NVarChar, Size = 400, ParameterName = promotionNameArgument, Value = promotion.Key });
parameters.Add(new SqlParameter() { SqlDbType = SqlDbType.UniqueIdentifier, ParameterName = instanceIdArgument, Value = base.InstancePersistenceContext.InstanceView.InstanceId });
storedProcInvocationBuilder.Append(";");
commandTextBuilder.AppendLine(storedProcInvocationBuilder.ToString());
promotionNumber++;
}
}
}
示例9: BuildWhereClause
private void BuildWhereClause(SqlParameterCollection cmdParameters, StringBuilder cmdTextBuilder)
{
if (_keyColumns.Count == 0)
throw new InvalidOperationException(_tableName + " doesn't have primary key");
cmdTextBuilder.Append(" WHERE ");
for (int i = 0; i < _keyColumns.Count; i++)
{
if (i > 0)
cmdTextBuilder.Append(" AND ");
cmdTextBuilder.AppendFormat("[{0}] = @{0}", _keyColumns[i].Name);
cmdParameters.Add(CreateParameter(_keyColumns[i]));
}
}
示例10: SetParameters
public override void SetParameters( SqlParameterCollection parameters )
{
parameters.Clear();
parameters.Add( "@id", SqlDbType.Int ).Value = DBNull.Value;
parameters.Add( "@transId", SqlDbType.Int ).Value = DBNull.Value;
parameters.Add( "@onlineId", SqlDbType.Int ).Value = DBNull.Value;
parameters.Add( "@accountId", SqlDbType.Int ).Value = DBNull.Value;
parameters.Add( "@date", SqlDbType.DateTime ).Value = DBNull.Value;
parameters.Add( "@type", SqlDbType.Char, 1 ).Value = DBNull.Value;
parameters.Add( "@number", SqlDbType.VarChar, 20 ).Value = DBNull.Value;
parameters.Add( "@amount", SqlDbType.Decimal ).Value = DBNull.Value;
parameters.Add( "@memo", SqlDbType.NVarChar, 200 ).Value = DBNull.Value;
parameters.Add( "@category", SqlDbType.NVarChar, 20 ).Value = DBNull.Value;
parameters.Add( "@reconciled", SqlDbType.Bit ).Value = DBNull.Value;
parameters.Add( "@machine", SqlDbType.NVarChar, 100 ).Value = DBNull.Value;
parameters.Add( "@now", SqlDbType.DateTime ).Value = DBNull.Value;
}
示例11: SerializePromotedProperties
private void SerializePromotedProperties(SqlParameterCollection parameters, StringBuilder commandTextBuilder, SaveWorkflowCommand saveWorkflowCommand)
{
int num = 0;
foreach (KeyValuePair<string, Tuple<List<XName>, List<XName>>> pair in base.Store.Promotions)
{
StringBuilder builder = new StringBuilder(0x200);
int num2 = 1;
bool flag = false;
string str = string.Format(CultureInfo.InvariantCulture, "@promotionName{0}", new object[] { num });
string str2 = string.Format(CultureInfo.InvariantCulture, "@instanceId{0}", new object[] { num });
builder.Append(string.Format(CultureInfo.InvariantCulture, "exec {0}.[InsertPromotedProperties] ", new object[] { "[System.Activities.DurableInstancing]" }));
builder.Append("@promotionName=");
builder.Append(str);
builder.Append(",");
builder.Append("@instanceId=");
builder.Append(str2);
foreach (XName name in pair.Value.Item1)
{
InstanceValue value2;
if (saveWorkflowCommand.InstanceData.TryGetValue(name, out value2))
{
if (!SerializationUtilities.IsPropertyTypeSqlVariantCompatible(value2))
{
throw FxTrace.Exception.AsError(new InstancePersistenceException(System.Activities.DurableInstancing.SR.CannotPromoteAsSqlVariant(value2.Value.GetType().ToString(), name.ToString())));
}
string str3 = string.Format(CultureInfo.InvariantCulture, "@value{0}=", new object[] { num2 });
string str4 = string.Format(CultureInfo.InvariantCulture, "@value{0}_promotion{1}", new object[] { num2, num });
SqlParameter parameter = new SqlParameter {
SqlDbType = SqlDbType.Variant,
ParameterName = str4,
Value = value2.Value ?? DBNull.Value
};
parameters.Add(parameter);
builder.Append(", ");
builder.Append(str3);
builder.Append(str4);
flag = true;
}
num2++;
}
num2 = 0x21;
foreach (XName name2 in pair.Value.Item2)
{
InstanceValue value3;
IObjectSerializer objectSerializer = ObjectSerializerFactory.GetObjectSerializer(base.Store.InstanceEncodingOption);
if (saveWorkflowCommand.InstanceData.TryGetValue(name2, out value3))
{
string str5 = string.Format(CultureInfo.InvariantCulture, "@value{0}=", new object[] { num2 });
string parameterName = string.Format(CultureInfo.InvariantCulture, "@value{0}_promotion{1}", new object[] { num2, num });
AddSerializedProperty(objectSerializer.SerializeValue(value3.Value), parameters, parameterName);
builder.Append(", ");
builder.Append(str5);
builder.Append(parameterName);
flag = true;
}
num2++;
}
if (flag)
{
SqlParameter parameter2 = new SqlParameter {
SqlDbType = SqlDbType.NVarChar,
Size = 400,
ParameterName = str,
Value = pair.Key
};
parameters.Add(parameter2);
SqlParameter parameter3 = new SqlParameter {
SqlDbType = SqlDbType.UniqueIdentifier,
ParameterName = str2,
Value = base.InstancePersistenceContext.InstanceView.InstanceId
};
parameters.Add(parameter3);
builder.Append(";");
commandTextBuilder.AppendLine(builder.ToString());
num++;
}
}
}
示例12: ExtractServiceDeploymentInformation
private void ExtractServiceDeploymentInformation(SaveWorkflowCommand saveWorkflowCommand, StringBuilder commandTextBuilder, SqlParameterCollection parameters)
{
InstanceValue value2;
string localName = null;
string namespaceName = null;
string str3 = null;
string str4 = null;
string str5 = null;
if (saveWorkflowCommand.InstanceMetadataChanges.TryGetValue(PersistenceMetadataNamespace.ActivationType, out value2))
{
if (!PersistenceMetadataNamespace.ActivationTypes.WAS.Equals(value2.Value))
{
throw FxTrace.Exception.AsError(new InstancePersistenceCommandException(System.Activities.DurableInstancing.SR.NonWASActivationNotSupported));
}
if (saveWorkflowCommand.InstanceMetadataChanges.TryGetValue(WorkflowServiceNamespace.Service, out value2))
{
localName = ((XName) value2.Value).LocalName;
namespaceName = ((XName) value2.Value).Namespace.NamespaceName;
}
if (saveWorkflowCommand.InstanceMetadataChanges.TryGetValue(WorkflowServiceNamespace.SiteName, out value2))
{
str3 = (string) value2.Value;
}
if (saveWorkflowCommand.InstanceMetadataChanges.TryGetValue(WorkflowServiceNamespace.RelativeApplicationPath, out value2))
{
str4 = (string) value2.Value;
}
if (saveWorkflowCommand.InstanceMetadataChanges.TryGetValue(WorkflowServiceNamespace.RelativeServicePath, out value2))
{
str5 = (string) value2.Value;
}
object[] args = new object[] { localName ?? string.Empty, namespaceName ?? string.Empty, str3 ?? string.Empty, str4 ?? string.Empty, str5 ?? string.Empty };
byte[] bytes = Encoding.Unicode.GetBytes(string.Format(CultureInfo.InvariantCulture, "{0}#{1}#{2}#{3}#{4}", args));
this.serviceDeploymentHash = new Guid(HashHelper.ComputeHash(bytes));
this.GetServiceDeploymentId();
}
if ((this.serviceDeploymentHash != Guid.Empty) && (this.serviceDeploymentId == 0L))
{
commandTextBuilder.AppendLine("declare @serviceDeploymentId bigint");
commandTextBuilder.AppendLine(string.Format(CultureInfo.InvariantCulture, "exec {0}.[CreateServiceDeployment] {1} ;", new object[] { "[System.Activities.DurableInstancing]", "@serviceDeploymentHash, @siteName, @relativeServicePath, @relativeApplicationPath,\r\n @serviceName, @serviceNamespace, @serviceDeploymentId output" }));
SqlParameter parameter = new SqlParameter {
ParameterName = "@serviceDeploymentHash",
SqlDbType = SqlDbType.UniqueIdentifier,
Value = this.serviceDeploymentHash
};
parameters.Add(parameter);
SqlParameter parameter2 = new SqlParameter {
ParameterName = "@serviceName",
Size = -1,
SqlDbType = SqlDbType.NVarChar,
Value = localName ?? DBNull.Value
};
parameters.Add(parameter2);
SqlParameter parameter3 = new SqlParameter {
ParameterName = "@serviceNamespace",
Size = -1,
SqlDbType = SqlDbType.NVarChar,
Value = namespaceName ?? DBNull.Value
};
parameters.Add(parameter3);
SqlParameter parameter4 = new SqlParameter {
ParameterName = "@siteName",
Size = -1,
SqlDbType = SqlDbType.NVarChar,
Value = str3 ?? DBNull.Value
};
parameters.Add(parameter4);
SqlParameter parameter5 = new SqlParameter {
ParameterName = "@relativeServicePath",
Size = -1,
SqlDbType = SqlDbType.NVarChar,
Value = str5 ?? DBNull.Value
};
parameters.Add(parameter5);
SqlParameter parameter6 = new SqlParameter {
ParameterName = "@relativeApplicationPath",
Size = -1,
SqlDbType = SqlDbType.NVarChar,
Value = str4 ?? DBNull.Value
};
parameters.Add(parameter6);
}
else
{
SqlParameter parameter7 = new SqlParameter {
ParameterName = "@serviceDeploymentId",
SqlDbType = SqlDbType.BigInt,
Value = (this.serviceDeploymentId != 0L) ? ((object) this.serviceDeploymentId) : ((object) DBNull.Value)
};
parameters.Add(parameter7);
}
}
示例13: SerializeAssociatedData
private void SerializeAssociatedData(SqlParameterCollection parameters, SaveWorkflowCommand saveWorkflowCommand, StringBuilder commandTextBuilder)
{
if (saveWorkflowCommand.CompleteInstance && (base.Store.InstanceCompletionAction == InstanceCompletionAction.DeleteAll))
{
SqlParameter parameter = new SqlParameter {
ParameterName = "@keysToAssociate",
SqlDbType = SqlDbType.Xml,
Value = DBNull.Value
};
parameters.Add(parameter);
SqlParameter parameter2 = new SqlParameter {
ParameterName = "@singleKeyId",
SqlDbType = SqlDbType.UniqueIdentifier,
Value = DBNull.Value
};
parameters.Add(parameter2);
SqlParameter parameter3 = new SqlParameter {
ParameterName = "@keysToComplete",
SqlDbType = SqlDbType.Xml,
Value = DBNull.Value
};
parameters.Add(parameter3);
SqlParameter parameter4 = new SqlParameter {
ParameterName = "@keysToFree",
SqlDbType = SqlDbType.Xml,
Value = DBNull.Value
};
parameters.Add(parameter4);
SqlParameter parameter5 = new SqlParameter {
ParameterName = "@concatenatedKeyProperties",
SqlDbType = SqlDbType.VarBinary,
Value = DBNull.Value
};
parameters.Add(parameter5);
SqlParameter parameter6 = new SqlParameter {
ParameterName = "@primitiveDataProperties",
SqlDbType = SqlDbType.VarBinary,
Value = DBNull.Value
};
parameters.Add(parameter6);
SqlParameter parameter7 = new SqlParameter {
ParameterName = "@complexDataProperties",
SqlDbType = SqlDbType.VarBinary,
Value = DBNull.Value
};
parameters.Add(parameter7);
SqlParameter parameter8 = new SqlParameter {
ParameterName = "@writeOnlyPrimitiveDataProperties",
SqlDbType = SqlDbType.VarBinary,
Value = DBNull.Value
};
parameters.Add(parameter8);
SqlParameter parameter9 = new SqlParameter {
ParameterName = "@writeOnlyComplexDataProperties",
SqlDbType = SqlDbType.VarBinary,
Value = DBNull.Value
};
parameters.Add(parameter9);
SqlParameter parameter10 = new SqlParameter {
ParameterName = "@metadataProperties",
SqlDbType = SqlDbType.VarBinary,
Value = DBNull.Value
};
parameters.Add(parameter10);
SqlParameter parameter11 = new SqlParameter {
ParameterName = "@metadataIsConsistent",
SqlDbType = SqlDbType.Bit,
Value = DBNull.Value
};
parameters.Add(parameter11);
SqlParameter parameter12 = new SqlParameter {
ParameterName = "@encodingOption",
SqlDbType = SqlDbType.TinyInt,
Value = DBNull.Value
};
parameters.Add(parameter12);
SqlParameter parameter13 = new SqlParameter {
ParameterName = "@lastMachineRunOn",
SqlDbType = SqlDbType.NVarChar,
Value = DBNull.Value
};
parameters.Add(parameter13);
SqlParameter parameter14 = new SqlParameter {
ParameterName = "@executionStatus",
SqlDbType = SqlDbType.NVarChar,
Value = DBNull.Value
};
parameters.Add(parameter14);
SqlParameter parameter15 = new SqlParameter {
ParameterName = "@blockingBookmarks",
SqlDbType = SqlDbType.NVarChar,
Value = DBNull.Value
};
parameters.Add(parameter15);
}
else
{
List<CorrelationKey> correlationKeys = CorrelationKey.BuildKeyList(saveWorkflowCommand.InstanceKeysToAssociate, base.Store.InstanceEncodingOption);
List<CorrelationKey> list2 = CorrelationKey.BuildKeyList(saveWorkflowCommand.InstanceKeysToComplete);
List<CorrelationKey> list3 = CorrelationKey.BuildKeyList(saveWorkflowCommand.InstanceKeysToFree);
//.........这里部分代码省略.........
示例14: ExtractServiceDeploymentInformation
void ExtractServiceDeploymentInformation(SaveWorkflowCommand saveWorkflowCommand, StringBuilder commandTextBuilder, SqlParameterCollection parameters)
{
InstanceValue instanceValue;
//Extract the activation parameters
string serviceName = null;
string serviceNamespace = null;
string site = null;
string relativeApplicationPath = null;
string relativeServicePath = null;
if (saveWorkflowCommand.InstanceMetadataChanges.TryGetValue(PersistenceMetadataNamespace.ActivationType, out instanceValue))
{
if (PersistenceMetadataNamespace.ActivationTypes.WAS.Equals(instanceValue.Value))
{
if (saveWorkflowCommand.InstanceMetadataChanges.TryGetValue(WorkflowServiceNamespace.Service, out instanceValue))
{
serviceName = ((XName)instanceValue.Value).LocalName;
serviceNamespace = ((XName)instanceValue.Value).Namespace.NamespaceName;
}
if (saveWorkflowCommand.InstanceMetadataChanges.TryGetValue(WorkflowServiceNamespace.SiteName, out instanceValue))
{
site = (string)instanceValue.Value;
}
if (saveWorkflowCommand.InstanceMetadataChanges.TryGetValue(WorkflowServiceNamespace.RelativeApplicationPath, out instanceValue))
{
relativeApplicationPath = (string)instanceValue.Value;
}
if (saveWorkflowCommand.InstanceMetadataChanges.TryGetValue(WorkflowServiceNamespace.RelativeServicePath, out instanceValue))
{
relativeServicePath = (string)instanceValue.Value;
}
byte[] serviceDeploymentHashBuffer = Encoding.Unicode.GetBytes(string.Format(CultureInfo.InvariantCulture, "{0}#{1}#{2}#{3}#{4}",
serviceName ?? string.Empty, serviceNamespace ?? string.Empty, site ?? string.Empty, relativeApplicationPath ?? string.Empty, relativeServicePath ?? string.Empty));
this.serviceDeploymentHash = new Guid(HashHelper.ComputeHash(serviceDeploymentHashBuffer));
//Get the service id has been seen before, get it from the cache
GetServiceDeploymentId();
}
else
{
throw FxTrace.Exception.AsError(new InstancePersistenceCommandException(SR.NonWASActivationNotSupported));
}
}
if ((this.serviceDeploymentHash != Guid.Empty) && (this.serviceDeploymentId == 0))
{
//This is the first time we see this service deployment so we need to create a new entry for it before creating the instance
commandTextBuilder.AppendLine("declare @serviceDeploymentId bigint");
commandTextBuilder.AppendLine(string.Format(CultureInfo.InvariantCulture, "exec {0}.[CreateServiceDeployment] {1} ;",
SqlWorkflowInstanceStoreConstants.DefaultSchema, SaveWorkflowAsyncResult.createServiceDeploymentStoredProcedureParameters));
parameters.Add(new SqlParameter { ParameterName = "@serviceDeploymentHash", SqlDbType = SqlDbType.UniqueIdentifier, Value = this.serviceDeploymentHash });
parameters.Add(new SqlParameter { ParameterName = "@serviceName", Size = -1, SqlDbType = SqlDbType.NVarChar, Value = serviceName ?? (object)DBNull.Value });
parameters.Add(new SqlParameter { ParameterName = "@serviceNamespace", Size = -1, SqlDbType = SqlDbType.NVarChar, Value = serviceNamespace ?? (object)DBNull.Value });
parameters.Add(new SqlParameter { ParameterName = "@siteName", Size = -1, SqlDbType = SqlDbType.NVarChar, Value = site ?? (object)DBNull.Value });
parameters.Add(new SqlParameter { ParameterName = "@relativeServicePath", Size = -1, SqlDbType = SqlDbType.NVarChar, Value = relativeServicePath ?? (object)DBNull.Value });
parameters.Add(new SqlParameter { ParameterName = "@relativeApplicationPath", Size = -1, SqlDbType = SqlDbType.NVarChar, Value = relativeApplicationPath ?? (object)DBNull.Value });
}
else
{
parameters.Add(new SqlParameter { ParameterName = "@serviceDeploymentId", SqlDbType = SqlDbType.BigInt, Value = (this.serviceDeploymentId != 0) ? (object)this.serviceDeploymentId : (object)DBNull.Value });
}
}
示例15: SetParameters
public override void SetParameters( SqlParameterCollection parameters )
{
parameters.Clear();
parameters.Add( "@id", SqlDbType.Int ).Value = DBNull.Value;
parameters.Add( "@name", SqlDbType.NVarChar, 50 ).Value = DBNull.Value;
parameters.Add( "@type", SqlDbType.VarChar, 20 ).Value = DBNull.Value;
parameters.Add( "@source", SqlDbType.VarChar, 100 ).Value = DBNull.Value;
parameters.Add( "@startingBalance", SqlDbType.Decimal ).Value = DBNull.Value;
parameters.Add( "@startingDate", SqlDbType.DateTime ).Value = DBNull.Value;
parameters.Add( "@machine", SqlDbType.NVarChar, 100 ).Value = DBNull.Value;
parameters.Add( "@now", SqlDbType.DateTime ).Value = DBNull.Value;
}