OData / OData/AspNetCoreOData

OData response gets truncated when using query features

Open
#403 3 comments 0 reactions 2 assignees View on GitHub

@xuzhg is already working on this.

Since Dec 14, 2021.

investigating
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:
image

With select query parameter:
image

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.