odata

How to turn on IIS7 output cache for WCF data services (OData)

感情迁移 提交于 2019-12-12 16:20:03
问题 I have a WCF data service which is sensitive to a quite sophisticated notion of parameters in terms of URL. The common case is having the URLs like http://host:port/DataServices/NavigationMetadataService.svc/Inventories('2.1.11.5')?$expand=Components,Items,Items/Properties,Items/Properties/Values (OData notion of parameters). The service is supposed to return static data. This means that for one unique combination of parameters the response will always be the same (but its size is about 10-20

How do I get Odata Web API to return data in the XML format

走远了吗. 提交于 2019-12-12 14:36:22
问题 I have created a Odata Web API service, by default this service returns data in JSON format. How can I get the data in the XML format? Thanks 回答1: If you are using OData V4, JSON is the default and recommended format for response payload and also the OASIS standard. So I highly recommend you to use JSON unless you have special reasons. If you have to get XML format, the thread WebAPI OData $format to xml may be helpful. 来源: https://stackoverflow.com/questions/25402483/how-do-i-get-odata-web

What's the best practice to do “stable paging” in OData?

谁说胖子不能爱 提交于 2019-12-12 14:14:00
问题 In the comment of this post (Problem with WCF Data Service (OData), SetEntitySetPageSize and custom operations), it mentioned “OData stable paging”. I am quite new to OData, and trying to get stable paging in OData query. By "stable paging", I mean there is an OData database in which new entries are constantly being created, I wanted the paging are not interrupted by the new data creation in the database. For example, if I get the first page by $top=100 , then get second page by $top=100&

Inheritance is not supported, even with a custom OData Service Provider?

冷暖自知 提交于 2019-12-12 13:29:31
问题 EDIT : I went ahead and created a little project to demonstrate this issue (called RestfulTimesTest), available on SkyDrive. I built a custom OData Service Provider to provide queries and updates into a custom model, based on Alex James' excellent blog post on Creating a Data Service Provider. Consider the following 3 CLR classes: ResidentialCustomer , Customer , and User . ResidentialCustomer extends Customer , Customer has a list of User s, and User has a reference back to Customer . The

Reuse existing ASP.NET-MVC 5 Identity 2 authorization for WEB API OData controllers to make it easy to login for other apps?

梦想的初衷 提交于 2019-12-12 13:04:32
问题 I have complete ASP.NET-MVC5 application which I extended by the WEB API 2 OData controllers. For instance I have: public class PersonController : ODataController and MVC controller which demands authorization [Authorize] public class PersonController : Controller Both contollers use ApplicationDbContext where my DbSets are I don't want to give data about person to everyone in the world through WEB API controller. I already have User , Moderator and Admin roles in my MVC application. Can I

Web API ODataResult Is Always Serializing to Atom

假装没事ソ 提交于 2019-12-12 12:23:42
问题 I'm returning an ODataResult from the new Web API OData package as follows: public ODataResult<Product> Get(ODataQueryOptions options) { var results = (options.ApplyTo(_db.Products) as IQueryable<Product>); var count = results.Count; var limitedResults = results.Take(100).ToArray(); return new ODataResult<Product>(results,null,count); } The above works great but it always returns an Atom response regardless of the query type. How can I return JSON? I can see that Atom is the first supported

OData WebApi V4 .net - Custom Serialization

不打扰是莪最后的温柔 提交于 2019-12-12 10:57:33
问题 I need to create a Serializer to support all of the following tasks: Removing null properties Removing Empty Lists I noticed the Syntax of the ODataMediaTypeFormatter has been changed. And I'm having trouble adding my Serialzation provider to the pipe. Here what I've tried: On WebApiConfig.cs: var odataFormatters = ODataMediaTypeFormatters.Create(); odataFormatters.Add(new MyDataMediaTypeFormatter()); config.Formatters.InsertRange(0, odataFormatters); Plus I've Created the following

Access-Control-Allow-Origin error when accessing Northwind OData service from SAPUI5?

佐手、 提交于 2019-12-12 10:23:33
问题 I have created a sample SAPUI5 application in online editor Check this link to view my code I am getting this below error - > XMLHttpRequest cannot load > http://services.odata.org/V2/Northwind/Northwind.svc/Products?$format=json. > No 'Access-Control-Allow-Origin' header is present on the requested > resource. Can someone help me in solving this issue - I understand that it is CORS issue which can be solved by disabling the security in chrome. However - I don't to disable the security

Exception message is On data context type there is a top IQueryable property whose element type is not an entity type

我们两清 提交于 2019-12-12 09:41:38
问题 im bulding my WCFDataService hosted in IIS 7, im going to use Reflection Provider as data source provider. my sample work if i keep the entity type definition in the same assembly where i defined the service, but dosen't work if i move the entity type to another referenced assembly with following error "server encountered an error processing the request. The exception message is 'On data context type 'EntityContainer', there is a top IQueryable property 'Cats' whose element type is not an

What's the right HTTP status code for a response when I can't perform a DELETE due to a FK constrain?

懵懂的女人 提交于 2019-12-12 09:29:18
问题 What would be the right response I should give to the users when they try to DELETE an entity on a datasource sitting behind a rest/odata api, and the operation cannot be performed due to a foreign key constrain? Is it a bad request? A not acceptable? A server-side error (>=500)? 回答1: Just found this website that says that '409 Conflict' should be used when 'the request could not be completed due to a conflict with the current state of the resource' and 'where it is expected that the user