Skip to content

How to ignore dependency injection arguments? #201

Description

@gcoda

Is there an easy way to make this work? Overloading breaks runtime DI, using IDbContextFactory<DataContext> ctx inside of HubInterface breaks Tapper.

[Hub]
public interface IInventoryHub
{
    Task<Shelf[]> GetShelves();
}

public class InventoryHub : Hub<IInventoryReceiver>
{
    public async Task<Shelf[]> GetShelves(IDbContextFactory<DataContext> ctx)
    {
        await using var db = await ctx.CreateDbContextAsync();
        var shelves = db.Shelves.ToArray();
        return shelves;
    }
}

Edit:
it is possible to use DI in constructor

public class InventoryHub(IDbContextFactory<DataContext> ctx) : Hub<IInventoryReceiver>, IInventoryHub

and it works, so not big deal

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions