本文整理汇总了C#中IQuery类的典型用法代码示例。如果您正苦于以下问题:C# IQuery类的具体用法?C# IQuery怎么用?C# IQuery使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IQuery类属于命名空间,在下文中一共展示了IQuery类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetFreeTextPredicate
protected Expression<Func<SearchResultItem, bool>> GetFreeTextPredicate(string[] fieldNames, IQuery query)
{
var predicate = PredicateBuilder.False<SearchResultItem>();
if (string.IsNullOrWhiteSpace(query.QueryText))
return predicate;
return fieldNames.Aggregate(predicate, (current, fieldName) => current.Or(i => i[fieldName].Contains(query.QueryText)));
}
示例2: ExecuteQuery
public void ExecuteQuery(IQuery<IEnumerable<Article>> query)
{
var predicateQuery = query as IPredicateQuery<Article>;
var result = this.articles.Where(a => predicateQuery.Predicate(a));
query.Callback(result);
}
示例3: Build
/// <summary>
/// <![CDATA[
/// 将聚合子表达式解析为嵌入式子查询条件。
/// 例如:
/// 将表达式
/// book.ChapterList.Cast<Chapter>().Any(c => c.Name == chapterName)
/// 转换为:
/// f.Exists(f.Query(chapter,
/// where: f.And(
/// f.Constraint(chapter.Column(Chapter.BookIdProperty), book.IdColumn),
/// f.Constraint(chapter.Column(Chapter.NameProperty), chapterName)
/// )
/// ))
/// SQL:
/// SELECT * FROM [Book] b
/// WHERE EXISTS(
/// SELECT * FROM [Chapter] c
/// WHERE c.BookId = b.Id AND
/// c.Name = {0}
/// )
/// ]]>
/// </summary>
/// <param name="exp">需要解析的表达式</param>
/// <param name="parentQuery"></param>
/// <param name="propertyFinder">The property finder.</param>
internal IConstraint Build(Expression exp, IQuery parentQuery, PropertyFinder propertyFinder)
{
_parentQuery = parentQuery;
_parentPropertyFinder = propertyFinder;
this.Visit(exp);
var res = f.Exists(_query);
if (!_isAny) res = f.Not(res);
//如果父查询中需要反转条件,则返回 NOT 语句。
if (propertyFinder.ReverseConstraint)
{
res = f.Not(res);
}
//把可空外键的不可空条件,与 Exists 条件合并后返回。
if (propertyFinder.NullableRefConstraint != null)
{
var op = propertyFinder.ReverseConstraint ? BinaryOperator.Or : BinaryOperator.And;
res = f.Binary(propertyFinder.NullableRefConstraint, op, res);
}
return res;
}
示例4: Search
public virtual ISearchResults Search(IQuery query)
{
using (var context = ContentSearchManager.GetIndex(this.IndexName).CreateSearchContext())
{
var root = this.Settings.Root;
var queryable = context.GetQueryable<SearchResultItem>();
queryable = SetQueryRoot(queryable, root);
queryable = this.FilterOnPresentationOnly(queryable);
queryable = FilterOnLanguage(queryable);
queryable = this.FilterOnTemplates(queryable);
queryable = this.AddContentPredicates(queryable, query);
queryable = AddFacets(queryable);
if (query.IndexOfFirstResult > 0)
{
queryable = queryable.Skip(query.IndexOfFirstResult);
}
if (query.NoOfResults > 0)
{
queryable = queryable.Take(query.NoOfResults);
}
var results = queryable.GetResults();
return SearchResultsRepository.Create(results, query);
}
}
示例5: Optimize
public void Optimize(IQuery q, object predicate, MethodBase filterMethod)
{
// TODO: cache predicate expressions here
var builder = new QueryExpressionBuilder();
var expression = builder.FromMethod(filterMethod);
new SODAQueryBuilder().OptimizeQuery(expression, q, predicate, _classFactory, new CecilReferenceResolver());
}
示例6: MatchesInvoke
internal override bool MatchesInvoke(Invoke invoke, IQuery query)
{
if (invoke == null)
return false;
bool ignoreCase = true;
if (query != null)
ignoreCase = query.IgnoreIdentifiersCase();
if (!RoutineName.Equals(invoke.RoutineName, ignoreCase))
return false;
var inputParams = Parameters.Where(parameter => parameter.IsInput).ToList();
if (invoke.Arguments.Length != inputParams.Count)
return false;
for (int i = 0; i < invoke.Arguments.Length; i++) {
// TODO: support variable evaluation here? or evaluate parameters before reaching here?
if (!invoke.Arguments[i].IsConstant())
return false;
var argType = invoke.Arguments[i].ReturnType(query, null);
var paramType = Parameters[i].Type;
// TODO: verify if this is assignable (castable) ...
if (!paramType.IsComparable(argType))
return false;
}
return true;
}
示例7: GetStream
public IObservable<string> GetStream(IQuery query)
{
if (query == null) throw new ArgumentNullException(nameof(query));
var requestProvider = GetRequestProvider(query);
var observable = Observable.Create<string>(async observer =>
{
//If exception thrown we retry ten times
//TODO: Config
for (var i = 0; i < 10; i++)
{
try
{
await _listener.Listen(requestProvider, observer.OnNext);
}
catch (Exception exception)
{
observer.OnError(exception);
continue;
}
break;
}
observer.OnCompleted();
});
return observable;
}
示例8: FilterAsync
public async Task FilterAsync(IQuery<ContentItem> query, ListContentsViewModel model, PagerParameters pagerParameters, IUpdateModel updateModel)
{
var viewModel = new ListPartContentAdminFilterModel();
if(await updateModel.TryUpdateModelAsync(viewModel, ""))
{
// Show list content items
if (viewModel.ShowListContentTypes)
{
var listableTypes = _contentDefinitionManager
.ListTypeDefinitions()
.Where(x =>
x.Parts.Any(p =>
p.PartDefinition.Name == nameof(ListPart)))
.Select(x => x.Name);
query.With<ContentItemIndex>(x => x.ContentType.IsIn(listableTypes));
}
// Show contained elements for the specified list
else if(viewModel.ListContentItemId != 0)
{
query.With<ContainedPartIndex>(x => x.ListContentItemId == viewModel.ListContentItemId);
}
}
}
示例9: CreateTable
private void CreateTable(IQuery query)
{
var tableInfo = new TableInfo(ObjectName.Parse("APP.test_table"));
tableInfo.AddColumn("a", PrimitiveTypes.Integer());
tableInfo.AddColumn("b", PrimitiveTypes.String(), false);
query.CreateTable(tableInfo, false, false);
}
示例10: NotFilter
public NotFilter(IQuery query)
{
if (query == null)
throw new ArgumentNullException("query", "NotFilter requires a query for this constructor.");
Query = query;
}
示例11: Create
private static void Create(IQuery systemQuery)
{
// SYSTEM.ROUTINE
systemQuery.Access()
.CreateTable(table => table
.Named(RoutineManager.RoutineTableName)
.WithColumn("id", PrimitiveTypes.Numeric())
.WithColumn("schema", PrimitiveTypes.String())
.WithColumn("name", PrimitiveTypes.String())
.WithColumn("type", PrimitiveTypes.String())
.WithColumn("location", PrimitiveTypes.String())
.WithColumn("body", PrimitiveTypes.Binary())
.WithColumn("return_type", PrimitiveTypes.String())
.WithColumn("username", PrimitiveTypes.String()));
// SYSTEM.ROUTINE_PARAM
systemQuery.Access().CreateTable(table => table
.Named(RoutineManager.RoutineParameterTableName)
.WithColumn("routine_id", PrimitiveTypes.Numeric())
.WithColumn("arg_name", PrimitiveTypes.String())
.WithColumn("arg_type", PrimitiveTypes.String())
.WithColumn("arg_attrs", PrimitiveTypes.Numeric())
.WithColumn("in_out", PrimitiveTypes.Integer())
.WithColumn("offset", PrimitiveTypes.Integer()));
}
示例12: UniqueAttribute
public UniqueAttribute(Type queryType, string nameOfMethodThatReturnsIList)
{
if (typeof(IQuery).IsAssignableFrom(queryType))
{
throw new InvalidTypeException(string.Format("The specified type '{0}' does not implement IQuery", queryType.Name));
}
_query = DependencyResolver.Current.GetService(queryType) as IQuery;
if (_query == null)
{
throw new TypeNotRegisteredException(
string.Format("The type '{0}' is not registered, and cannot be used to validate the uniqueness of a property", queryType.Name));
}
_queryMethod = queryType.GetMethod(nameOfMethodThatReturnsIList);
if (_queryMethod == null)
{
throw new InvalidMethodException(string.Format("The method '{0}.{1}' could not be found", queryType, nameOfMethodThatReturnsIList));
}
if (!typeof(IList).IsAssignableFrom(_queryMethod.ReturnType))
{
throw new InvalidMethodException(
string.Format(
"Really?! The method '{0}' assigned to nameOfMethodThatReturnsIList does not return an IEnumerable",
nameOfMethodThatReturnsIList));
}
}
示例13: AddAdditionalCriteria
private void AddAdditionalCriteria(IQuery query)
{
foreach (var criteria in AdditionalCriteria)
{
criteria(query);
}
}
示例14: SetParameters
private void SetParameters(IQuery query)
{
foreach (var parameter in NamedParameters)
{
query.SetParameter(parameter.Name, parameter.Value);
}
}
示例15: InsertData
private void InsertData(IQuery query)
{
var tableName = ObjectName.Parse("APP.persons");
var table = query.Access().GetMutableTable(tableName);
var row = table.NewRow();
row["name"] = Field.String("Antonello Provenzano");
row["age"] = Field.Integer(36);
row.SetDefault(query);
table.AddRow(row);
row = table.NewRow();
row["name"] = Field.String("Sebastiano Provenzano");
row["age"] = Field.Integer(35);
row.SetDefault(query);
table.AddRow(row);
row = table.NewRow();
row["name"] = Field.String("Mart Rosmaa");
row["age"] = Field.Integer(33);
row.SetDefault(query);
table.AddRow(row);
row = table.NewRow();
row["name"] = Field.String("Karl Inge Stensson");
row["age"] = Field.Integer(54);
row.SetDefault(query);
table.AddRow(row);
}