Skip to content

Minimal Api does not work $search #1558

Description

@AndrewTheWild

net9.0 - "Microsoft.AspNetCore.OData" Version="9.4.1"

**
I have minimal api controller

    .MapGet("", (
        HttpContext context,
        IApplicationDbContext dbContext,
        ODataQueryOptions<Category> queryOptions,
        CancellationToken _) =>
    {
        var userId = context.User.FindFirst(ClaimTypes.NameIdentifier)?.Value;

        var baseQuery = dbContext.Category
            .Where(c => c.OwnerId == new Guid(userId));

        var b = context.RequestServices.GetService<ISearchBinder>();

        return queryOptions.ApplyTo(baseQuery);
    })
    .WithODataResult();

and next odata settings

     .AddOData(opt =>
         opt.EnableQueryFeatures()
             .AddRouteComponents("api/v{version:apiVersion}/odata", edmModel,
                 s => s.AddSingleton<ISearchBinder, TableSearchBinder>()));

All query features is working except $search. I implemted ISearchBinder and regitered it, but it does not help, this binder dont work
public class TableSearchBinder : QueryBinder,ISearchBinder

Does it expect behavior or OData does not support minimal api fully?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions