How to retrieve Domain Object from Repositories

后端 未结 3 1632
星月不相逢
星月不相逢 2020-12-19 11:48

I have a little problem understanding repository-domain object relation. Here is some information I know about domain design(they may also be wrong or not accurate). And wit

3条回答
  •  太阳男子
    2020-12-19 12:24

    I am trying to understand your query here. Some tips on how you can proceed. First of all the Domain should know the repository contracts and not the actual repository infrastructure. in other words, you may choose to have 3 class libs as follows

    1. XYZDomain (will know XYZRepository and make call on the appropriate methods of this interface)
    2. XYZRepository (contains Interface IXYZService interface)
    3. XYZSQLRepository(actual implementation of XYZRepository interfaces).

    Now it's up to you to choose where to inject XYZSQLRepository to the XYZDomain using Dependency injection.

    You can also try using eventing model to register these repositories if you want.

    Use a custom Service Locator to get the concrete objects

提交回复
热议问题