Пример #1
0
        public IItemEnumerable <IQueryResult> Query(string statement, bool searchAllVersions, IOperationContext context)
        {
            IDiscoveryService service = Binding.GetDiscoveryService();
            IOperationContext ctxt    = new OperationContext(context);

            PageFetcher <IQueryResult> .FetchPage fetchPageDelegate = delegate(long maxNumItems, long skipCount)
            {
                // fetch the data
                IObjectList resultList = service.Query(RepositoryId, statement, searchAllVersions, ctxt.IncludeAllowableActions,
                                                       ctxt.IncludeRelationships, ctxt.RenditionFilterString, maxNumItems, skipCount, null);

                // convert query results
                IList <IQueryResult> page = new List <IQueryResult>();
                if (resultList.Objects != null)
                {
                    foreach (IObjectData objectData in resultList.Objects)
                    {
                        if (objectData == null)
                        {
                            continue;
                        }

                        page.Add(ObjectFactory.ConvertQueryResult(objectData));
                    }
                }

                return(new PageFetcher <IQueryResult> .Page <IQueryResult>(page, resultList.NumItems, resultList.HasMoreItems));
            };

            return(new CollectionEnumerable <IQueryResult>(new PageFetcher <IQueryResult>(DefaultContext.MaxItemsPerPage, fetchPageDelegate)));
        }