-
Notifications
You must be signed in to change notification settings - Fork 847
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
多个 IFreeSql 实例,如何注入使用? #44
Labels
docs
This is a document
Comments
Closed
Closed
Closed
Closed
public void ConfigureServices(IServiceCollection services)
{
var fsql1 = new FreeSqlBuilder().UseConnectionString(DataType.MySql, "str1")
.Build<MySqlFlag>();
var fsql2 = new FreeSqlBuilder().UseConnectionString(DataType.MySql, "str1")
.Build<SqlServerFlag>();
services.AddSingleton<IFreeSql<MySqlFlag>>(fsql1);
services.AddSingleton<IFreeSql<SqlServerFlag>>(fsql2);
} 通过定义标识类的方式来注册多个FreeSql的实例,在本地开发是可用的,为什么部署在服务器上就无法使用? |
增加了一种基于配置的注入方式,可以参考:#1033 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
第一种方法:定义多个 IFreeSql
1、定义两个标识类:
2、在 Startup.cs 中单例注入
3、在 Controller 中使用
第二种方法:使用 FreeSql.Clound(推荐)
为 FreeSql 提供跨数据库访问,分布式事务TCC、SAGA解决方案,支持 .NET Core 2.1+, .NET Framework 4.0+.
开源地址:https://github.com/2881099/FreeSql.Cloud
or
FreeSqlCloud 的访问方式和 IFreeSql 一样:
切换数据库:
自动定向数据库配置:
The text was updated successfully, but these errors were encountered: