odata

How to create query expression for Odata for get by Id

北慕城南 提交于 2019-12-12 08:57:47
问题 I have created an OData service and now I am trying to consume this service at client side. I wants to create an expression such as for the below url in the c# query expression- http://odata.org/Product-Service/Product(150) The above url is working fine in browsers but I want to create query expression in the C# for the above url. Any help would be greatly appreciable. 回答1: You could use a DataServiceContext + DataServiceQuery in System.Data.Services.Client to hit the Url. Remember no query

Inserting Entities in OData with required Foreign Keys

烈酒焚心 提交于 2019-12-12 08:48:27
问题 EDIT-2: After hours of research and almost every odata related link on google turning purple, I found out that the concept of 'deep-inserts' (link) exists in the OData specification. So after all, what I'm doing should work, even without the links. Does anyone know how to enable this on the Microsoft OData client? Are there any other OData clients out there that support that concept? EDIT: Maybe this is the wrong approach, so please tell me if I'm doing it totally wrong. Not being able to

Kendo DataSource: How to define “Computed” Properties for data read from remote odata source

為{幸葍}努か 提交于 2019-12-12 07:28:20
问题 Situation: kendo DataSource var ordersDataSource = new kendo.data.DataSource({ type: "odata", transport: { read: { url: "http://localhost/odata.svc/Orders?$expand=OrderDetails" } }, schema: { type: "json", data: function(response){ return response.value; } total: function(response){ return response['odata.count']; } }, serverPaging: true, serverFiltering: true, serverSorting: true }) the json data read from the odata source is like: { odata.metadata: "xxxx", odata.count: "5", value: [ {

Webapi odata expand with entity framework functions

时光总嘲笑我的痴心妄想 提交于 2019-12-12 07:21:13
问题 I have a Product odata controller and a Product Category odata controller. They are both using entity framework entities and have navigation methods used for odata expand. The expand for both is working fine. Now I added a stored procedure in entity framework to manipulate the data returned from the database and still return a "Product" record. I set the entity stored procedure function return type to "Product" and created a new function in the Product odata controller to call the entity

Expanding collections using Web Api OData controller

时光总嘲笑我的痴心妄想 提交于 2019-12-12 06:37:44
问题 I'm using OData framework 5.0.0 and Web API 5.0.0 and EntityFramework 5.0.0. And have problem with expand on navigation property which is a collection. I always get the following exception: The 'ObjectContent`1' type failed to serialize the response body for content type 'application/json; charset=utf-8'. The given key was not present in the dictionary. at System.Web.Http.OData.Query.Expressions.SelectExpandWrapper`1.GetEdmType() at System.Web.Http.OData.Formatter.Serialization

Every OData Service will provoide metadata document?

自作多情 提交于 2019-12-12 06:17:51
问题 I'm a little bit confused that metadata doucment in OData Service. As odata-v4.0-part1-protocol doc mentioned, there are two well-defined resources that describe its data model, a service document and a metadata document. I want to know if that means both of these two resources must be implemented during development of OData Services, or developers just only need to implement one of them by their own choices? I do appreciate anyone's help. Thanks 回答1: Not necessarily. According to the "13.1

Is there an OData dependency graph somewhere?

跟風遠走 提交于 2019-12-12 04:33:27
问题 I'm following this guide to migrate an app I developed to an open framework. I get to the part where I'm supposed to install all the OData references. Specifically these: Install-Package Angularjs Install-Package Microsoft.OData.Client Install-Package Microsoft.OData.Core Install-Package Microsoft.OData.Edm Install-Package Microsoft.Spatial Install-Package Microsoft.AspNet.OData Install-Package Microsoft.AspNet.WebApi.WebHost And these are the errors I get: Unable to resolve dependencies.

GET /entity.svc failed in batch

杀马特。学长 韩版系。学妹 提交于 2019-12-12 04:24:27
问题 I defined a service in dataSources "dataSources": { "mainService": { "uri": "/backend/service/v1/entity.svc/", "type": "OData", } } "models": { "": { "dataSource": "mainService", "preload": true, "settings" : { "sizeLimit" : 500, "useBatch" : false, "refreshAfterChange": false, "defaultBindingMode": "TwoWay", "defaultCountMode" : "None", "defaultUpdateMethod" : "Put" } } } But for some reason I don't know, ui5 project will call GET /backend/service/v1/entity.svc/ when initial load, which

Invalid request handling in OData

放肆的年华 提交于 2019-12-12 04:24:01
问题 Im writing an OData webservice with C# and I need some advice on how to handle invalid requests? An example of an error would be if a customer requested a service on an item they no longer own. I would idealy like to report back to the customer exactly why it is invalid as there are multiple possible reasons. Many thanks 回答1: I would recommend using FaultContracts as part of the OperationContract. You can define them just like DataContracts, and handle exceptions just like a custom exception.

OData controller returns different error for local and different for remote machine

梦想的初衷 提交于 2019-12-12 04:16:01
问题 In my project I use OData 3.0 and I need to handle error that comes from SQL stored procedure. Here is the controller code: public class StartProductionBatchListController : ODataController { private SitContext<StartProductionBatchModel> db = new SitContext<StartProductionBatchModel>(); [EnableQuery] [SITAuthorize("/production/ordersOverview")] public DbRawSqlQuery<StartProductionBatchModel> GetStartProductionBatchList([FromODataUri] string entryId) { Dictionary<string, string> parameters =