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

C# Query.ODataQueryOptions类代码示例

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

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



ODataQueryOptions类属于System.Web.Http.OData.Query命名空间,在下文中一共展示了ODataQueryOptions类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Get

 public IQueryable<ProductType> Get(ODataQueryOptions<Domain.ProductType> paramters)
 {
     var resultset = paramters.ApplyTo(_db.ProductTypes).AsQueryable() as IQueryable<Domain.ProductType>;
     // ReSharper disable once AssignNullToNotNullAttribute
     var productTypes = resultset.ToArray().Select(Mapper.Map<ProductType>).AsQueryable();
     return productTypes;
 }
开发者ID:cberberian,项目名称:GameSim,代码行数:7,代码来源:ProductTypeController.cs


示例2: GetCount

        public HttpResponseMessage GetCount(ODataQueryOptions<ODataPackage> options)
        {
            var queryResults = (IQueryable<ODataPackage>)options.ApplyTo(Get());
            var count = queryResults.Count();

            return OkCount(count);
        }
开发者ID:jjchiw,项目名称:NuGet.Lucene,代码行数:7,代码来源:PackagesODataController.cs


示例3: GetReference

        // GET: odata/References(5)
        public async Task<IHttpActionResult> GetReference([FromODataUri] int key, ODataQueryOptions<Reference> queryOptions)
        {
            //Get access token to SharePoint
            string accessToken = await _tokenProvider.GetSharePointAccessToken();
            if (accessToken == null)
            {
                throw new UnauthorizedAccessException();
            }

            // validate the query.
            try
            {
                queryOptions.Validate(_validationSettings);
            }
            catch (ODataException ex)
            {
                return BadRequest(ex.Message);
            }

            //Get reference from SharePoint
            string eTag = Request.Headers.IfNoneMatch.ToString();
            Reference reference = await _repository.GetReference(accessToken, key, eTag);

            //Check eTag
            if (reference.__eTag == eTag)
            {
                return new StatusCodeResult(HttpStatusCode.NotModified, Request);
            }
            
            return Ok(reference);
        }
开发者ID:modulexcite,项目名称:Research-Project-Code-Sample,代码行数:32,代码来源:ReferencesController.cs


示例4: Get

        public IHttpActionResult Get(int key, ODataQueryOptions<ETagsCustomer> queryOptions)
        {
            IEnumerable<ETagsCustomer> appliedCustomers = customers.Where(c => c.Id == key);

            if (appliedCustomers.Count() == 0)
            {
                return BadRequest("The key is not valid");
            }

            if (queryOptions.IfNoneMatch != null)
            {
                appliedCustomers = queryOptions.IfNoneMatch.ApplyTo(appliedCustomers.AsQueryable()).Cast<ETagsCustomer>();
            }

            if (queryOptions.IfMatch != null)
            {
                appliedCustomers = queryOptions.IfMatch.ApplyTo(appliedCustomers.AsQueryable()).Cast<ETagsCustomer>();
            }

            if (appliedCustomers.Count() == 0)
            {
                return StatusCode(HttpStatusCode.NotModified);
            }
            else
            {
                return Ok(new SingleResult<ETagsCustomer>(appliedCustomers.AsQueryable()));
            }
        }
开发者ID:ZhaoYngTest01,项目名称:WebApi,代码行数:28,代码来源:ETagsController.cs


示例5: GetProject

        // GET: odata/Projects(5)
        public async Task<IHttpActionResult> GetProject([FromODataUri] int key, ODataQueryOptions<Project> queryOptions)
        {
            //Get access token to SharePoint
            string accessToken = ((Repository)_repository).GetAccessToken();
            if (accessToken == null)
            {
                throw new UnauthorizedAccessException();
            }

            // validate the query.
            try
            {
                queryOptions.Validate(_validationSettings);
            }
            catch (ODataException ex)
            {
                return BadRequest(ex.Message);
            }

            //Get project from SharePoint
            string eTag = Request.Headers.IfNoneMatch.ToString();
            Project project = await _repository.GetProject(accessToken, key, eTag);

            //Check eTag
            if (project.__eTag == eTag)
            {
                return new StatusCodeResult(HttpStatusCode.NotModified, Request);
            }
            else
            {
                return Ok<Project>(project);
            }
        }
开发者ID:developerlucky,项目名称:DevCampTraining,代码行数:34,代码来源:ProjectsController.cs


