在基于 Servicestack 消息的设计中将连接传递到数据库的正确方法是什么
What is the proper way to pass the connection to the DB in a Servicestack message based design
我在决定如何将 OrmLiteConnectionFactory 传递给不同的 类 时遇到了问题。是否应该通过将容器注入构造函数来完成?如果重要的话,这是一个基于消息的设计。
基本上您只想将 "reference" 传递给您希望执行服务的连接。
ServiceStack 的 Multitenancy docs shows different approaches of specifying the DB connection to use per Request DTO message, including using a custom filter,或利用内置的 [ConnectionInfo]
或 [NamedConnection]
属性。
或者,如果您愿意,您可以通过 IDbConnectionFactory dependency.
来解析要与服务逻辑一起使用的数据库连接。
我在决定如何将 OrmLiteConnectionFactory 传递给不同的 类 时遇到了问题。是否应该通过将容器注入构造函数来完成?如果重要的话,这是一个基于消息的设计。
基本上您只想将 "reference" 传递给您希望执行服务的连接。
ServiceStack 的 Multitenancy docs shows different approaches of specifying the DB connection to use per Request DTO message, including using a custom filter,或利用内置的 [ConnectionInfo]
或 [NamedConnection]
属性。
或者,如果您愿意,您可以通过 IDbConnectionFactory dependency.
来解析要与服务逻辑一起使用的数据库连接。