Filters in DDD Repository

前端 未结 4 1102
遥遥无期
遥遥无期 2021-02-03 12:01

There is Campaign Entity and for that, I have CampaignRepository which have this functions

  1. public IList FindAll();
  2. public Campaign FindByCampaignNumber(st
4条回答
  •  无人及你
    2021-02-03 12:44

    You should be able to do all of the above with the following repository method:

    List findCampaigns(Date fromCreationDate, Date toCreationDate, int offset, Integer limit) {
    
       if (fromCreationDate != null) add criteria...
       if (toCreationDate != null) add criteria...
       if (limit != null) add limit...
    }
    

    This is how I do it and it works very well.

提交回复
热议问题