odata

Enable WCF Data Service to accept/return JSON by default

为君一笑 提交于 2019-12-20 11:52:45
问题 I have a WCF Data Service that I'd like to return JSON by default for all operations. Is there a place I can set that in configuration/via service attributes? 回答1: In order to enable json via the $format tag like this: host:8038/YourService.svc/?$format=json Add this attribute to your service declaration: [JSONPSupportBehavior] public class Service : DataService<YourEntities> Add this as a class to your service: using System; using System.ServiceModel; using System.ServiceModel.Channels;

Enable WCF Data Service to accept/return JSON by default

寵の児 提交于 2019-12-20 11:52:00
问题 I have a WCF Data Service that I'd like to return JSON by default for all operations. Is there a place I can set that in configuration/via service attributes? 回答1: In order to enable json via the $format tag like this: host:8038/YourService.svc/?$format=json Add this attribute to your service declaration: [JSONPSupportBehavior] public class Service : DataService<YourEntities> Add this as a class to your service: using System; using System.ServiceModel; using System.ServiceModel.Channels;

using apicontroller vs odata EntitySetController [closed]

∥☆過路亽.° 提交于 2019-12-20 09:17:47
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 6 years ago . I just started learning about ASP.NET Web API and I have several things that are still unclear to me: why should I use EntitySetController,which inherits from odata controller instead of ApiController Why is EF frequently mentioned in the context of OData. I know it

breezejs: adding referential constraint to an entity type

你说的曾经没有我的故事 提交于 2019-12-20 07:30:58
问题 This is a follow-up question to my previous issue - this one was getting a bit messy and is more related to the Telerik Data Service. The metadata I receive from the server are missing the referential constraints in the association node, although I've set the foreign key attribute on my model . Therefore I was thinking about manually adding these constraints to my entities in the callback of FetchMetadata. Is that possible and can someone provide a simple example on how to do it ? [EDIT] Here

Problem with WCF Data Service (OData), SetEntitySetPageSize and custom operations

家住魔仙堡 提交于 2019-12-20 06:27:51
问题 I have a WCF Data Service with a custom operation named MostRecentFilms that returns the 10 most recent films in the source. Each film has, among others, a Year property. All goes fine with the default setting but when I set the page size for entity sets, config.SetEntitySetPageSize("*", 100) , the order of returned films are not good. Doesn't matter if the result set has less than 100, they are not properly ordered from more recent to less, how it was returned when the page size restriction

Why are there missing client-side results when using OData options with Entity Framework DBContext?

六眼飞鱼酱① 提交于 2019-12-20 06:20:05
问题 OData and Entity Framework are suppose to work well together, in that OData options will be passed to the EF db context to filter queries - ie. return only the number of records requested from the server as not to inflate the payload rather than all the records then filter. Given the following URL path: /api/Users?$top=10&$skip=10 Given the following controller action: [Queryable(AllowedQueryOptions = AllowedQueryOptions.All)] public IEnumerable<USER> Get(ODataQueryOptions<USER> options) {

Passing parameters to an OData (GET) method which returns a collection

半世苍凉 提交于 2019-12-20 05:33:15
问题 I am using OData v3 . How do I pass a parameter to an OData controller and return a collection? Example of what I am trying to do: [EnableQuery(AllowedQueryOptions = AllowedQueryOptions.All)] public IQueryable<ServiceInfoResult> Get([FromODataUri] int instanceId) { //etc } When I test this, I get this error: No HTTP resource was found that matches the request URI 'http://localhost:30863/odata/ServiceInfoResultApi(1)'. No action was found on the controller 'ServiceInfoResultApi' that matches

Web API, odata v4 and Castle Windsor

喜夏-厌秋 提交于 2019-12-20 03:52:35
问题 I have WebApi project with ODataController and I'm trying to inject some dependency into MyController. I was following this blogpost by Mark Seemann. Consider code below. Problem is, that when is MyController creating, I got exception inside WindsorCompositionRoot Create method on this line, var controller = (IHttpController)this.container.Resolve(controllerType); An exception of type 'Castle.MicroKernel.ComponentNotFoundException' occurred in Castle.Windsor.dll but was not handled in user

Consume OData Service from Visual Studio 2017

最后都变了- 提交于 2019-12-20 02:36:31
问题 I've a issue consuming Dynamics Nav OData. I'm using Visual Studio Community 2017 (version 15.9.0), and I've installed the extension OData Connected Service (Official Microsoft Extension)1. This is my Odata structure: http://myWeb:8145/DynamicsNav90_Desa/OData I've verified and the odata is returning 2 values correctly at opera browser. So far, it's working fine. The problem is when I go to the visual studio and I try to add a new connected service, It throws the next error 3: Image text:

How to provide custom mediatype formats for OData Api

情到浓时终转凉″ 提交于 2019-12-20 02:08:32
问题 I am developing an ASP.NET application that uses ODataApiController. The application shows users a grid by querying data and showing it in a table. I would like the ability to export to a number of different formats, including CSV and a custom XML format. Ideally, I would just take the same OData query the grid uses, set the Accepts header, and get back CSV or XML. I've created MediaTypeFormatters to do what I need, but they only work with "regular" ApiController, not ODataApiController.