本文整理汇总了C#中System.Data.SqlClient.SqlParameterCollection.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# SqlParameterCollection.Contains方法的具体用法?C# SqlParameterCollection.Contains怎么用?C# SqlParameterCollection.Contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.SqlClient.SqlParameterCollection
的用法示例。
在下文中一共展示了SqlParameterCollection.Contains方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetParameter
static void SetParameter(IEdmFunction func, JObject parameterValues, IEdmType edmType, SqlParameterCollection pars)
{
if (parameterValues == null)
return;
JToken token = null;
Type colType = null;
foreach (var p in func.Parameters)
{
if (parameterValues.TryGetValue(p.Name, out token))
{
if (p.Type.Definition.TypeKind == EdmTypeKind.Complex)
{
DataTable dt = new DataTable();
var c = p.Type.AsComplex();
foreach (var item in c.StructuralProperties())
{
dt.Columns.Add(item.Name, item.Type.PrimitiveKind().ToClrType());
}
foreach (var item in token)
{
DataRow dr = dt.NewRow();
foreach (JProperty col in item)
{
if (!dt.Columns.Contains(col.Name))
continue;
colType = dt.Columns[col.Name].DataType;
if (colType == typeof(Boolean))
{
dr.SetField(col.Name, col.Value.ToString() == "0" ? false : true);
}
else
dr.SetField(col.Name, col.Value.ToString().ChangeType(colType));
}
dt.Rows.Add(dr);
}
pars.AddWithValue(p.Name, dt);
}
else
{
if (string.IsNullOrEmpty(token.ToString()))
pars.AddWithValue(p.Name, DBNull.Value);
else
pars.AddWithValue(p.Name, token.ToString().ChangeType(p.Type.PrimitiveKind()));
}
}
}
if (edmType.TypeKind == EdmTypeKind.Entity)
{
foreach (var outp in (edmType as EdmEntityType).Properties())
{
if (outp.Name == "$Results")
continue;
if (pars.Contains(outp.Name))
{
pars[outp.Name].Direction = ParameterDirection.Output;
}
else
{
pars.AddWithValue(outp.Name, DBNull.Value);
}
}
}
}
示例2: ThreadSafeDetermineParms
private static SqlParameterCollection ThreadSafeDetermineParms(string command, SqlParameterCollection parms, drGeneric_String_String globalInputs)
{
if (NonUpdatedProcedures.Instance.IsProcedureUpdated(command))
{
//******* 20121029 DHB Start code changes.
//if (AppSettings.GlobalInputs == null)
//{
// throw new ApplicationException("The procedure " + command + " has been flagged as being updated to accept GlobalInputs but the call to FetchDataTable did not include GlobalInputs. Please modify your call. Contact Wesley or Michael for further info.");
//}
//******* 20121029 DHB Stop code changes.
if (!parms.Contains("GlobalInputs"))
{
SqlParameter param = new SqlParameter("GlobalInputs", SqlDbType.Structured);
param.Value = globalInputs.ToDataTable();
parms.Add(param);
}
return parms;
}
return parms;
}