当前位置: 首页>>代码示例>>C#>>正文


C# IQuery.SetParameter方法代码示例

本文整理汇总了C#中IQuery.SetParameter方法的典型用法代码示例。如果您正苦于以下问题:C# IQuery.SetParameter方法的具体用法?C# IQuery.SetParameter怎么用?C# IQuery.SetParameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IQuery的用法示例。


在下文中一共展示了IQuery.SetParameter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetParameters

 private void SetParameters(IQuery query)
 {
     foreach (var parameter in NamedParameters)
     {
         query.SetParameter(parameter.Name, parameter.Value);
     }
 }
开发者ID:nkmajeti,项目名称:nhibernate,代码行数:7,代码来源:CommandData.cs

示例2: SetQueryParameters

		protected override void SetQueryParameters(IQuery query)
		{
			int i = 0;
			
			foreach (object param in parameters)
			{
				query.SetParameter(i++, param);
			}
		}
开发者ID:ralescano,项目名称:castle,代码行数:9,代码来源:ARPaginableSimpleQuery.cs

示例3: SetQueryParameters

		protected override void SetQueryParameters(IQuery query)
		{
			var i = 0;
			
			foreach (var param in parameters)
			{
				query.SetParameter(i++, param);
			}
		}
开发者ID:rambo-returns,项目名称:MonoRail,代码行数:9,代码来源:ARPaginableSimpleQuery.cs

示例4: OnEvent

 public void OnEvent(IQuery query)
 {
     switch (ctorType)
     {
         case CtorType.PositionVal:
             query.SetParameter(position, val);
             break;
         case CtorType.PositionValType:
             query.SetParameter(position, val, type);
             break;
         case CtorType.NameVal:
             query.SetParameter(name, val);
             break;
         case CtorType.NameValType:
             query.SetParameter(name, val, type);
             break;
         default:
             throw new ShardedSessionException(
                 "Unknown ctor type in SetParameterEvent: " + ctorType);
     }
 }
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:21,代码来源:SetParameterEvent.cs

示例5: ApplyNamedParameterToQuery

        /// <summary>
        /// Apply the given name parameter to the given Query object.
        /// </summary>
        /// <param name="queryObject">The query object.</param>
        /// <param name="paramName">Name of the parameter</param>
        /// <param name="value">The value of the parameter</param>
        /// <param name="type">The NHibernate type of the parameter (or <code>null</code> if none specified)</param>
        public virtual void ApplyNamedParameterToQuery(IQuery queryObject, string paramName, object value, IType type)
        {

            if (value is ICollection)
            {
                if (type != null)
                {
                    queryObject.SetParameterList(paramName, (ICollection)value, type);
                }
                else
                {
                    queryObject.SetParameterList(paramName, (ICollection)value);
                }
            }
            else if (value is Object[])
            {

                //TODO investigate support for this conversion.
                if (type != null)
                {
                    queryObject.SetParameterList(paramName, (Object[])value, type);
                }
                else
                {
                    queryObject.SetParameterList(paramName, (Object[])value);
                }
            }
            else
            {
                if (type != null)
                {
                    queryObject.SetParameter(paramName, value, type);
                }
                else
                {
                    queryObject.SetParameter(paramName, value);
                }
            }
        }
开发者ID:fuadm,项目名称:spring-net,代码行数:46,代码来源:HibernateAccessor.cs

