Appropriate lifecycle for repository classes using Castle Windsor

后端 未结 2 723
暖寄归人
暖寄归人 2020-12-21 19:15

When I started with Windsor I thought DI would be simple. Now it\'s causing me more and more confusion.

A repository strikes me as a class with a singleton lifecycle

2条回答
  •  我在风中等你
    2020-12-21 19:18

    Rule of thumb is - component should not depend on other components that will outlive it.

    In other words, it's ok for transient to depend on singleton, or per-web-request component, but not the other way around.

    The way I approach Repository - UoW scenario is my UoW is per web request, but repositories are stateless and transient.

提交回复
热议问题