• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# IQuery类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IQuery的典型用法代码示例。如果您正苦于以下问题:C# IQuery类的具体用法?C# IQuery怎么用?C# IQuery使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IQuery类属于命名空间,在下文中一共展示了IQuery类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: InterfaceSelectionItemsSource

 public InterfaceSelectionItemsSource(
     ClassifierDictionary classifiers,
     IQuery<Classifier> availableClassifiers,
     MessageSystem messageSystem):base(classifiers,availableClassifiers.Get,messageSystem)
 {
     _classifiers = classifiers;
 }
开发者ID:pgenfer,项目名称:YumlFrontEnd,代码行数:7,代码来源:InterfaceSelectionItemsSource.cs


示例17: _IRunnable_50

			public _IRunnable_50(EventRegistryImpl _enclosing, Transaction transaction, IQuery
				 query)
			{
				this._enclosing = _enclosing;
				this.transaction = transaction;
				this.query = query;
			}
开发者ID:erdincay,项目名称:db4o,代码行数:7,代码来源:EventRegistryImpl.cs


示例18: AddTestData

        private void AddTestData(IQuery context)
        {
            var table = context.GetMutableTable(ObjectName.Parse("APP.people"));
            var row = table.NewRow();

            // row.SetValue("id", DataObject.Integer(0));
            row.SetDefault(0, context);
            row.SetValue("first_name", DataObject.String("John"));
            row.SetValue("last_name", DataObject.String("Doe"));
            row.SetValue("birth_date", DataObject.Date(new SqlDateTime(1977, 01, 01)));
            row.SetValue("active", DataObject.Boolean(false));
            table.AddRow(row);

            row = table.NewRow();

            // row.SetValue("id", DataObject.Integer(1));
            row.SetDefault(0, context);
            row.SetValue("first_name", DataObject.String("Jane"));
            row.SetValue("last_name", DataObject.String("Doe"));
            row.SetValue("birth_date", DataObject.Date(new SqlDateTime(1978, 11, 01)));
            row.SetValue("active", DataObject.Boolean(true));
            table.AddRow(row);

            row = table.NewRow();

            // row.SetValue("id", DataObject.Integer(2));
            row.SetDefault(0, context);
            row.SetValue("first_name", DataObject.String("Roger"));
            row.SetValue("last_name", DataObject.String("Rabbit"));
            row.SetValue("birth_date", DataObject.Date(new SqlDateTime(1985, 05, 05)));
            row.SetValue("active", DataObject.Boolean(true));
            table.AddRow(row);

            context.Commit();
        }
开发者ID:ArsenShnurkov,项目名称:deveeldb,代码行数:35,代码来源:TableQueryTests.cs


示例19: Query

        public virtual string Query(IQuery query)
        {
            try
            {
                StringBuilder str = new StringBuilder();
                IReadOnlyList<SingleEntityView> svList = _vv.VisitAlias(query.View);

                str.Append(_tr.Select);
                str.Append(_cb.BuildSelectColumns(query.View));
                str.Append(_tr.From);
                str.Append(_vv.BuildJoinClause(query.View));
                if (query.Criteria != null)
                {
                    str.Append(_tr.Where);
                    str.Append(_cv.BuildWhereFilters(query.Criteria, svList));
                }
                if (query.Order != null)
                {
                    str.Append(_tr.OrderBy);
                    str.Append(_ov.BuildOrderClause(query.Order, svList));
                }
                return str.ToString();
            }
            catch (Exception ex)
            {
                throw ex.CreateWrapException<SQLGenerateException>();
            }
        }
开发者ID:rexzh,项目名称:RexToy,代码行数:28,代码来源:AbstractQuerySQLEmit.cs


示例20: FindAllAsync

        /// <summary>
        /// Gets a paginated list of APObjects matching the given search criteria.
        /// </summary>
        /// <param name="type">The object type.</param>
        /// <param name="query">The search query for objects to be found.</param>
        /// <param name="fields">The object fields to be returned for the matching list of objects.</param>
        /// <param name="pageNumber">The page number.</param>
        /// <param name="pageSize">The page size.</param>
        /// <param name="orderBy">The object field on which the results should be sorted.</param>
        /// <param name="sortOrder">The sort order.</param>
        /// <param name="options">Request specific api options. These will override the global settings for the app for this request.</param>
        /// <returns>Paginated list of APObject objects matching the given search criteria.</returns>
        public async static Task<PagedList<APObject>> FindAllAsync(string type, IQuery query = null, IEnumerable<string> fields = null, int pageNumber = 1, int pageSize = 20, string orderBy = null, SortOrder sortOrder = SortOrder.Descending, ApiOptions options = null)
        {
            query = query ?? Query.None;
            var request = new FindAllObjectsRequest()
            {
                Type = type,
                Query = query.AsString().Escape(),
                PageNumber = pageNumber,
                PageSize = pageSize,
                OrderBy = orderBy,
                SortOrder = sortOrder
            };
            if( fields != null )
                request.Fields.AddRange(fields);
            ApiOptions.Apply(request, options);
            var response = await request.ExecuteAsync();
            if (response.Status.IsSuccessful == false)
                throw response.Status.ToFault();
            var objects = new PagedList<APObject>()
            {
                PageNumber = response.PagingInfo.PageNumber,
                PageSize = response.PagingInfo.PageSize,
                TotalRecords = response.PagingInfo.TotalRecords,
                GetNextPage = async skip => await FindAllAsync(type, query, fields, pageNumber + skip + 1, pageSize, orderBy, sortOrder, options)
            };
            objects.AddRange(response.Objects);
            return objects;

        }
开发者ID:ytokas,项目名称:appacitive-dotnet-sdk,代码行数:41,代码来源:APObjects.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IQueryAdapter类代码示例发布时间:2022-05-24
下一篇:
C# IQuantity类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap