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


C# ODataQueryOptions.Validate方法代码示例

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


在下文中一共展示了ODataQueryOptions.Validate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetOrders

        // GET: odata/Orders
        public async Task<IHttpActionResult> GetOrders(ODataQueryOptions<Order> queryOptions)
        {
            // validate the query.
            try
            {
                queryOptions.Validate(_validationSettings);
            }
            catch (ODataException ex)
            {
                return BadRequest(ex.Message);
            }

            var repository = new Repositories.OrderMemoryRepository();
            var orders = queryOptions.ApplyTo(repository.Get().AsQueryable<Order>());

            return Ok<IQueryable<Order>>((IQueryable<Order>)orders);
        }
开发者ID:SergeyDushkin,项目名称:test,代码行数:18,代码来源:OrdersController.cs

示例2: 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

示例3: 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

示例4: 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

示例5: GetSalesLead

        // GET: odata/SalesLeads(5)
        public IHttpActionResult GetSalesLead([FromODataUri] int key, ODataQueryOptions<SalesLead> queryOptions)
        {
            // validate the query.
              try {
            queryOptions.Validate(_validationSettings);
              }
              catch (ODataException ex) {
            return BadRequest(ex.Message);
              }

              // return Ok<SalesLead>(salesLead);
              return StatusCode(HttpStatusCode.NotImplemented);
        }
开发者ID:CriticalPathTraining,项目名称:CBD365,代码行数:14,代码来源:SalesLeadsController.cs

示例6: GetCustomers

        public IEnumerable<Customer> GetCustomers(ODataQueryOptions<Customer> queryOptions)
        {
            // validate the query.
            queryOptions.Validate(_validationSettings);

            // Apply the query.
            IQuery query = queryOptions.ApplyTo(_db);

            Console.WriteLine("Executing HQL:\t" + query);
            Console.WriteLine();

            return query.List<Customer>();
        }
开发者ID:nickgoodrow,项目名称:ODataSamples,代码行数:13,代码来源:CustomersController.cs

示例7: GetProductViewModel

        // GET: odata/Product(5)
        public IHttpActionResult GetProductViewModel([FromODataUri] System.Guid key, ODataQueryOptions<ProductViewModel> queryOptions)
        {
            // validate the query.
            try
            {
                queryOptions.Validate(_validationSettings);
            }
            catch (ODataException ex)
            {
                return BadRequest(ex.Message);
            }

            // return Ok<ProductViewModel>(productViewModel);
            return StatusCode(HttpStatusCode.NotImplemented);
        }
开发者ID:verveinfotech,项目名称:Innoventory,代码行数:16,代码来源:ProductController.cs

示例8: GetProduct

        // GET: odata/Product
        public IHttpActionResult GetProduct(ODataQueryOptions<ProductViewModel> queryOptions)
        {
            // validate the query.
            try
            {
                queryOptions.Validate(_validationSettings);
            }
            catch (ODataException ex)
            {
                return BadRequest(ex.Message);
            }

            // return Ok<IEnumerable<ProductViewModel>>(productViewModels);
            return StatusCode(HttpStatusCode.NotImplemented);
        }
开发者ID:verveinfotech,项目名称:Innoventory,代码行数:16,代码来源:ProductController.cs

示例9: GetCategoryEntity

        // GET: odata/CategoryEntities(5)
        public IHttpActionResult GetCategoryEntity([FromODataUri] int key, ODataQueryOptions<CategoryEntity> queryOptions)
        {
            // validate the query.
            try
            {
                queryOptions.Validate(_validationSettings);
            }
            catch (ODataException ex)
            {
                return BadRequest(ex.Message);
            }

             return Ok<CategoryEntity>(db.Category.Single(o=>o.CategoryId==key));
            //return StatusCode(HttpStatusCode.NotImplemented);
        }
开发者ID:kimx,项目名称:AngularLab,代码行数:16,代码来源:CategoryEntitiesController.cs

