Servicestack MultiTenancy

时间:2016-06-15 07:45:26

标签: servicestack ormlite-servicestack

我安装了ServiceStack v4.0.60,并且正在按照以下方式在AppHost配置中查找ChangeDb:

container.Register<IDbConnectionFactory>(c => 
    new OrmLiteConnectionFactory(defaultDbConn, SqlServer2012Dialect.Provider));

var dbFactory = container.Resolve<IDbConnectionFactory>();

//Register NamedConnection
dbFactory.RegisterConnection("Reporting", ReportConnString, PostgreSqlDialect.Provider);

//Register DialectProvider
dbFactory.RegisterDialectProvider("Sqlite", SqliteDialect.Provider);

然而,Visual Studio告诉我'RegisterConnection'和'RegisterDialectProvider'不是IDbConnectionFactory的一部分。我错过了什么?

1 个答案:

答案 0 :(得分:1)

它不属于IDbConnectionFactory,但它位于OrmLiteConnectionFactory,因此您需要引用具体类型,例如:

var dbFactory = new OrmLiteConnectionFactory(defaultDbConn, SqlServer2012Dialect.Provider);
container.Register<IDbConnectionFactory>(dbFactory);

//Register NamedConnection
dbFactory.RegisterConnection("Reporting", ReportConnString, PostgreSqlDialect.Provider);

//Register DialectProvider
dbFactory.RegisterDialectProvider("Sqlite", SqliteDialect.Provider);