Sybase ASE 16x 和 .NET Core 1.1 进行 SP 调用
Sybase ASE 16x and .NET Core 1.1 making a SP call
我正在使用 Visual Studio 2017 (v 15.2)。核心 1.1 并使用 Sybase ASE 16.0 sp2。我还在 Sybase SDK 16.0.
中使用 Sybase.AdoNet4.AseClient.dll
public IEnumerable<Countries> GetCountry()
{
var con = new AseConnection(ConnectionString); // No Errors
var cmd = con.CreateCommand(); // Error described below
return null;
}
CreateCommand()
在 IDE (红色波浪线)中生成以下内容:
The type 'Db Connection is defined in an assembly that is not referenced. You must add a reference to assembly 'system.Data, Version=4.0.0.0, Culture=neutral, PublicKey=b77a5c561934e089'
我按 PackageManger 加载
- install-package System.Data.Common -version 4.1.0,加载但错误仍然存在。
- install-package System.Data.Common -version 4.3.0,加载但错误仍然存在。
- 已尝试安装 安装包 System.Data.Common - 版本 4.0.0,
但出现错误(如下所示):
- 尝试安装 install-package System.Data.Common -version
4.0.0.0,但得到上面相同的错误(如下所示):
安装包:包恢复失败。回滚 'iKYC.API' 的包更改。
在 line:1 char:16
+ 安装包 <<<< System.Data.Common - 版本 4.0.0
+ CategoryInfo : NotSpecified: (:) [Install-Package], 异常
+ FullyQualifiedErrorId:NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPacka
geCommand
我没有加载 EntityFrame 工作,因为这是 Sybase。 Sybase 是我唯一可以使用的数据库。
我建立了一个项目来测试这个,有趣的是,如果你定位
.net core 2.0
而不是 1.1
它将构建。
但是,这会导致运行时错误System.MissingMethodException
,因为驱动程序正在寻找.net core 中尚不存在的方法(和命名空间?) .
原因是 Sybase.AdoNet4.AseClient.dll
针对 .net framework 4,而不是 .net core。它甚至在文件名中暗示它 (AdoNet4
)。
目前看来,此驱动程序与 .net 核心不兼容。也许有一天,当缺失的方法被移植到 .net core 时......它可能会起作用?
幸运的是,有几种选择:
- 使用
System.Data.Odbc
namespace/package。 System.Data.Odbc
目前处于预发布阶段,目标是 .net core 2.0+
。如果您被束缚在 .net core 1.1
,可能不适合您。
- 就我个人而言,我已经弄乱了
System.Data.Odbc
包,虽然它可以处理简单的东西,但我遇到了一些问题。特别是,似乎没有任何方法可以从工作的存储过程中获取 return 值,并且缺乏对命名参数的支持(我认为是 ODBC
的东西),使得工作变得困难与.
- 使用
AdoNetCore.AseClient
namespace/package. After a lot of frustration, I bit the bullet and working on an ADO.NET
driver which targets .net core 1.0
, 1.1
, 2.0
, and .net framework 4.6
. If you want to view the sources/documentation and figure out if it's the right fit for you, it's available on github。
- 要使用此驱动程序,只需引用包并将
using Sybase.Data.AseClient;
替换为 using AdoNetCore.AseClient;
。
我正在使用 Visual Studio 2017 (v 15.2)。核心 1.1 并使用 Sybase ASE 16.0 sp2。我还在 Sybase SDK 16.0.
中使用 Sybase.AdoNet4.AseClient.dllpublic IEnumerable<Countries> GetCountry()
{
var con = new AseConnection(ConnectionString); // No Errors
var cmd = con.CreateCommand(); // Error described below
return null;
}
CreateCommand()
在 IDE (红色波浪线)中生成以下内容:
The type 'Db Connection is defined in an assembly that is not referenced. You must add a reference to assembly 'system.Data, Version=4.0.0.0, Culture=neutral, PublicKey=b77a5c561934e089'
我按 PackageManger 加载
- install-package System.Data.Common -version 4.1.0,加载但错误仍然存在。
- install-package System.Data.Common -version 4.3.0,加载但错误仍然存在。
- 已尝试安装 安装包 System.Data.Common - 版本 4.0.0, 但出现错误(如下所示):
- 尝试安装 install-package System.Data.Common -version 4.0.0.0,但得到上面相同的错误(如下所示):
安装包:包恢复失败。回滚 'iKYC.API' 的包更改。 在 line:1 char:16 + 安装包 <<<< System.Data.Common - 版本 4.0.0 + CategoryInfo : NotSpecified: (:) [Install-Package], 异常 + FullyQualifiedErrorId:NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPacka geCommand
我没有加载 EntityFrame 工作,因为这是 Sybase。 Sybase 是我唯一可以使用的数据库。
我建立了一个项目来测试这个,有趣的是,如果你定位
.net core 2.0
而不是 1.1
它将构建。
但是,这会导致运行时错误System.MissingMethodException
,因为驱动程序正在寻找.net core 中尚不存在的方法(和命名空间?) .
原因是 Sybase.AdoNet4.AseClient.dll
针对 .net framework 4,而不是 .net core。它甚至在文件名中暗示它 (AdoNet4
)。
目前看来,此驱动程序与 .net 核心不兼容。也许有一天,当缺失的方法被移植到 .net core 时......它可能会起作用?
幸运的是,有几种选择:
- 使用
System.Data.Odbc
namespace/package。System.Data.Odbc
目前处于预发布阶段,目标是.net core 2.0+
。如果您被束缚在.net core 1.1
,可能不适合您。- 就我个人而言,我已经弄乱了
System.Data.Odbc
包,虽然它可以处理简单的东西,但我遇到了一些问题。特别是,似乎没有任何方法可以从工作的存储过程中获取 return 值,并且缺乏对命名参数的支持(我认为是ODBC
的东西),使得工作变得困难与.
- 就我个人而言,我已经弄乱了
- 使用
AdoNetCore.AseClient
namespace/package. After a lot of frustration, I bit the bullet and working on anADO.NET
driver which targets.net core 1.0
,1.1
,2.0
, and.net framework 4.6
. If you want to view the sources/documentation and figure out if it's the right fit for you, it's available on github。- 要使用此驱动程序,只需引用包并将
using Sybase.Data.AseClient;
替换为using AdoNetCore.AseClient;
。
- 要使用此驱动程序,只需引用包并将