示例10: GetVELEMIMUNKAINMLIST

        // GET: odata/DBElemiMunka(5)
        public IHttpActionResult GetVELEMIMUNKAINMLIST([FromODataUri] long key, ODataQueryOptions<VELEMIMUNKAINMLIST> queryOptions)
        {
            // validate the query.
            try
            {
                queryOptions.Validate(_validationSettings);
            }
            catch (ODataException ex)
            {
                return BadRequest(ex.Message);
            }

            // return Ok<VELEMIMUNKAINMLIST>(vELEMIMUNKAINMLIST);
            return StatusCode(HttpStatusCode.NotImplemented);
        }
开发者ID:focsi,项目名称:WebAPIDevExpressApp,代码行数:16,代码来源:DBElemiMunkaController.cs

示例11: GetOrder

        // GET: odata/Orders(5)
        public async Task<IHttpActionResult> GetOrder([FromODataUri] System.Guid key, ODataQueryOptions<Order> queryOptions)
        {
            // validate the query.
            try
            {
                queryOptions.Validate(_validationSettings);
            }
            catch (ODataException ex)
            {
                return BadRequest(ex.Message);
            }

            // return Ok<Order>(order);
            return StatusCode(HttpStatusCode.NotImplemented);
        }
开发者ID:SergeyDushkin,项目名称:test,代码行数:16,代码来源:OrdersController.cs

示例12: GetRacer

        // GET: odata/Racers(5)
        public IHttpActionResult GetRacer([FromODataUri] long key, ODataQueryOptions<Racer> queryOptions)
        {
            // validate the query.
            try
            {
                queryOptions.Validate(_validationSettings);
            }
            catch (ODataException ex)
            {
                return BadRequest(ex.Message);
            }

            // return Ok<Racer>(racer);
            return StatusCode(HttpStatusCode.NotImplemented);
        }
开发者ID:Saroko-dnd,项目名称:My_DZ,代码行数:16,代码来源:RacersController.cs

示例13: GetRacers

        // GET: RaceApi/Racers
        public IQueryable<Racer> GetRacers(ODataQueryOptions<Racer> queryOptions)
        {
            // validate the query.
            try
            {
                queryOptions.Validate(_validationSettings);
            }
            catch (ODataException ex)
            {
                return null;
            }

            // return Ok<IEnumerable<Racer>>(racers);
            return CurrentRaceRepository.AllRacers;
        }
开发者ID:Saroko-dnd,项目名称:My_DZ,代码行数:16,代码来源:RacersController.cs

示例14: GetNews

        // GET: NewsOdata/GettingNewsUsingHeaderValue(5)
        public IHttpActionResult GetNews([FromODataUri] long key, ODataQueryOptions<NewsInfrastructure.News> queryOptions)
        {
            // validate the query.
            try
            {
                queryOptions.Validate(_validationSettings);
            }
            catch (ODataException ex)
            {
                return BadRequest(ex.Message);
            }

            // return Ok<News>(news);
            return StatusCode(HttpStatusCode.NotImplemented);
        }
开发者ID:Saroko-dnd,项目名称:My_DZ,代码行数:16,代码来源:GettingNewsUsingHeaderValueController.cs

示例15: GetCategoryEntities

        // GET: odata/CategoryEntities
        public IHttpActionResult GetCategoryEntities(ODataQueryOptions<CategoryEntity> queryOptions)
        {
            // validate the query.
            try
            {
                queryOptions.Validate(_validationSettings);
            }
            catch (ODataException ex)
            {
                return BadRequest(ex.Message);
            }

            return Ok<IEnumerable<CategoryEntity>>(db.Category);

            return StatusCode(HttpStatusCode.NotImplemented);
        }
开发者ID:kimx,项目名称:AngularLab,代码行数:17,代码来源:CategoryEntitiesController.cs


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