Microsoft.SqlServer.Types 与 .NET Standard 不兼容 [英] Microsoft.SqlServer.Types incompatible with .NET Standard

查看:40
本文介绍了Microsoft.SqlServer.Types 与 .NET Standard 不兼容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将我们所有的 C# 类库从 .NET Framework 转换为 .NET Standard 项目,因为我们开始利用 .NET Core,因此需要这些库可以被 .NET Core 和 .NET Framework 应用程序使用(后者将在未来几个月内移植到 Core.)

I'm attempting to convert all of our C# class libraries from .NET Framework to .NET Standard projects, as we are starting to leverage .NET Core so need these to be consumable by both .NET Core and .NET Framework apps (with the latter being ported over to Core in the upcoming months.)

我在转换数据访问层代码时遇到问题,因为我们广泛利用 Microsoft.SqlServer.Types 和 官方 NuGet 包 不支持 .NET Standard.我尝试了 dotmorten 的非官方 NuGet 包,但它是缺少很多功能.下面是我们需要的所有缺失的列表(拼凑起来构建代码......)

I'm having trouble converting our data access layer code because we leverage Microsoft.SqlServer.Types extensively and the official NuGet package doesn't support .NET Standard. I tried an unofficial NuGet package by dotmorten but it's missing a lot of functionality. Below is a list of everything missing that we would need (thrown together to get the code building...)

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();
}

当我搜索 SO 其他人试图集成 Microsoft 时.SqlServer.Types 到他们的 .NET Core 和 Standard 项目中,我看到提到包括官方 NuGet 包,然后做这样的事情:

When I search SO for others trying to integrate Microsoft.SqlServer.Types into their .NET Core and Standard projects, I see mentions of including the official NuGet package and then doing something like this:

SqlServerTypes.Utilities.LoadNativeAssemblies(AppDomain.CurrentDomain.BaseDirectory);

但是,当您尝试将不符合 .NET Standard 的 NuGet 包添加到 .NET Standard 项目时会出错,因此我不清楚这是如何解决的.

However, it errors when you try to add a non-.NET Standard compliant NuGet package into a .NET Standard project, so I'm not clear how this is a solution.

这似乎是一个非常普遍的问题,必须有很多开发人员利用 Microsoft.SqlServer.Types 进行 SqlGeography、SqlGeometry 等......并且正在移植到 .NET Standard.那么你们都是如何做到这一点的?

This seems like a very common problem to have, there have to be a lot of developers out there who leverage Microsoft.SqlServer.Types for SqlGeography, SqlGeometry, etc... and are porting over to .NET Standard. So how are all of you accomplishing this?

推荐答案

对于它的价值,我们没有找到答案.

For what it's worth, we did not find an answer.

我们最终转向了 EF Core.

We ended up moving to EF Core.

这篇关于Microsoft.SqlServer.Types 与 .NET Standard 不兼容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