本文整理汇总了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);
}
示例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;
}