private void SaveParameter() { ParameterInfo parameter; ParameterInfo[] parameterInfos = this.methodInfo.GetParameters(); ParameterWrapContext parameterWrap; for (int i = 0; i < parameterInfos.Length; i++) { parameter = parameterInfos[i]; parameterWrap = ParameterWrapContext.GetContext(this, parameter); ParameterCache.Add(parameterWrap); } ParameterCache.ForEach(x => { x.CreateBind(); }); }
/// <summary> /// Create or retrieves from cache a parameter using the classes supplied parameter prefix. /// The name is autogenerated. Use the ParameterName property of the returned param in your queries. /// </summary> /// <param name="value"></param> /// <returns></returns> public virtual IDataParameter CreateParameter <TValue>(TValue value) { ///if TValue is System.Object we need to expand it to generate the correct parameter type if (typeof(TValue) == typeof(object) && value.GetType() != typeof(object)) { return(CreateParameterFromObject(value)); } object key = value; if (Equals(null, value)) { key = new NullValue <TValue>(); } if (ParameterCache.ContainsKey(key)) { return(ParameterCache[key]); } IDataParameter p; if (value is IGeometry) { p = Provider.DbUtility.CreateParameter(string.Format("iparam{0}", ParameterCache.Count), ((IGeometry)value).AsBinary(), ParameterDirection.Input); } else { p = Provider.DbUtility.CreateParameter(string.Format("iparam{0}", ParameterCache.Count), value, ParameterDirection.Input); } ParameterCache.Add(key, p); return(p); }