question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Custom repositories should override the default repositories

See original GitHub issue

We can create custom repositories easily. But even we create custom repository for a Person entitiy, we can still inject IRepository<Person>. That’s very good. But think that we overrided Delete method on the custom repository and changed delete logic a bit. What happens if we still use IRepository<Person> instead of custom IPersonRepository? Delete method will work as before. So, there will be 2 different Delete method implementations for same entity. This is dangerous!

So, while registering default repositories, we can check if there is a custom implementation and register IRepository<TEntity> as the custom repository.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:22 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
hikalkancommented, Sep 20, 2016

This can be done manually using Configuration.ReplaceService (http://www.aspnetboilerplate.com/Pages/Documents/Startup-Configuration#replacing-built-in-services) in module’s PreInitialize, as shown bloe:

Configuration.ReplaceService<IRepository<Post, Guid>>(() =>
{
    IocManager.IocContainer.Register(
        Component.For<IRepository<Post, Guid>, IPostRepository, PostRepository>()
            .ImplementedBy<PostRepository>()
            .LifestyleTransient()
    );
});

I decided to not do it automatically, because we may have more than one dbcontext containing the same entity and we may have more than one custom repository implementation (for different dbcontextes) and ABP can not know which implementation to be used.

Read more comments on GitHub >

github_iconTop Results From Across the Web

When creating a yum repo in Red Hat Satellite 6, can it be ...
The custom product has many individual repositories already created under it. If a new repository is created, it is Enabled by default in...
Read more >
Manage custom repositories - HCL Product Documentation
Use the RHEL Custom Repository Management dashboard to register and manage standard ... Disable custom repository support - Red Hat Enterprise Linux.
Read more >
[SOLVED] Prevent yum to change the content of /etc/ ...
Dear All, In my /etc/yum.repos.d directory, the default .repo files (e.g. CentOS-Base.repo) are replaced by custom files pointing to a local ...
Read more >
Setting repository visibility
Organization owners can restrict the ability to change repository visibility to organization owners only. For more information, see "Restricting repository ...
Read more >
Declaring repositories
Repositories with custom URLs can be specified as Maven or Ivy repositories by calling the corresponding methods available on the RepositoryHandler API.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found