Search code examples
c#entity-frameworkentity-framework-4repository-patternentity-framework-ctp5

How to implemented this using Repository Pattern (or something more appropriate)?


I have a repository called: IChocolateRepository

It derives from a generic repository interface IRepository<> which defines basic repository functions (FindAll, Delete, Add, etc.)

Now, I need to write a piece of code which will go and delete 'all chocolates from the database with expiry data before a supplied date' (assuming that ExpiryDate is a non-nullable property on the Chocolate model class.)

Does this belong in the repository?

Also, how would a sample implementation look like? (I am using EF CTP5)


Solution

  • I don't think so.

    This does not belong in the Repository but in a class that operates the Transactions using these Repositories.

    Unless this is just too simple application where avoiding a separate layer to avoid complexity would be much better.