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


C# Query.ODataQueryOptions类代码示例

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


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


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