本文整理汇总了C#中SimpleQuery.OfType方法的典型用法代码示例。如果您正苦于以下问题:C# SimpleQuery.OfType方法的具体用法?C# SimpleQuery.OfType怎么用?C# SimpleQuery.OfType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimpleQuery
的用法示例。
在下文中一共展示了SimpleQuery.OfType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPagedQueryCommandBuilders
private ICommandBuilder[] GetPagedQueryCommandBuilders(SimpleQuery query, Int32 bulkIndex, out IEnumerable<SimpleQueryClauseBase> unhandledClauses)
{
var commandBuilders = new List<ICommandBuilder>();
var unhandledClausesList = new List<SimpleQueryClauseBase>();
unhandledClauses = unhandledClausesList;
IEnumerable<SimpleQueryClauseBase> unhandledClausesForPagedQuery;
var mainCommandBuilder = new QueryBuilder(this, bulkIndex).Build(query, out unhandledClausesForPagedQuery);
unhandledClausesList.AddRange(unhandledClausesForPagedQuery);
const int maxInt = 2147483646;
var skipClause = query.Clauses.OfType<SkipClause>().FirstOrDefault() ?? new SkipClause(0);
var takeClause = query.Clauses.OfType<TakeClause>().FirstOrDefault() ?? new TakeClause(maxInt);
if (skipClause.Count != 0 || takeClause.Count != maxInt)
{
var queryPager = this.ProviderHelper.GetCustomProvider<IQueryPager>(this.ConnectionProvider);
if (queryPager == null)
{
unhandledClausesList.AddRange(query.OfType<SkipClause>());
unhandledClausesList.AddRange(query.OfType<TakeClause>());
}
var commandTexts = queryPager.ApplyPaging(mainCommandBuilder.Text, skipClause.Count, takeClause.Count);
foreach (var commandText in commandTexts)
{
var commandBuilder = new CommandBuilder(commandText, this._schema, mainCommandBuilder.Parameters);
commandBuilders.Add(commandBuilder);
}
}
return commandBuilders.ToArray();
}
示例2: DeferPaging
private void DeferPaging(ref SimpleQuery query, ICommandBuilder mainCommandBuilder, List<ICommandBuilder> commandBuilders,
List<SimpleQueryClauseBase> unhandledClausesList)
{
unhandledClausesList.AddRange(query.OfType<SkipClause>());
unhandledClausesList.AddRange(query.OfType<TakeClause>());
query = query.ClearSkip().ClearTake();
var commandBuilder = new CommandBuilder(mainCommandBuilder.Text, _adapter.GetSchema(),
mainCommandBuilder.Parameters);
commandBuilders.Add(commandBuilder);
}