ServiceStack.Data.IDbConnectionFactory 中没有名为 open 的扩展方法
No extension method called open in ServiceStack.Data.IDbConnectionFactory
我想使用 servicestack.ormlite 连接到 database.But 即使在添加来自 Nuget 的引用后我仍然收到此错误。
我用这个命令安装
Install-Package ServiceStack.OrmLite.SqlServer
这是抛出的错误
'ServiceStack.Data.IDbConnectionFactory' does not contain a
definition for 'Open' and no extension method 'Open' accepting a first
argument of type 'ServiceStack.Data.IDbConnectionFactory' could be
found (are you missing a using directive or an assembly
reference?)
var dbFactory = new OrmLiteConnectionFactory(connectionString, SqliteDialect.Provider);
//I get error when I call open method
using (IDbConnection db = dbFactory.Open())
{
}
您确定扩展方法 Open 不接受任何参数吗?
我在 git 上检查了 OrmLiteConnectionFactory Extensions 的源代码,没有名称为 Open for OrmLiteConnectionFactory 的扩展方法没有参数。
OrmLiteConnectionFactory 的扩展方法 Open 接受一个字符串参数 "nammedconnection".
以下是gitlink的源码。
https://github.com/ServiceStack/ServiceStack.OrmLite/blob/master/src/ServiceStack.OrmLite/OrmLiteConnectionFactory.cs
所以我确信使用适当的参数调用 Open 会解决您的问题。
感谢和问候,
Chetan Ranpariya
IDbConnectionFactory.Open()
扩展方法在 OrmLiteConnectionFactoryExtensions 中定义,在 ServiceStack.OrmLite
命名空间下定义,因此您需要导入:
using ServiceStack.OrmLite;
我想使用 servicestack.ormlite 连接到 database.But 即使在添加来自 Nuget 的引用后我仍然收到此错误。
我用这个命令安装
Install-Package ServiceStack.OrmLite.SqlServer
这是抛出的错误
'ServiceStack.Data.IDbConnectionFactory' does not contain a definition for 'Open' and no extension method 'Open' accepting a first argument of type 'ServiceStack.Data.IDbConnectionFactory' could be found (are you missing a using directive or an assembly reference?)
var dbFactory = new OrmLiteConnectionFactory(connectionString, SqliteDialect.Provider);
//I get error when I call open method
using (IDbConnection db = dbFactory.Open())
{
}
您确定扩展方法 Open 不接受任何参数吗?
我在 git 上检查了 OrmLiteConnectionFactory Extensions 的源代码,没有名称为 Open for OrmLiteConnectionFactory 的扩展方法没有参数。 OrmLiteConnectionFactory 的扩展方法 Open 接受一个字符串参数 "nammedconnection".
以下是gitlink的源码。 https://github.com/ServiceStack/ServiceStack.OrmLite/blob/master/src/ServiceStack.OrmLite/OrmLiteConnectionFactory.cs
所以我确信使用适当的参数调用 Open 会解决您的问题。
感谢和问候, Chetan Ranpariya
IDbConnectionFactory.Open()
扩展方法在 OrmLiteConnectionFactoryExtensions 中定义,在 ServiceStack.OrmLite
命名空间下定义,因此您需要导入:
using ServiceStack.OrmLite;