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

Idia on what's the best way to support custom reposity? #95

Open
DmitrijOkeanij opened this issue Dec 18, 2018 · 3 comments
Open

Idia on what's the best way to support custom reposity? #95

DmitrijOkeanij opened this issue Dec 18, 2018 · 3 comments

Comments

@DmitrijOkeanij
Copy link

DmitrijOkeanij commented Dec 18, 2018

Now code.

 // what's the best way to support custom reposity?
        if (hasCustomRepository)
        {
            var customRepo = _context.GetService<IRepository<TEntity>>();
            if (customRepo != null)
            {
                return customRepo;
            }
        }

But mabe to check it automatic like TryGetService on HasCustom Check?

  1. Check if Custom is in _context.GetService
  2. If yes - return it.
  3. If no - return new default.

Because user can dont know is there custom or not. He just want to get Repository Service.

@rigofunc
Copy link
Member

You mean remove the hasCustomRepository parameter?

@DmitrijOkeanij
Copy link
Author

DmitrijOkeanij commented Dec 18, 2018

Mabe to make it true as default?
Or rename to forceGetDefault = false.

Or mabe to make 2 functions.
If I register MyCustomRepository I want to use it in most cases. Every time call GetRepositor with additional parameters for my opinion is unclear and more big code.

@rigofunc
Copy link
Member

In the previous version, the code var customRepo = _context.GetService<IRepository<TEntity>>(); will throw exception if no custom repository. If the new version return null rather than throw exception, I think remove the parameter is good idea

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

No branches or pull requests

2 participants