How should I implement removerange using the defaul IRepository?
Thanks in advance.
1 Answer(s)
-
0
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.