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


C# IQuery类代码示例

本文整理汇总了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)));
 }
开发者ID:BIGANDYT,项目名称:Habitat,代码行数:7,代码来源:IndexContentProviderBase.cs

示例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);
        }
开发者ID:codewithpassion,项目名称:SimpleCQS,代码行数:7,代码来源:ArticleServiceStub.cs

示例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;
        }
开发者ID:569550384,项目名称:Rafy,代码行数:50,代码来源:SubEntityQueryBuilder.cs

示例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);
              }
        }
开发者ID:JobiJoba,项目名称:Habitat,代码行数:25,代码来源:SearchService.cs

示例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());
 }
开发者ID:masroore,项目名称:db4o,代码行数:7,代码来源:NQOptimizer.cs

示例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;
        }
开发者ID:ArsenShnurkov,项目名称:deveeldb,代码行数:31,代码来源:ProcedureInfo.cs

示例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;
        }
开发者ID:MiningCat,项目名称:AwesomeTwitterClient,代码行数:29,代码来源:Streaming.cs

示例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);
                }
            }
        }
开发者ID:MichaelPetrinolis,项目名称:Orchard2,代码行数:25,代码来源:ListPart.cs

示例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);
 }
开发者ID:ArsenShnurkov,项目名称:deveeldb,代码行数:7,代码来源:OpenStatementTests.cs

示例10: NotFilter

        public NotFilter(IQuery query)
        {
            if (query == null)
                throw new ArgumentNullException("query", "NotFilter requires a query for this constructor.");

            Query = query;
        }
开发者ID:kbolay,项目名称:Bolay.Elastic,代码行数:7,代码来源:NotFilter.cs

示例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()));
        }
开发者ID:deveel,项目名称:deveeldb,代码行数:25,代码来源:SystemBuilderExtensions.cs

示例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));
			}
		}
开发者ID:smhinsey,项目名称:Euclid,代码行数:28,代码来源:UniqueAttribute.cs

示例13: AddAdditionalCriteria

 private void AddAdditionalCriteria(IQuery query)
 {
     foreach (var criteria in AdditionalCriteria)
     {
         criteria(query);
     }
 }
开发者ID:nkmajeti,项目名称:nhibernate,代码行数:7,代码来源:CommandData.cs

示例14: SetParameters

 private void SetParameters(IQuery query)
 {
     foreach (var parameter in NamedParameters)
     {
         query.SetParameter(parameter.Name, parameter.Value);
     }
 }
开发者ID:nkmajeti,项目名称:nhibernate,代码行数:7,代码来源:CommandData.cs

示例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);
        }
开发者ID:deveel,项目名称:deveeldb,代码行数:28,代码来源:CompositeSelectTests.cs


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