How do read-only database views fit into the repository pattern?

后端 未结 3 960
北恋
北恋 2020-12-23 12:37

Example: Your database has a SQL view named \"CustomerOrdersOnHold\". This view returns a filtered mix of specific customer and order data fields. You need to fetch data fro

3条回答
  •  醉梦人生
    2020-12-23 13:06

    I would prefer separating the read repository, preferably even change its name to Finder or Reader, the repository is meant for Domain usage not for querying read-only data, you can refer to this article and this which explains the usage of Finder separated form repository.

    I would recommend also the separating of read model from write model architecture CQRS and there

    This architecture allows you to separate the read model from write model even in terms of data storage and the use of event sourcing.

    For a middle solution you can utilize some CQRS concepts without the complexity of separating database by just separating repository from finders, read this post

    for a sample of this type of solution (use the same database but separating finders form repositories) check this sample

提交回复
热议问题