示例6: SetQueryProperties

		/// <summary>
		/// Fill all <see cref="IQuery"/> properties.
		/// </summary>
		/// <param name="q">The <see cref="IQuery"/>.</param>
		/// <remarks>
		/// Query properties are overriden/merged.
		/// </remarks>
		protected void SetQueryProperties(IQuery q)
		{
			q.SetMaxResults(selection.MaxRows)
				.SetFirstResult(selection.FirstRow)
				.SetCacheable(cacheable)
				.SetReadOnly(readOnly)
				.SetTimeout(selection.Timeout)
				.SetFlushMode(flushMode)
				.SetFetchSize(selection.FetchSize);
			if (!string.IsNullOrEmpty(comment))
				q.SetComment(comment);
			if (!string.IsNullOrEmpty(cacheRegion))
				q.SetCacheRegion(cacheRegion);
			if (resultTransformer != null)
				q.SetResultTransformer(resultTransformer);
			if (cacheMode.HasValue)
				q.SetCacheMode(cacheMode.Value);
			foreach (KeyValuePair<string, LockMode> mode in lockModes)
				q.SetLockMode(mode.Key, mode.Value);

			// Set AbstractQueryImpl property before set parameters
			AbstractQueryImpl aqi = q as AbstractQueryImpl;
			if (aqi != null)
				aqi.SetIgnoreUknownNamedParameters(shouldIgnoredUnknownNamedParameters);

			// Even if the probably that somebody use a mixed technique to set parameters 
			// (from POCO using SetProperties and using named parameter setters) here is a possible
			// difference between IQuery and DetachedQuery behaviour.
			// In IQuery we don't know who override a param value; in DetachedQuery the direct use of 
			// a named parameter setter override the param value set by SetProperties(POCO)
			foreach (object obj in optionalUntypeParams)
				q.SetProperties(obj);

			// Set untyped positional parameters
			foreach (KeyValuePair<int, object> pup in posUntypeParams)
				q.SetParameter(pup.Key, pup.Value);

			// Set untyped named parameters
			foreach (KeyValuePair<string, object> nup in namedUntypeParams)
				q.SetParameter(nup.Key, nup.Value);

			// Set untyped named parameters list
			foreach (KeyValuePair<string, ICollection> nulp in namedUntypeListParams)
				q.SetParameterList(nulp.Key, nulp.Value);

			// Set typed positional parameters
			foreach (KeyValuePair<int, TypedValue> pp in posParams)
				q.SetParameter(pp.Key, pp.Value.Value, pp.Value.Type);

			// Set typed named parameters
			foreach (KeyValuePair<string, TypedValue> np in namedParams)
				q.SetParameter(np.Key, np.Value.Value, np.Value.Type);

			// Set typed named parameters List
			foreach (KeyValuePair<string, TypedValue> nlp in namedListParams)
				q.SetParameterList(nlp.Key, (ICollection)nlp.Value.Value, nlp.Value.Type);
		}
开发者ID:peterbeams,项目名称:nhibernate-core,代码行数:64,代码来源:AbstractDetachedQuery.cs

示例7: SetTimePeriodParameters

 private static void SetTimePeriodParameters(IQuery q, TimePeriod period)
 {
     q.SetParameter("year", period.Year);
     q.SetParameter("yearRange", period.YearRange);
     q.SetParameter("quarter", period.Quarter);
     q.SetParameter("month", period.Month);
 }
开发者ID:PublicHealthEngland,项目名称:fingertips-open,代码行数:7,代码来源:GroupDataReader.cs

示例8: SetGroupingParameters

 private static void SetGroupingParameters(IQuery q, Grouping grouping)
 {
     q.SetParameter("indicatorId", grouping.IndicatorId);
     q.SetParameter(ParameterSexId, grouping.SexId);
     q.SetParameter("ageId", grouping.AgeId);
 }
开发者ID:PublicHealthEngland,项目名称:fingertips-open,代码行数:6,代码来源:GroupDataReader.cs

示例9: Apply

 /// <summary>
 /// Add this parameter to the <paramref name="query"/>.
 /// </summary>
 /// <param name="query">The query</param>
 /// <remarks>
 /// Is there a cleaner way to do this, without reflection or complex
 /// hierarchies?
 /// </remarks>
 public void Apply(IQuery query)
 {
     if (IsFlagged(ParameterFlags.Named))
     {
         if (IsFlagged(ParameterFlags.List))
         {
             if (Type != null)
                 query.SetParameterList(Name, (ICollection) Value, Type);
             else
                 query.SetParameterList(Name, (ICollection) Value);
         }
         else
         {
             if (Type != null)
                 query.SetParameter(Name, Value, Type);
             else
                 query.SetParameter(Name, Value);
         }
     }
     else if (IsFlagged(ParameterFlags.Positional))
     {
         if (IsFlagged(ParameterFlags.List))
         {
             throw new InvalidOperationException("Parameter lists can not be positional");
         }
         else
         {
             if (Type != null)
                 query.SetParameter(Position, Value, Type);
             else
                 query.SetParameter(Position, Value);
         }
     }
 }
开发者ID:zhoufoxcn,项目名称:ActiveRecord,代码行数:42,代码来源:QueryParameter.cs

示例10: CreateParameter

        private void CreateParameter(ModelBindingContext context, IQuery crit)
        {
            int i = 0;
            foreach (string pName in AnotherParameterName)
            {
                string parameterName = NHModelBinder.CreateSubPropertyName(context.ModelName, pName);
                var strValu = (string) context.ValueProvider.GetValue(parameterName).ConvertTo(typeof (string));
                IType paramType = TypeFactory.Basic(AnotherParameterType[i]);
                if (paramType == null)
                    throw new ArgumentException("Nhibernate do not defined base type named " +
                                                AnotherParameterType[i]);

                object val = NHMappingHelper.ConvertStringToObject(strValu, paramType);
                crit.SetParameter(parameterName, val, paramType);
            }
        }
开发者ID:luqizheng,项目名称:Qi4Net,代码行数:16,代码来源:HqlFounderAttribute.cs

