Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

RemoveRange #918


User avatar
0
eu11111 created

How should I implement removerange using the defaul IRepository?

Thanks in advance.


1 Answer(s)
  • User Avatar
    0
    hikalkan created
    Support Team

    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 (<a class="postlink" href="http://www.aspnetboilerplate.com/Pages/Documents/EntityFramework-Integration#DocAppBaseRepo">http://www.aspnetboilerplate.com/Pages/ ... ppBaseRepo</a>), in that case, you should define custom repositories (<a class="postlink" href="http://www.aspnetboilerplate.com/Pages/Documents/EntityFramework-Integration#DocCustomRepositoryMethods">http://www.aspnetboilerplate.com/Pages/ ... 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.