Questions tagged [odatacontroller]

27 questions
6
votes
1 answer

How to specify an API key name in Excel - A web API key can only be specified when a web API key name is provided

I have a standard MVC API OData enabled service which works under anonymous authentication. I would like to pass a web API key to the application...which works fine when added through code or postman.. Unfortunately my users would prefer to use…
Kye
  • 5,919
  • 10
  • 49
  • 84
3
votes
1 answer

Change field type in Odata OrderBy

I have OdataService with CustDetails table (I am using Entity Framework). In the table I have column PostalCode of string type. When I sort the data it working fine. It sort the data by considering it as string type. But my requirement is, in my…
Sunil Prabakar
  • 442
  • 1
  • 5
  • 19
2
votes
1 answer

get count from oData enabled web api Get function

i have an oData enabled classic REST web api controller with a Get function like [EnableQuery()] public IQueryable Get() { return _storeCommandService.GetAllStoreCommands().AsQueryable(); } i need to understand…
1
vote
1 answer

How to deal with overposting/underposting when your setup is OData with Entity Framework

The normal path in WEB API is to have your "Entity" and the "DTO". For example: public class Product // DB Entity { public int Id { get; set; } public string Name { get; set; } public string SerialNumber { get; set; } public string…
T.S.
  • 18,195
  • 11
  • 58
  • 78
1
vote
2 answers

Return CreatedAtRoute location from ODataController

I have ODataController with a Post method in it which should return a URL to a newly created OData resource, something like the following: public class TasksController: ODataController { [HttpPost] public IActionResult Post([FromBody]…
1
vote
0 answers

Is there a way to implement Group by in OData

How to implement group by in ODATA. Please let me know if there are any option available to do group by on a column and Summation on another column . I know this is very vague question, but i could not figure out right pointers for implementing…
user145610
  • 2,949
  • 4
  • 43
  • 75
1
vote
0 answers

How to return IQueryable result after joining 2 entities in oData controller

I have two tables UU_DeliveryCharges and SC_Countries and I want to return result set as a join of these two in my odata function but getting an exception: The entity or complex type 'ULYXModel.UU_DeliveryCharges' cannot be constructed in a LINQ to…
Mona
  • 21
  • 5
1
vote
1 answer

Issue implementing child class method

So I'm having a bit of a problem... the thing is that I have a base class that has implementation for all GET/POST/PUT/DELETE and it's a Generic class so basically whatever I Entity I update passes through there and then I have a class for my…
Alonso Quesada
  • 125
  • 1
  • 3
  • 11
1
vote
1 answer

OData v4 DefaultODataBatchHandler NotImplementedException

In my web service I've setup for batch requests. I wrapped the DefaultODataBatchHandler class just to add break points. It is processing the requests successfully and the CreateResponseMessageAsync method is creating a 200 OK response. But the…
1
vote
3 answers

How can I POST with navigation properties using Microsoft.OData.Client and Web Api

I have two classes, Vehicle and OwnershipRecord and neither can be persisted to the database without the other. A Vehicle must have at least one OwnershipRecord and an OwnershipRecord must be associated with a Vehicle. It doesn't make sense…
1
vote
1 answer

OData attribute routing: one controller for multiple data types

I am reading the OData V4 update blog: https://blogs.msdn.microsoft.com/webdev/2014/03/13/getting-started-with-asp-net-web-api-2-2-for-odata-v4-0/ It mentions the newly added [ODataRoute] attribute for attribute routing. In the traditional…
1
vote
1 answer

How to create custom entity for Web API 2 OData Data controller

I have the need to migrate my traditional Web API 2 Data controllers over to OData v4 style data controllers. This works very easily with the standard one-to-one table-to-entity relationship but I now have the need to use several different tables…
1
vote
1 answer

OdataClient SaveChanges doesn't work and results an empty Microsoft.OData.Client.DataServiceResponse

I encapsulated the odata container because of some extensions: public class Connector { public string apiKey{get;set;} public Connector(string apiKey) { this.apiKey = apiKey; } public Default.Container Get() { …
1
vote
0 answers

Performance Issue with ODataController

We have developed a logistic domain system that deals with millions of records. In order to show the records as per the filter applied by the user, we were fetching the data with filtering conditions included in the query and fetching back the…
1
vote
1 answer

OData attribute routing for deleting relationship between m:m entities

The scenario is an application that uses OData v4, server-side API based on an Entity Framework model using ODataLib, client-side using the OData client code generator extension for Visual Studio I'm failing to get OData attribute routing working…
1
2