多数据库连接的一种注入方式
#1033
Replies: 1 comment 3 replies
-
这里似乎有语法错误 |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
参考 #44
如果针对数据库连接是以配置为主,并且在一个请求中需要同时操作多个数据库连接,MultiFreeSql 的实现就没有那么好用了。
针对此,可以参考以下代码:
对应的有一个配置:
基于此我们可以进行配置:
使用时首先需要先调用
AddFreeSql
进行依赖注入,例如.net 6
的ASP.NET Core
程序中:后面就是可以通过构造函数注入,或者直接在控制器中使用:
Beta Was this translation helpful? Give feedback.
All reactions