All Questions
Tagged with odata asp.net-core
462 questions
0
votes
1
answer
96
views
When OData apply ODataQueryOptions<T> in .NET 8?
Help me understand when Odata applies query parameters to IQueryable?
The task is as follows: it is necessary to get the result of the query execution to the database before sending it to the client.
...
0
votes
0
answers
55
views
EnsureStableOrdering = false is not stopping default sorting in navigation entities on ASP.NET Core OData
Even after setting EnsureStableOrdering = falsein the ODataQuerySettings ODataQueryOptions is still applying default sorting in the collection of navigation entities when expand is specified in the ...
1
vote
0
answers
63
views
OData orderby Enum Type throws exception
I have an entity defined as follows, which encounters issues when trying to sort by the TheType property:
[Serializable]
[Authorize]
[JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)]
...
0
votes
1
answer
91
views
ASP.NET Core OData 8: allow deep navigation
We're using odata2ts as our client side library. As stated on it's docs:
OData exposes and advertises entry points, most often entity sets (e.g. /People). We can traverse to a specific entity of that ...
0
votes
0
answers
46
views
AutoMapper.Extensions.OData wrong SQL query for compare nullable DateTime and DateOnly
For all OData endpoints in my ASP.NET Core Web API, I return value in this way:
{
"@odata.context": "...",
"@odata.count": 0,
"value": [...]
}
When ...
1
vote
0
answers
23
views
OData and ASP.NET Core : how do I handle OData queries with dots in the key strings? [duplicate]
I have an OData interface running in an IIS application. When I try to update an entry whose primary key contains a dot, the application returns a 404 error.
This is the format of the URL that's ...
0
votes
1
answer
34
views
.NET Core OData - $expand not working with ODataQueryOptions in the backend
I have a controller which has OdataQueryOptions as a parameter, as follows:
[EnableQuery]
public async Task<ActionResult<IEnumerable<SecuredEmployee>>> Get([FromQuery] int? ...
2
votes
1
answer
131
views
Could not find a property named 'keyName' on type 'MyClass' on ASP.NET Core OData 8.2.5
Assemblies affected: ASP.NET Core OData 8.2.5
I am getting an error
Could not find a property named 'keyName' on type 'MyClass' on ASP.NET Core OData 8.2.5
but it was working fine up to the ASP.NET ...
0
votes
0
answers
29
views
How to support OData /$count endpoint on functions
I am currently developing an OData web service with ASP.NET Core. I have a controller for companies and added an endpoint as an OData function to retrieve subsidiaries.
The subsidiaries should be ...
1
vote
0
answers
91
views
Filtering with OData on More Properties but Returning a DTO with Fewer Properties in ASP.NET Core not possible
I am working on an ASP.NET Core project where I need to filter data based on all properties of an entity using complex OData query strings. However, the response should only include a subset of these ...
0
votes
1
answer
202
views
Entity Framework Core - Performing NOLOCK queries with OData
I am trying to perform EF Core queries using NOLOCK, there is an article which demonstrated how to write an extension method, but it is not working as expected with OData query.
Here is the link:
...
1
vote
2
answers
134
views
How to create odata and non-odata endpoint in same controller
Goal: Within the same controller create two httpget endpoints: one for OData and one for non-OData.
This code gives error: AmbiguousMatchException: The request matched multiple endpoints.
[Route("...
0
votes
0
answers
48
views
OData .net core dealing with a generic collection
New to OData and I have a question I cannot seem to find a solid solution for. I admit this might just be info overload and I cannot find the right path. So I am looking for at least a path forward.
I ...
1
vote
0
answers
149
views
Unable to create a constant value of type 'Microsoft.OData.Edm.IEdmModel' for OData Select Request
I'm using OData 8.2.5 with .NET 6 and I'm trying to return results from my controller shown below. When I hit /odata/MyType it works, but if I hit /odata/MyType?$select=Id, I get the error in the ...
0
votes
0
answers
43
views
Ignoring properties at runtime in .NET Core / EF Core and OData
I want to make Common.Student and xyzProp dynamic (replaced programmatically).
I have them as string right now how to handle type? I tried using generics and reflections but got an error:
System....
0
votes
0
answers
95
views
Response payload is not odata payload
I am struggling to get an asp.net core web api with ODATA working properly. While it seems that the GET endpoint responds to the select, filter, order functions, the payload does not seem to be an ...
0
votes
0
answers
65
views
ASP.NET Core OData creating generic pass through controller for underlying APIs
Scenario:
There are multiple APIs on async pattern. Each API has its own query option and its JSON request body
Each API only returns 202 and a custom response header
I want to have a single API, ...
0
votes
0
answers
114
views
Using OData to query a collection of "random" JsonObject
I'm trying to create an apicontroller that can use odata syntax to filter a collection of json objects. This collection can be from json columns in databases or any other datastore. The important ...
1
vote
0
answers
76
views
How to expose SQL Server temporal table history records via ASP.NET Core Web API ODataController
How does one expose a SQL Server temporal table's history data via an ASP.NET Core Web API ODataController accessing its data from an Entity Framework Core repository?
I am encountering "invalid ...
0
votes
1
answer
192
views
OData filtering on client-defined dynamic properties
I have two entities defined in the server:
public partial class MyModel
{
public string ModelCode { get; set; }
public virtual ICollection<MyModelSubItem> SubItems { get; set; } = new ...
0
votes
0
answers
83
views
use odata v3 only in asp.net core
For my ASP.Net Core WEB API endpoints, I only want to use ODataV3 instead of ODataV4 how can I make that possible or enforce it, because client is sending data V3 format to the server.
Please don't ...
0
votes
1
answer
250
views
The entity type cannot be configured as complex type because the derivd typ is alredy configred as entity typ. ODataConventionModelBuilder GetEdmModel
Background : We were using this code with previous version of OData v4.0.30319 with .net 4.8 it was working fine recently we started to migrate the project to .NET Core 6 and using Microsoft....
1
vote
1
answer
185
views
Return entity from bound OData action
I'm trying to return an entity from a bound OData action but I can't find a way that works.
The request gets routed correctly but when writing the response, OData complains:
When writing a JSON ...
0
votes
1
answer
168
views
OData Count in ASP.NET Core 6 doesn't return the count of data
I am able to get the count using an OData query of $count=true
https://localhost:7269/programs?$skip=20&$top=2&$count=true
but it didn't work and returned with the API this is my controller ...
0
votes
0
answers
38
views
.ReturnsCollectionFromEntitySet not working as expected in AspNetCore.Odata
i have Aspnetcore API using AspNetCore.Odata 7.5.12
when i hit https://localhost/beta/$metadata
i get the following response
<EntityType Name="Recipient">
<Key>
<PropertyRef ...
0
votes
1
answer
95
views
OData Endpoint missing properties of the Entity
I have a class such as this
public class AppData
{
[Key]
[JsonProperty("Id")]
public Guid AppId { get; set; }
[JsonProperty("Link")]
...
1
vote
1
answer
431
views
IEEE754Compatible=true doesn't return int64s in string format in ASP.NET Core OData 8
According to the spec, OData v4 services should return int64 and decimal types in string format when IEEE754Compatible=true is included in the Content-Type request header in the Accept request header ...
0
votes
1
answer
170
views
ASP.NET Core OData response json serialization nullvalue handling
Consider two endpoints exposing data as OData.
The first in an ODataController:
private static readonly string[] Summaries = new[]
{
"Freezing", "Bracing", "Chilly", &...
0
votes
0
answers
216
views
Odata $count and Search by Entity Id Not Working in Dot Net 6
Odata Count is not supporting, not sure what is missing.
https://localhost:7080/odata/Person?$count
Microsoft.OData.ODataException: The value for OData query '$count' cannot be empty.
at Microsoft....
1
vote
0
answers
375
views
OData Query parameters are not working in 8.2.3
We have migrated our API from 2.2 to 6.0 and we are upgraded OData also to 8.2.3.
Before update custom methods with query parameters are working well but after update no luck.
Basic OData methods and ...
2
votes
0
answers
74
views
.NET Core OData: override the entity set routing convention for navigation key
In non-Core project with Microsoft.AspNet.OData package, it was possible to override
SelectAction(ODataPath odataPath, HttpControllerContext context, ILookup<string, HttpActionDescriptor> ...
0
votes
1
answer
382
views
Get data from Odata service Business Central
I want to consume Business Central Odata service from ASP.NET project.
This is Odata URI: http://windowsbc:7048/BC230/ODataV4/Company('Copia%20Cronus')/Power_BI_Vendor_List
This is result in Postman:
&...
0
votes
1
answer
57
views
API implemented using ODataController does not return the complete object in output
I have implemented an API using the ODataController
When I hit the API at https://localhost:4046/v1/Search, I am only able to get the backupId and count in the GranularSeachResult object. The ...
0
votes
1
answer
60
views
How to replace a service provider configured in odata AddRouteComponents in integration test?
I've already known how to replace a service in asp.net core in integration test as per:
replace-service-with-mocked-using-webapplicationfactory
But the added services when AddRouteComponents() seem to ...
0
votes
1
answer
258
views
Only include certain fields from expanded entity
I have an asp.net core project with Microsoft.AspNetCore.OData 8.2.3 on top of Entity Framework Core. My entities are Order and Customer which have a relation.
I can successfully load my Orders with ...
1
vote
0
answers
94
views
ASP.NET Core OData 8.0 sub child collection convention
I`m trying to create a get/patch/Post Action for a sub child items for OData controller.
The endpoint I want to create is:
/odata/Documents(1)/Lines(1)/SubLines
Here is the entity:
public class ...
1
vote
1
answer
133
views
Nullable foreign key causes runtime error in OData service
I'm using OData in an ASP.NET Core Web API.
I have the following entities:
public class Equipment
{
[Key]
public long EquipmentId { get; set; }
[Required]
public string EquipmentCode { ...
0
votes
1
answer
301
views
Expand navigation property of owned type OData EF Core
I have the following entities:
[Table("tblA")]
public class EntityA
{
[Key]
public int ID { get; set; }
[Required]
public virtual EntityB EntityB { get; set; }
}
[Owned]
...
1
vote
0
answers
135
views
Getting 405 response on OData API Controller
Currently the Get() request is working as expected but Post() is giving me 405 response. I am using .NET 7.0 with OData 8. This is running on localhost no CORS but added the permissive CORS policy ...
0
votes
1
answer
201
views
OData8 aggregate multiple count on nested Entities
I am trying to find the best solution to get the count and sum of large relational db using AspNetCore EntityFramework and/or OData8.
I have the following Entity models
public class Entity1
{
...
1
vote
0
answers
158
views
I cannot map certain fields (FormattedValues) from the OData service using the OData Client in the .NET 7
I'm querying the Dataverse OData API server using the Microsoft.OData.Client.
I made a class which inherits DataServiceContext and I have property which represents Entity Set that I query.
That works ...
2
votes
1
answer
613
views
.NET core OData web API PATCH/POST request - complex properties missing in response
I have a requirement to return the entire updated entity from .net core OData web API after executing a PATCH/POST request.
But with below code, I'm getting response object containing only primitive ...
0
votes
1
answer
247
views
Adding OData to ASP.NET Core web app and make use of both a ODataBatchHandler and the service configuration
I am using OData in an ASP.NET Core (.NET 6) web app
At first, I needed a way to output CSV (for data exporting feature) and found this great guide, it worked by doing so in Program.cs, the magic is ...
4
votes
0
answers
222
views
OData 8 - Custom routing with named parameters that do not care about order
In the .NET Framework 4.8 version of the API I'm working on, I could specify the routing to an endpoint as so:
[ODataRoute("/myEndpoint(FirstName={firstName},LastName={lastName})/Data")]
...
0
votes
1
answer
86
views
new List of Class object gives System.NullReferenceException
I am upgrading my project from ASP.NET 4.8 to ASP.NET Core 6.0. The code below works fine for ASP.NET, but gives an error for Core. I am not sure why. I have tried many different ways to solve it, ...
0
votes
2
answers
670
views
.Net Core OData 8.0 endpoint lowercaseand custom name
is it possible to set any name for an OData endpoint? I can't figure it out, I found some examples of routing to lowercase, but that's not what I need right now. Here is a working example that exposes ...
0
votes
1
answer
1k
views
.NET 7.0 - OData 8.0 versioning not show in swagger
I added OData to my project and tested some scenarios. I got stuck on adding versioning to OData, but I eventually added it without any major issues. Now, I can call the endpoint with the version ...
0
votes
1
answer
945
views
OData batch in asp.net core 7
I'm trying to implement batching in my api by leveraging the OData batch endpoint. Please note that I'm not interested in using OData query/select/etc. Just use the batch endpoint to batch queries/...
0
votes
1
answer
520
views
Conflicting method/name for an OData Endpoint
My program.cs looks like below:
.
.
builder.Services.AddControllers()
.AddOData(options =>
{
options.Select().Count().AddRouteComponents(WeatherEDM.GetEdmModel());
});
.
.
.
app.UseEndpoints(...
0
votes
1
answer
301
views
There is a way to set entities dynamically based on model string name in odata asp net core web api?
I am trying to register entities dynamically in odata based on string name or variable types.
var modelBuilder = new ODataConventionModelBuilder();
modelBuilder.EntitySet<Employee>(&...