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


C# IQuery.SetProperties方法代码示例

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


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

示例1: OnEvent

 public void OnEvent(IQuery query)
 {
     switch (sig)
     {
         case MethodSig.Object:
             query.SetProperties(bean);
             break;
         case MethodSig.Map:
             query.SetProperties(map);
             break;
         default:
             throw new ShardedSessionException(
                 "Unknown sig in SetPropertiesEvent: " + sig);
     }
 }
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:15,代码来源:SetPropertiesEvent.cs

示例2: 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


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