本文整理汇总了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);
}
示例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);
}
示例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);
}
}
示例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);
}
示例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);
}
示例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>();
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}