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


C# QueryParameters.PrepareParameterTypes方法代码示例

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


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

示例1: GetQueryStringAndTypes

		public virtual SqlCommandInfo GetQueryStringAndTypes(ISessionImplementor session, QueryParameters parameters, int startParameterIndex)
		{
			SqlString sqlString = ProcessFilters(parameters, session);
			Dialect.Dialect dialect = session.Factory.Dialect;

			RowSelection selection = parameters.RowSelection;
			bool useLimit = UseLimit(selection, dialect);
			bool hasFirstRow = GetFirstRow(selection) > 0;
			bool useOffset = hasFirstRow && useLimit && dialect.SupportsLimitOffset;
			int limitParameterCount = GetFirstLimitParameterCount(dialect, useLimit, hasFirstRow, useOffset);

			SqlType[] sqlTypes = parameters.PrepareParameterTypes(sqlString, Factory, GetNamedParameterLocs, startParameterIndex + limitParameterCount, useLimit, useOffset);

			if (useLimit)
			{
				sqlString =
					dialect.GetLimitString(sqlString.Trim(), useOffset ? GetFirstRow(selection) : 0, GetMaxOrLimit(dialect, selection));
			}

			sqlString = PreprocessSQL(sqlString, parameters, dialect);
			return new SqlCommandInfo(sqlString, sqlTypes);
		}
开发者ID:remcoros,项目名称:nhibernate,代码行数:22,代码来源:Loader.cs

示例2: PrepareQueryCommand

		/// <summary>
		/// Obtain an <c>IDbCommand</c> with all parameters pre-bound. Bind positional parameters,
		/// named parameters, and limit parameters.
		/// </summary>
		/// <remarks>
		/// Creates an IDbCommand object and populates it with the values necessary to execute it against the 
		/// database to Load an Entity.
		/// </remarks>
		/// <param name="queryParameters">The <see cref="QueryParameters"/> to use for the IDbCommand.</param>
		/// <param name="scroll">TODO: find out where this is used...</param>
		/// <param name="session">The SessionImpl this Command is being prepared in.</param>
		/// <returns>A CommandWrapper wrapping an IDbCommand that is ready to be executed.</returns>
		protected internal virtual IDbCommand PrepareQueryCommand(QueryParameters queryParameters, bool scroll,
		                                                          ISessionImplementor session)
		{
			SqlString sqlString = ProcessFilters(queryParameters, session);
			Dialect.Dialect dialect = session.Factory.Dialect;

			RowSelection selection = queryParameters.RowSelection;
			bool useLimit = UseLimit(selection, dialect);
			bool hasFirstRow = GetFirstRow(selection) > 0;
			bool useOffset = hasFirstRow && useLimit && dialect.SupportsLimitOffset;
			int startIndex = GetFirstLimitParameterCount(dialect, useLimit, hasFirstRow, useOffset);
			// TODO NH bool callable = queryParameters.Callable;

			SqlType[] parameterTypes = queryParameters.PrepareParameterTypes(sqlString, Factory, GetNamedParameterLocs, startIndex, useLimit, useOffset);

			if (useLimit)
			{
				sqlString =
					dialect.GetLimitString(sqlString.Trim(), useOffset ? GetFirstRow(selection) : 0, GetMaxOrLimit(dialect, selection));
			}

			sqlString = PreprocessSQL(sqlString, queryParameters, dialect);

			// TODO NH: Callable for SP -> PrepareCallableQueryCommand
			IDbCommand command =
				session.Batcher.PrepareQueryCommand(CommandType.Text, sqlString, parameterTypes);

			try
			{
				// Added in NH - not in H2.1
				if (selection != null && selection.Timeout != RowSelection.NoValue)
				{
					command.CommandTimeout = selection.Timeout;
				}

				int colIndex = 0;

				if (useLimit && dialect.BindLimitParametersFirst)
				{
					colIndex += BindLimitParameters(command, colIndex, selection, session);
				}
				// TODO NH
				//if (callable)
				//{
				//  colIndex = dialect.RegisterResultSetOutParameter(command, col);
				//}

				colIndex += BindParameterValues(command, queryParameters, colIndex, session);

				if (useLimit && !dialect.BindLimitParametersFirst)
				{
					BindLimitParameters(command, colIndex, selection, session);
				}

				if (!useLimit)
				{
					SetMaxRows(command, selection);
				}
				if (selection != null)
				{
					if (selection.Timeout != RowSelection.NoValue)
					{
						command.CommandTimeout = selection.Timeout;
					}
					// H2.1 handles FetchSize here - not ported
				}
			}
			catch (HibernateException)
			{
				session.Batcher.CloseCommand(command, null);
				throw;
			}
			catch (Exception sqle)
			{
				session.Batcher.CloseCommand(command, null);
				ADOExceptionReporter.LogExceptions(sqle);
				throw;
			}

			return command;
		}
开发者ID:remcoros,项目名称:nhibernate,代码行数:93,代码来源:Loader.cs


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