OData response gets truncated when using query features
@xuzhg is already working on this.
Since Dec 14, 2021.
- Dominant language
- C#
- Stars
- 505
- Forks
- 186
- PR merge metrics
- No merged PRs in 30d
Description
OData response gets truncated when using query features.
Microsoft.AspNetCore.OData version 8.0.4
Without query parameters:

With select query parameter:

Startup.cs
public void ConfigureServices(IServiceCollection services)
{
...
services.AddControllers(options =>
{
var policy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build();
options.Filters.Add(new AuthorizeFilter(policy));
}).AddNewtonsoftJson()
.AddOData(opt => opt.EnableQueryFeatures().AddRouteComponents("odata", GetEdmModel()));
...
}
private static IEdmModel GetEdmModel()
{
var builder = new ODataConventionModelBuilder();
var entitySetConfiguration = builder.EntitySet<GenericDocument>("Documents");
entitySetConfiguration.EntityType.HasKey(entity => entity.IdStr);
return builder.GetEdmModel();
}
DocumentsController
[HttpGet]
[EnableQuery]
public IActionResult Get()
{
return Ok(_service.GetAll());
}
Model
[BsonCollection("my_documents")]
public class GenericDocument : Document
{
public DateTime Date { get; set; }
public string SupplierName { get; set; }
public string SupplierAddress { get; set; }
public string SupplierIban { get; set; }
public string BuyerName { get; set; }
public string BuyerAddress { get; set; }
public string BuyerIban { get; set; }
public string ProductCode { get; set; }
public string ProductDescription { get; set; }
public float Quantity { get; set; }
public float Price { get; set; }
public string Value { get; set; }
public float TotalValueWithoutVat { get; set; }
public float Vat { get; set; }
public float Total { get; set; }
}
public abstract class Document : IDocument
{
public string IdStr => Id.ToString();
public ObjectId Id { get; set; }
public DateTime CreatedAt => Id.CreationTime;
}
What could be the problem?
Some of the links, that I've checked:
https://devblogs.microsoft.com/odata/routing-in-asp-net-core-8-0-preview/
https://jira.mongodb.org/browse/CSHARP-1771?focusedCommentId=4145551&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-4145551
https://www.learmoreseekmore.com/2021/07/intro-on-odata-v8-in-dotnet5-api.html
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.