Open Closed

RemoveRange #918

eu11111 created

How should I implement removerange using the defaul IRepository?

Thanks in advance.

1 Answer(s)
  • 0
    hikalkan created
    Support Team


    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 (<a class="postlink" href=""> ... ppBaseRepo</a>), in that case, you should define custom repositories (<a class="postlink" href=""> ... oryMethods</a>) 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.