c# - Microsoft.SqlServer.Types 与 .NET 标准不兼容
问题描述
我正在尝试将我们所有的 C# 类库从 .NET Framework 转换为 .NET Standard 项目,因为我们开始利用 .NET Core,因此需要这些可以被 .NET Core 和 .NET Framework 应用程序使用(使用后者将在未来几个月内移植到 Core。)
我在转换我们的数据访问层代码时遇到了麻烦,因为我们广泛利用了 Microsoft.SqlServer.Types,而官方的 NuGet 包不支持 .NET Standard。我尝试了dotmorten 的非官方 NuGet 包,但它缺少很多功能。下面是我们需要的所有缺失的列表(放在一起以获得代码构建......)
public static class SqlMockExtensions
{
public static SqlBytes STAsBinary(this SqlGeography geography) => throw new NotImplementedException();
public static SqlGeography MakeValid(this SqlGeography geography) => throw new NotImplementedException();
public static int STDimension(this SqlGeography geography) => throw new NotImplementedException();
public static bool STIsValid(this SqlGeography geography) => throw new NotImplementedException();
public static Nullable<double> EnvelopeAngle(this SqlGeography geography) => throw new NotImplementedException();
public static SqlGeography ReorientObject(this SqlGeography geography) => throw new NotImplementedException();
public static SqlGeography BufferWithTolerance(this SqlGeography geography, double arg1, int arg2, bool arg3) => throw new NotImplementedException();
public static SqlGeography Reduce(this SqlGeography geography, double tolerance) => throw new NotImplementedException();
public static SqlGeography EnvelopeCenter(this SqlGeography geography) => throw new NotImplementedException();
public static double STDistance(this SqlGeography geography, SqlGeography point2) => throw new NotImplementedException();
public static SqlBytes STAsBinary(this SqlGeometry geometry) => throw new NotImplementedException();
}
当我搜索其他试图将 Microsoft.SqlServer.Types 集成到他们的 .NET Core 和 Standard 项目中的人时,我看到提到包含官方 NuGet 包然后执行以下操作:
SqlServerTypes.Utilities.LoadNativeAssemblies(AppDomain.CurrentDomain.BaseDirectory);
但是,当您尝试将不符合 .NET Standard 的 NuGet 包添加到 .NET Standard 项目中时,它会出错,所以我不清楚这是一个解决方案。
这似乎是一个非常普遍的问题,必须有很多开发人员将 Microsoft.SqlServer.Types 用于 SqlGeography、SqlGeometry 等......并且正在移植到 .NET Standard。那么你们所有人是如何做到这一点的呢?
解决方案
对于它的价值,我们没有找到答案。
我们最终转向了 EF Core。
推荐阅读
- php - 显示 strtotime() 是否正确有效
- mysql - MYSQL - 如何在连接表中使用 LIKE 运算符?
- javascript - 如何在ag-grid的树数据中折叠子行元素后获取子行元素
- java - 子布局视图显示在父布局视图下方
- gulp - 从 gulp v3 更改为 v4 后,gulp.series 没有运行所有应用的任务
- php - 如何解决 OG:image 编码问题?
- python - 仅在生产时抛出“内部错误 500”的两个 Django 视图
- android - 如何基于onItemSelectedListener在textview中显示纺织品?
- ios - 将文本从单元格传输到下一个 VC 中的标签时,第一次打开 VC 时不会出现
- python - 使用类和排序时如何编写列表来更新文本文档?