本文整理汇总了C#中NHibernate.SqlCommand.SqlString.IndexOf方法的典型用法代码示例。如果您正苦于以下问题:C# SqlString.IndexOf方法的具体用法?C# SqlString.IndexOf怎么用?C# SqlString.IndexOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NHibernate.SqlCommand.SqlString
的用法示例。
在下文中一共展示了SqlString.IndexOf方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Apply
public static SqlString Apply(SqlString sql)
{
if (text == null)
return sql;
var s = "from " + theTable;
var index = sql.IndexOfCaseInsensitive(s);
var indexOfSpaceAfterAlias = sql.IndexOf(" ", index + s.Length +1, sql.Length, StringComparison.InvariantCultureIgnoreCase);
if (indexOfSpaceAfterAlias == -1)
return sql;
return sql.Insert(indexOfSpaceAfterAlias, text);
}
示例2: ExpandDynamicFilterParameters
private SqlString ExpandDynamicFilterParameters(SqlString sqlString, ICollection<IParameterSpecification> parameterSpecs, ISessionImplementor session)
{
var enabledFilters = session.EnabledFilters;
if (enabledFilters.Count == 0 || sqlString.IndexOf(ParserHelper.HqlVariablePrefix, 0, sqlString.Length, StringComparison.Ordinal) < 0)
{
return sqlString;
}
Dialect.Dialect dialect = session.Factory.Dialect;
string symbols = ParserHelper.HqlSeparators + dialect.OpenQuote + dialect.CloseQuote;
var originSql = sqlString.Compact();
var result = new SqlStringBuilder();
foreach (var sqlPart in originSql)
{
var parameter = sqlPart as Parameter;
if (parameter != null)
{
result.Add(parameter);
continue;
}
var sqlFragment = sqlPart.ToString();
var tokens = new StringTokenizer(sqlFragment, symbols, true);
foreach (string token in tokens)
{
if (token.StartsWith(ParserHelper.HqlVariablePrefix))
{
string filterParameterName = token.Substring(1);
string[] parts = StringHelper.ParseFilterParameterName(filterParameterName);
string filterName = parts[0];
string parameterName = parts[1];
var filter = (FilterImpl)enabledFilters[filterName];
object value = filter.GetParameter(parameterName);
IType type = filter.FilterDefinition.GetParameterType(parameterName);
int parameterColumnSpan = type.GetColumnSpan(session.Factory);
var collectionValue = value as ICollection;
int? collectionSpan = null;
// Add query chunk
string typeBindFragment = string.Join(", ", Enumerable.Repeat("?", parameterColumnSpan).ToArray());
string bindFragment;
if (collectionValue != null && !type.ReturnedClass.IsArray)
{
collectionSpan = collectionValue.Count;
bindFragment = string.Join(", ", Enumerable.Repeat(typeBindFragment, collectionValue.Count).ToArray());
}
else
{
bindFragment = typeBindFragment;
}
// dynamic-filter parameter tracking
var filterParameterFragment = SqlString.Parse(bindFragment);
var dynamicFilterParameterSpecification = new DynamicFilterParameterSpecification(filterName, parameterName, type, collectionSpan);
var parameters = filterParameterFragment.GetParameters().ToArray();
var sqlParameterPos = 0;
var paramTrackers = dynamicFilterParameterSpecification.GetIdsForBackTrack(session.Factory);
foreach (var paramTracker in paramTrackers)
{
parameters[sqlParameterPos++].BackTrack = paramTracker;
}
parameterSpecs.Add(dynamicFilterParameterSpecification);
result.Add(filterParameterFragment);
}
else
{
result.Add(token);
}
}
}
return result.ToSqlString().Compact();
}