本文整理汇总了C#中System.Web.UI.WebControls.ParameterCollection.GetValues方法的典型用法代码示例。如果您正苦于以下问题:C# ParameterCollection.GetValues方法的具体用法?C# ParameterCollection.GetValues怎么用?C# ParameterCollection.GetValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.UI.WebControls.ParameterCollection
的用法示例。
在下文中一共展示了ParameterCollection.GetValues方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitializeParameters
/// <devdoc>
/// Initializes a DbCommand with parameters from a ParameterCollection.
/// The exclusion list contains parameter names that should not be added
/// to the command's parameter collection.
/// </devdoc>
private void InitializeParameters(DbCommand command, ParameterCollection parameters, IDictionary exclusionList) {
Debug.Assert(command != null);
Debug.Assert(parameters != null);
string parameterPrefix = ParameterPrefix;
IDictionary caseInsensitiveExclusionList = null;
if (exclusionList != null) {
caseInsensitiveExclusionList = new ListDictionary(StringComparer.OrdinalIgnoreCase);
foreach (DictionaryEntry de in exclusionList) {
caseInsensitiveExclusionList.Add(de.Key, de.Value);
}
}
IOrderedDictionary values = parameters.GetValues(_context, _owner);
for (int i = 0; i < parameters.Count; i++) {
Parameter parameter = parameters[i];
if ((caseInsensitiveExclusionList == null) || (!caseInsensitiveExclusionList.Contains(parameter.Name))) {
DbParameter dbParameter = _owner.CreateParameter(parameterPrefix + parameter.Name, values[i]);
dbParameter.Direction = parameter.Direction;
dbParameter.Size = parameter.Size;
if (parameter.DbType != DbType.Object || (parameter.Type != TypeCode.Empty && parameter.Type != TypeCode.DBNull)) {
SqlParameter sqlParameter = dbParameter as SqlParameter;
if (sqlParameter == null) {
dbParameter.DbType = parameter.GetDatabaseType();
}
else {
// In Whidbey, the DbType Date and Time members mapped to SqlDbType.DateTime since there
// were no SqlDbType equivalents. SqlDbType has since been modified to include the new
// Katmai types, including Date and Time. For backwards compatability SqlParameter's DbType
// setter doesn't support Date and Time, so the SqlDbType property should be used instead.
// Other new SqlServer 2008 types (DateTime2, DateTimeOffset) can be set using DbType.
DbType dbType = parameter.GetDatabaseType();
switch (dbType) {
case DbType.Time:
sqlParameter.SqlDbType = SqlDbType.Time;
break;
case DbType.Date:
sqlParameter.SqlDbType = SqlDbType.Date;
break;
default:
dbParameter.DbType = parameter.GetDatabaseType();
break;
}
}
}
command.Parameters.Add(dbParameter);
}
}
}
示例2: InitializeParameters
void InitializeParameters (DbCommand command, ParameterCollection parameters, IDictionary values, IDictionary oldValues, bool parametersMayMatchOldValues)
{
IOrderedDictionary parameterValues = parameters.GetValues (context, owner);
foreach (string parameterName in parameterValues.Keys) {
Parameter p = parameters [parameterName];
object value = FindValueByName (parameterName, values, false);
string valueName = parameterName;
if (value == null)
value = FindValueByName (parameterName, oldValues, true);
if (value == null && parametersMayMatchOldValues) {
value = FindValueByName (parameterName, oldValues, false);
valueName = FormatOldParameter (parameterName);
}
if (value != null) {
object dbValue = p.ConvertValue (value);
DbParameter newParameter = CreateDbParameter (valueName, dbValue, p.Direction, p.Size);
if (!command.Parameters.Contains (newParameter.ParameterName)) {
command.Parameters.Add (newParameter);
}
}
else {
command.Parameters.Add (CreateDbParameter (p.Name, parameterValues [parameterName], p.Direction, p.Size));
}
}
if (values != null) {
foreach (DictionaryEntry de in values)
if (!command.Parameters.Contains (ParameterPrefix + (string) de.Key))
command.Parameters.Add (CreateDbParameter ((string) de.Key, de.Value));
}
if (oldValues != null) {
foreach (DictionaryEntry de in oldValues)
if (!command.Parameters.Contains (ParameterPrefix + FormatOldParameter ((string) de.Key)))
command.Parameters.Add (CreateDbParameter (FormatOldParameter ((string) de.Key), de.Value));
}
}
示例3: OnOkButtonClick
private void OnOkButtonClick(object sender, EventArgs e)
{
ParameterCollection parameters = new ParameterCollection();
foreach (ParameterItem item in this._parameterItems)
{
if (item.Parameter.DbType == DbType.Object)
{
parameters.Add(new Parameter(item.Parameter.Name, item.Parameter.Type, item.Parameter.DefaultValue));
}
else
{
parameters.Add(new Parameter(item.Parameter.Name, item.Parameter.DbType, item.Parameter.DefaultValue));
}
}
try
{
parameters.GetValues(null, null);
}
catch (Exception exception)
{
UIServiceHelper.ShowError(base.ServiceProvider, exception, System.Design.SR.GetString("SqlDataSourceParameterValueEditorForm_InvalidParameter"));
return;
}
base.DialogResult = DialogResult.OK;
base.Close();
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:26,代码来源:SqlDataSourceParameterValueEditorForm.cs
示例4: MergeParameterValues
/// <summary>
/// Merge the current data item fields with view parameter default values
/// </summary>
/// <param name="viewParams">default parameters</param>
/// <param name="values">new parameters for update and insert</param>
/// <param name="oldValues">old parameters for update and delete</param>
/// <param name="allwaysAddNewValues">true for insert, as current item is
/// irrelevant for insert</param>
/// <returns>merged values</returns>
IOrderedDictionary MergeParameterValues (ParameterCollection viewParams, IDictionary values, IDictionary oldValues)
{
IOrderedDictionary parametersValues = viewParams.GetValues (context, owner);
OrderedDictionary mergedValues = new OrderedDictionary (StringComparer.InvariantCultureIgnoreCase);
foreach (string parameterName in parametersValues.Keys) {
mergedValues [parameterName] = parametersValues [parameterName];
if (oldValues != null) {
object value = FindValueByName (parameterName, oldValues, true);
if (value != null) {
object dataValue = viewParams [parameterName].ConvertValue (value);
mergedValues [parameterName] = dataValue;
}
}
if (values != null) {
object value = FindValueByName (parameterName, values, false);
if (value != null) {
object dataValue = viewParams [parameterName].ConvertValue (value);
mergedValues [parameterName] = dataValue;
}
}
}
if (values != null) {
foreach (DictionaryEntry de in values)
if (FindValueByName ((string) de.Key, mergedValues, false) == null)
mergedValues [de.Key] = de.Value;
}
if (oldValues != null) {
foreach (DictionaryEntry de in oldValues) {
string oldValueKey = FormatOldParameter ((string) de.Key);
if (FindValueByName (oldValueKey, mergedValues, false) == null)
mergedValues [oldValueKey] = de.Value;
}
}
return mergedValues;
}
示例5: CreateObjectParametersFromParameterCollection
private ObjectParameter[] CreateObjectParametersFromParameterCollection(ParameterCollection paramColl)
{
IOrderedDictionary paramValues = paramColl.GetValues(HttpContext, this);
List<ObjectParameter> objectParameters = new List<ObjectParameter>();
foreach (Parameter parameter in paramColl)
{
if (!string.IsNullOrEmpty(parameter.Name))
{
WebControlParameterProxy wcParam = new WebControlParameterProxy(parameter, paramColl, this);
if (wcParam.Value != null)
{
objectParameters.Add(new ObjectParameter(wcParam.Name, wcParam.Value));
}
else
{
objectParameters.Add(new ObjectParameter(wcParam.Name, wcParam.ClrType));
}
}
}
return objectParameters.ToArray();
}
示例6: InitializeParameters
private void InitializeParameters(DbCommand command, ParameterCollection parameters, IDictionary exclusionList)
{
string parameterPrefix = this.ParameterPrefix;
IDictionary dictionary = null;
if (exclusionList != null)
{
dictionary = new ListDictionary(StringComparer.OrdinalIgnoreCase);
foreach (DictionaryEntry entry in exclusionList)
{
dictionary.Add(entry.Key, entry.Value);
}
}
IOrderedDictionary values = parameters.GetValues(this._context, this._owner);
for (int i = 0; i < parameters.Count; i++)
{
Parameter parameter = parameters[i];
if ((dictionary != null) && dictionary.Contains(parameter.Name))
{
continue;
}
DbParameter parameter2 = this._owner.CreateParameter(parameterPrefix + parameter.Name, values[i]);
parameter2.Direction = parameter.Direction;
parameter2.Size = parameter.Size;
if ((parameter.DbType != DbType.Object) || ((parameter.Type != TypeCode.Empty) && (parameter.Type != TypeCode.DBNull)))
{
SqlParameter parameter3 = parameter2 as SqlParameter;
if (parameter3 == null)
{
parameter2.DbType = parameter.GetDatabaseType();
}
else
{
DbType databaseType = parameter.GetDatabaseType();
if (databaseType != DbType.Date)
{
if (databaseType != DbType.Time)
{
goto Label_0143;
}
parameter3.SqlDbType = SqlDbType.Time;
}
else
{
parameter3.SqlDbType = SqlDbType.Date;
}
}
}
goto Label_0151;
Label_0143:
parameter2.DbType = parameter.GetDatabaseType();
Label_0151:
command.Parameters.Add(parameter2);
}
}
示例7: TrimToParameters
protected virtual IDictionary TrimToParameters(ParameterCollection parameters, IDictionary values)
{
if (null == this._dataSource)
{
throw new InvalidOperationException("DataSource is null");
}
if (!(this._dataSource is Control))
{
throw new InvalidOperationException("DataSource is not a Control");
}
IDictionary result;
if (null == values)
{
result = null;
}
else
{
Dictionary<string, object> prepared = new Dictionary<string, object>();
IOrderedDictionary paramValues = parameters.GetValues(this.Context, this._dataSource as Control);
if (null != parameters)
{
foreach (Parameter param in parameters)
{
prepared.Add(param.Name, paramValues[param.Name]);
}
}
if (null != values)
{
foreach (DictionaryEntry entry in values)
{
if (prepared.ContainsKey(entry.Key.ToString()))
{
prepared[entry.Key.ToString()] = entry.Value;
}
}
}
result = prepared;
}
return result;
}
示例8: BuildSelectCommand
internal DbCommand BuildSelectCommand(DbProviderFactory factory, DbConnection connection, string commandText, ParameterCollection parameters, SqlDataSourceCommandType commandType)
{
DbCommand command = CreateCommand(factory, commandText, connection);
if ((parameters != null) && (parameters.Count > 0))
{
IOrderedDictionary values = parameters.GetValues(null, null);
string parameterPrefix = GetParameterPrefix(factory);
for (int i = 0; i < parameters.Count; i++)
{
Parameter parameter = parameters[i];
DbParameter parameter2 = CreateParameter(factory);
parameter2.ParameterName = parameterPrefix + parameter.Name;
if (parameter.DbType != DbType.Object)
{
SqlParameter parameter3 = parameter2 as SqlParameter;
if (parameter3 == null)
{
parameter2.DbType = parameter.DbType;
}
else if (parameter.DbType == DbType.Date)
{
parameter3.SqlDbType = SqlDbType.Date;
}
else if (parameter.DbType == DbType.Time)
{
parameter3.SqlDbType = SqlDbType.Time;
}
else
{
parameter2.DbType = parameter.DbType;
}
}
else
{
if ((parameter.Type != TypeCode.Empty) && (parameter.Type != TypeCode.DBNull))
{
parameter2.DbType = parameter.GetDatabaseType();
}
if ((parameter.Type == TypeCode.Empty) && ProviderRequiresDbTypeSet(factory))
{
parameter2.DbType = DbType.Object;
}
}
parameter2.Value = values[i];
if (parameter2.Value == null)
{
parameter2.Value = DBNull.Value;
}
if (Parameter.ConvertDbTypeToTypeCode(parameter2.DbType) == TypeCode.String)
{
if ((parameter2.Value is string) && (parameter2.Value != null))
{
parameter2.Size = ((string) parameter2.Value).Length;
}
else
{
parameter2.Size = 1;
}
}
command.Parameters.Add(parameter2);
}
}
command.CommandType = GetCommandType(commandType);
return command;
}
示例9: ExtractCommandParametersToDataRow
private void ExtractCommandParametersToDataRow(ParameterCollection parameters, DataRow row)
{
IOrderedDictionary paramsValues = parameters.GetValues(context, owner);
for (int i = 0; i < parameters.Count; i++)
{
if (paramsValues[i] != null)
{
row[parameters[i].Name] = paramsValues[i];
}
}
}