示例11: AddGroupingParameters

 private void AddGroupingParameters(Grouping grouping, IQuery q)
 {
     q.SetParameter("indicatorId", grouping.IndicatorId);
     q.SetParameter("startYear", grouping.BaselineYear);
     q.SetParameter("endYear", grouping.DataPointYear);
     q.SetParameter("sexId", grouping.SexId);
     q.SetParameter("ageId", grouping.AgeId);
 }
开发者ID:PublicHealthEngland,项目名称:fingertips-open,代码行数:8,代码来源:TrendDataReader.cs

示例12: SetParameterValue

 public void SetParameterValue(IQuery query)
 {
     query.SetParameter(flatEntityPropertyName, value);
 }
开发者ID:hazzik,项目名称:nhcontrib-all,代码行数:4,代码来源:QueryParameterData.cs

示例13: AddParameters

        /// <summary>
        /// 
        /// </summary>
        /// <param name="query"></param>
        private void AddParameters(IQuery query)
        {
            if (!string.IsNullOrEmpty(txtNP1.Text) && !string.IsNullOrEmpty(txtPar1.Text))
            {
                query.SetParameter(txtNP1.Text , txtPar1.Text);
            }

            if (!string.IsNullOrEmpty(txtNP2.Text) && !string.IsNullOrEmpty(txtPar2.Text))
            {
                query.SetParameter(txtNP2.Text, txtPar2.Text);
            }

            if (!string.IsNullOrEmpty(txtNP3.Text) && !string.IsNullOrEmpty(txtPar3.Text))
            {
                query.SetParameter(txtNP3.Text, txtPar3.Text);
            }
        }
开发者ID:TheHunter,项目名称:WFPersistentLayerTester,代码行数:21,代码来源:Form1.cs

示例14: InitSession

 /// <summary>
 /// Initializes the session that will be used to enumerate
 /// </summary>
 private void InitSession()
 {
     _session = _sessionFactory.OpenSession();
     _session.FlushMode = FlushMode.Never;
     _tx = _session.BeginTransaction();
     try
     {
         //Handle the case of entity type (InitialLoad)
         if (_entityType != null)
         {
             _criteria = _session.CreateCriteria(_entityType);
             _criteria.SetCacheable(false);
             //If perform by id, add order to the criteria
             if (_performOrderById)
             {
                 IClassMetadata metadata = _sessionFactory.GetClassMetadata(_entityType);
                 string idPropName = metadata.IdentifierPropertyName;
                 if (idPropName != null)
                     _criteria.AddOrder(Order.Asc(idPropName));
             }
         }
         //Handle the case of Persistency.Query (GetEnumerator)
         else if (_persistencyQuery != null)
         {
             string select = _persistencyQuery.SqlQuery;
             _query = _session.CreateQuery(select);
             object[] preparedValues = _persistencyQuery.Parameters;
             if (preparedValues != null)
             {
                 for (int i = 0; i < preparedValues.Length; i++)
                 {
                     _query.SetParameter(i, preparedValues[i]);
                 }
             }
             _query.SetCacheable(false);
             _query.SetFlushMode(FlushMode.Never);
         }
         else throw new Exception("NHibernateDataEnumerator must receive an Entity Type or a Query");
     }
     catch(Exception ex)
     {
         if (_tx != null && _tx.IsActive)
             _tx.Rollback();
         if (_session.IsOpen)
             _session.Close();
         throw new Exception("Error while constructing an enumerator", ex);
     }
 }
开发者ID:GigaSpaces-ProfessionalServices,项目名称:xapnet-templates,代码行数:51,代码来源:NHibernateDataEnumerator.cs

示例15: AddParameters

        /// <summary>
        /// 向 IQuery 添加参数
        /// </summary>
        /// <param name="query"></param>
        private void AddParameters(IQuery query)
        {
            foreach (var item in filters)
            {
                if (!item.NoAdd && item.PropertyType == "ARR")
                    query.SetParameterList(item.PlaceholderPropertyName, item.PropertyValue as object[]);
                else if (!item.NoAdd)
                {
                    //query.SetParameter(item.PlaceholderPropertyName, item.PropertyValue);

                    if (item.Operation == "BT")
                    {
                        string[] valarr = item.PropertyValue.ToString().Split('_');
                        query.SetParameter(item.PlaceholderPropertyName + "_0", ValueConverter.Convert(item.PropertyType, valarr[0]));
                        query.SetParameter(item.PlaceholderPropertyName + "_1", ValueConverter.Convert(item.PropertyType, valarr[1]));
                    }
                    else
                    {
                        query.SetParameter(item.PlaceholderPropertyName, ValueConverter.Convert(item.PropertyType, item.PropertyValue));
                    }
                }
            }
        }
开发者ID:jeephalin,项目名称:dotnet,代码行数:27,代码来源:QueryInfo.cs


注:本文中的IQuery.SetParameter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。