Open Closed

RemoveRange #918


0
eu11111 created

How should I implement removerange using the defaul IRepository?

Thanks in advance.


1 Answer(s)
  • 0
    hikalkan created

    Hi,

    You may add an extension method to IRepository<TEntity, TPrimaryKey> interface. But extension methods are limited since they can only use public interface.

    You may create a repository base (and interface) for your app (http://www.aspnetboilerplate.com/Pages/ ... ppBaseRepo), in that case, you should define custom repositories (http://www.aspnetboilerplate.com/Pages/ ... oryMethods) for your entities (which derives from your custom interface/repository base).

    But.. if you want that it directly added to IRepository.. it's possible but a little tricky. You can write an extension method, then cast repository to efrepositorybase, then get it's Context property and work directly on dbcontext. But since Context is protected, you need to use reflection.