Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom method to a custom repository #140

Open
josemojena opened this issue Jun 20, 2020 · 2 comments
Open

Add custom method to a custom repository #140

josemojena opened this issue Jun 20, 2020 · 2 comments

Comments

@josemojena
Copy link

Hi, how I can add a custom method to the custom repository, now when I get the repository using
_unitOfWork.GetRepository<User>(hasCustomRepository: true) its impossible to get the custom methods available inside the UserRepository, always I have to convert it to UserRepository using something like this var userRepository = _unitOfWork.GetRepository<User>(hasCustomRepository: true) as UsersRepository; , so is there some way to get access to the custom methods without converting it manually

@issue-label-bot
Copy link

Issue-Label Bot is automatically applying the label feature_request to this issue, with a confidence of 0.61. Please mark this comment with 👍 or 👎 to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

@djechelon
Copy link
Contributor

djechelon commented Jan 7, 2021

I had to do a tricky and horrible alternative instead 🤢

I declared the custom repository as custom service and injected it

services.AddUnitOfWork<TContext>()
            .AddCustomRepository<TEntity, TEntityRepository>()
            .AddScoped(serviceProvider => (MyEntityRepository)serviceProvider.GetRequiredService<IRepository<TEntity>>());

Maybe you could create an extension method (edit: no you can't)

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

No branches or pull requests

2 participants