示例6: IsHijackable

        public static bool IsHijackable(ODataQueryOptions<V2FeedPackage> options, out HijackableQueryParameters hijackable)
        {
            // Check if we can process the filter clause
            if (!CanProcessFilterClause(options))
            {
                hijackable = null;
                return false;
            }

            // Build expression (this works around all internal classes in the OData library - all we want is an expression tree)
            var expression = options.ApplyTo(EmptyQueryable, QueryResultDefaults.DefaultQuerySettings).Expression;

            // Unravel the comparisons into a list we can reason about
            List<Tuple<Target, string>> comparisons = new List<Tuple<Target, string>>();
            Expression remnant = FindQueryableWhere(expression as MethodCallExpression);
            MethodCallExpression where;
            while (IsQueryableWhere(where = remnant as MethodCallExpression))
            {
                var extractedComparisons = ExtractComparison(where).ToList();
                if (!extractedComparisons.Any() || extractedComparisons.Any(c => c == null))
                {
                    hijackable = null;
                    return false;
                }
                else
                {
                    // We recognize this comparison, record it and keep iterating on the nested expression
                    comparisons.AddRange(extractedComparisons);
                    remnant = where.Arguments[0];
                }
            }

            // We should be able to hijack here
            if (comparisons.Any())
            {
                hijackable = new HijackableQueryParameters();
                foreach (var comparison in comparisons)
                {
                    if (comparison.Item1 == Target.Id)
                    {
                        hijackable.Id = comparison.Item2;
                    }
                    else if (comparison.Item1 == Target.Version)
                    {
                        hijackable.Version = comparison.Item2;
                    }
                    else
                    {
                        hijackable = null;
                        return false;
                    }
                }

                return true;
            }

            hijackable = null;
            return false;
        }
开发者ID:rhysawilliams2010,项目名称:NuGetGallery,代码行数:59,代码来源:SearchHijacker.cs


示例7: Get

 /// <summary>
 /// Gets the list of blog posts by specified filter.
 /// </summary>
 /// <param name="options">The options.</param>
 /// <returns>
 /// List of blog post service models.
 /// </returns>
 public DataListResponse<AuthorModel> Get(ODataQueryOptions<AuthorModel> options)
 {
     using (var api = CmsContext.CreateApiContextOf<BlogsApiContext>())
     {
         var results = api.GetAuthorsAsQueryable();
         return results.ToDataListResponse(options);
     }
 }
开发者ID:tkirda,项目名称:BetterCMS,代码行数:15,代码来源:AuthorsController.cs


示例8: Get

 /// <summary>
 /// Gets the list of blog posts by specified filter.
 /// </summary>
 /// <param name="options">The options.</param>
 /// <param name="filter">The filter.</param>
 /// <returns>
 /// List of blog post service models.
 /// </returns>
 public DataListResponse<BlogPostModel> Get(ODataQueryOptions<BlogPostModel> options, [FromUri] GetBlogPostRequest filter)
 {
     using (var api = CmsContext.CreateApiContextOf<BlogsApiContext>())
     {
         var results = api.GetBlogPostsAsQueryable(filter);
         return results.ToDataListResponse(options);
     }
 }
开发者ID:tkirda,项目名称:BetterCMS,代码行数:16,代码来源:BlogsController.cs


示例9: ApplyQuery

        /// <summary>
        /// All standard OData web api support is handled here (except select and expand).
        /// This method also handles nested orderby statements the the current ASP.NET web api does not yet support.
        /// This method is called by base.OnActionExecuted
        /// </summary>
        /// <param name="queryable"></param>
        /// <param name="queryOptions"></param>
        /// <returns></returns>
        public override IQueryable ApplyQuery(IQueryable queryable, ODataQueryOptions queryOptions)
        {
            var queryHelper = GetQueryHelper(queryOptions.Request);

              queryable = queryHelper.BeforeApplyQuery(queryable, queryOptions);
              queryable = queryHelper.ApplyQuery(queryable, queryOptions);
              return queryable;
        }
开发者ID:nateClicks,项目名称:Breeze,代码行数:16,代码来源:BreezeQueryableAttribute.cs


示例10: GetSalesLeads

        public IHttpActionResult GetSalesLeads(ODataQueryOptions<SalesLead> queryOptions)
        {
            try { queryOptions.Validate(_validationSettings); }
              catch (ODataException ex) { return BadRequest(ex.Message); }

              var queryResults = queryOptions.ApplyTo(SalesLeadFactory.GetSalesLeads()).Cast<SalesLead>();

              return Ok<IQueryable<SalesLead>>(queryResults);
        }
开发者ID:CriticalPathTraining,项目名称:CBD365,代码行数:9,代码来源:SalesLeadsController.cs


示例11: BeforeApplyQuery

 public override IQueryable BeforeApplyQuery(IQueryable queryable, ODataQueryOptions queryOptions)
 {
     var nhQueryable = queryable as IQueryableInclude;
     if (nhQueryable != null)
     {
         queryable = ApplyExpand(nhQueryable);
     }
     return queryable;
 }
开发者ID:GoneFishern,项目名称:Breeze,代码行数:9,代码来源:NHQueryHelper.cs


示例12: GetPurchaseRequisitionDescriptions

        // GET api/PurchaseRequisitionDescription
        public IEnumerable<PurchaseRequisitionDescription> GetPurchaseRequisitionDescriptions(ODataQueryOptions Options)
        {
            //return db.PurchaseRequisitionDescriptions.Include(p=>p.Product).AsEnumerable();
            //return Options.ApplyTo(db.PurchaseRequisitionDescriptions.Include(p => p.Product) as IQueryable) as IEnumerable<PurchaseRequisitionDescription>;

            //db.PurchaseRequisitionDescriptions.Include(p => p.Product).Include()

            return Options.ApplyTo(db.PurchaseRequisitionDescriptions.AsQueryable().Include(p => p.Product).Include(p => p.Product.ProductCategory).Include(u => u.UOM)) as IEnumerable<PurchaseRequisitionDescription>;
        }
开发者ID:daradbd,项目名称:BMS,代码行数:10,代码来源:PurchaseRequisitionDescriptionController.cs


示例13: Get

        // GET api/buildingupgrade
        public IQueryable<BuildingUpgrade> Get(ODataQueryOptions<Domain.BuildingUpgrade> paramters)
        {
            var logStart = LogHelper.StartLog("Started BuildingUpgradeController.Get", Logger);
            var resultset = paramters.ApplyTo(_db.BuildingUpgrades).AsQueryable() as IQueryable<Domain.BuildingUpgrade>;
            // ReSharper disable once AssignNullToNotNullAttribute

            var buildingUpgrades = resultset.ToArray().Where(x=>x.Name.StartsWith("Property") && x.Completed == false).OrderBy(x=>x.Name). Select(Mapper.Map<BuildingUpgrade>).AsQueryable();
            return LogHelper.EndLog(logStart, buildingUpgrades);
        }
开发者ID:cberberian,项目名称:GameSim,代码行数:10,代码来源:BuildingUpgradeController.cs


示例14: Get

        public IHttpActionResult Get(ODataQueryOptions<V1FeedPackage> options)
        {
            var queryable = _packagesRepository.GetAll()
                .Where(p => !p.IsPrerelease && !p.Deleted)
                .WithoutVersionSort()
                .ToV1FeedPackageQuery(_configurationService.GetSiteRoot(UseHttps()));

            return QueryResult(options, queryable, MaxPageSize);
        }
开发者ID:NuGet,项目名称:NuGetGallery,代码行数:9,代码来源:ODataV1FeedController.cs


示例15: Ctor_SuccedsIfEntityTypesMatch

        public void Ctor_SuccedsIfEntityTypesMatch()
        {
            ODataConventionModelBuilder builder = new ODataConventionModelBuilder();
            builder.EntitySet<Customer>("Customers");

            ODataQueryContext context = new ODataQueryContext(builder.GetEdmModel(), typeof(Customer));

            ODataQueryOptions<Customer> query = new ODataQueryOptions<Customer>(context, new HttpRequestMessage(HttpMethod.Get, "http://server/?$top=10"));
            Assert.Equal("10", query.Top.RawValue);
        }
开发者ID:chrissimon-au,项目名称:aspnetwebstack,代码行数:10,代码来源:ODataQueryOptionsOfTEntityTest.cs


示例16: ApplyQuery

 public override IQueryable ApplyQuery(IQueryable queryable, ODataQueryOptions queryOptions)
 {
     var queryHelper = GetQueryHelper(queryOptions.Request);
     if (queryOptions.SelectExpand?.RawExpand != null)
     {
         queryOptions = QueryHelper.RemoveOptions(queryOptions, new List<string>() { "$expand" });
         //queryOptions = new ODataQueryOptions()
     }
     return queryHelper.ApplyQuery(queryable, queryOptions);
 }
开发者ID:mcshaz,项目名称:SimPlanner,代码行数:10,代码来源:EnableMappedBreezeQueryAttribute.cs


示例17: ApplyExpand

        /// <summary>
        /// Overrides the method in QueryHelper to perform the $expands in NHibernate.
        /// Also populates the ExpandTypeMap that controls lazy initialization and serialization.
        /// </summary>
        /// <param name="queryable"></param>
        /// <param name="expandsQueryString"></param>
        /// <returns></returns>
        public override IQueryable ApplyExpand(IQueryable queryable, ODataQueryOptions queryOptions)
        {
            var expandQueryString = queryOptions.RawValues.Expand;
            if (string.IsNullOrWhiteSpace(expandQueryString)) return queryable;
            var session = GetSession(queryable);
            var fetcher = new NHEagerFetch(session.SessionFactory);
            queryable = fetcher.ApplyExpansions(queryable, expandQueryString, expandMap);

            return queryable;
        }
开发者ID:rmarmer1,项目名称:Breeze,代码行数:17,代码来源:NHQueryHelper.cs


示例18: GetCore

        private async Task<IHttpActionResult> GetCore(ODataQueryOptions<V1FeedPackage> options, string id, string version, bool return404NotFoundWhenNoResults)
        {
            var packages = _packagesRepository.GetAll()
                .Include(p => p.PackageRegistration)
                .Where(p => p.PackageRegistration.Id.Equals(id, StringComparison.OrdinalIgnoreCase) && !p.IsPrerelease && !p.Deleted);

            if (!string.IsNullOrEmpty(version))
            {
                packages = packages.Where(p => p.Version == version);
            }

            // try the search service
            try
            {
                var searchAdaptorResult = await SearchAdaptor.FindByIdAndVersionCore(
                    _searchService, GetTraditionalHttpContext().Request, packages, id, version, curatedFeed: null);

                // If intercepted, create a paged queryresult
                if (searchAdaptorResult.ResultsAreProvidedBySearchService)
                {
                    // Packages provided by search service
                    packages = searchAdaptorResult.Packages;

                    // Add explicit Take() needed to limit search hijack result set size if $top is specified
                    var totalHits = packages.LongCount();

                    if (return404NotFoundWhenNoResults && totalHits == 0)
                    {
                        return NotFound();
                    }

                    var pagedQueryable = packages
                        .Take(options.Top != null ? Math.Min(options.Top.Value, MaxPageSize) : MaxPageSize)
                        .ToV1FeedPackageQuery(GetSiteRoot());

                    return QueryResult(options, pagedQueryable, MaxPageSize, totalHits, (o, s, resultCount) =>
                       SearchAdaptor.GetNextLink(Request.RequestUri, resultCount, new { id }, o, s));
                }
            }
            catch (Exception ex)
            {
                // Swallowing Exception intentionally. If *anything* goes wrong in search, just fall back to the database.
                // We don't want to break package restores. We do want to know if this happens, so here goes:
                QuietLog.LogHandledException(ex);
            }

            if (return404NotFoundWhenNoResults && !packages.Any())
            {
                return NotFound();
            }

            var queryable = packages.ToV1FeedPackageQuery(GetSiteRoot());
            return QueryResult(options, queryable, MaxPageSize);
        }
开发者ID:NuGet,项目名称:NuGetGallery,代码行数:54,代码来源:ODataV1FeedController.cs


示例19: GetGeoCache

 // GET: odata/GeoCaches(1)
 public GeoCache GetGeoCache([FromODataUri] int key, ODataQueryOptions<GeoCache> queryOptions)
 {
     var geoCache = GeoCacheService.GetGeoCache(key);
     return new GeoCache
     {
         Id = geoCache.Id,
         Latitude = geoCache.Latitude,
         Longitude = geoCache.Longitude,
         Name = geoCache.Name
     };
 }
开发者ID:Alpinfish,项目名称:Calico,代码行数:12,代码来源:GeoCachesController.cs


示例20: CountSearch

        public HttpResponseMessage CountSearch(
            [FromODataUri] string searchTerm,
            [FromODataUri] string targetFramework,
            [FromODataUri] bool includePrerelease,
            ODataQueryOptions<ODataPackage> options)
        {
            var queryResults = (IQueryable<ODataPackage>)options.ApplyTo(Search(searchTerm, targetFramework, includePrerelease, options));
            var count = queryResults.Count();

            return OkCount(count);
        }
开发者ID:jjchiw,项目名称:NuGet.Lucene,代码行数:11,代码来源:PackagesODataController.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Routing.ODataPath类代码示例发布时间:2022-05-26
下一篇:
C# Serialization.SelectExpandNode类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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