當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。