There is Campaign Entity and for that, I have CampaignRepository which have this functions
Here is how I would do this:
class Campaigns{
IEnumerable All(){...}
IEnumerable ByNumber(int number){...}
IEnumerable CreatedToday(){...}
IEnumerable CreatedThisMonth(){...}
IEnumerable CreatedThisYear(){...}
IEnumerable Latest5(){...}
private IQueryable GetSomething(Something something){
//used by public methods to dry out repository
}
}
Reasoning is simple - it matters by what You are interested to look for campaigns (that knowledge is part of Your domain). If we explicitly state functions to reflect that, we will always know it.
Is it appropriate to add all this methods in campaign repository ?
I don't see anything wrong with that.
Arnis i want some code, how u implementing Created today function in domain itself, Are you injecting repository here in this function ? Thanks for your cooperation
I wouldn't implement CreatedToday function in my domain. It would sit in repository and repository implementations should not be concern of domain. If You mean how I would use Campaign repository and if it should be used from domain - no, it should not be used from within of domain. If You mean if I would inject repository inside of repository - You are listening too much of xzibit.