简体   繁体   English

Microsoft.SqlServer.Types是做什么的,它是如何工作的?

[英]What does Microsoft.SqlServer.Types do, and how does it work?

I am being told to use Microsoft.SqlServer.Types for DbGeography in a homework project I have. 有人告诉我在我的家庭作业项目DbGeography Microsoft.SqlServer.Types用于DbGeography The homework project is with ASP.NET, and is trying to use a database to do a search on stuff in the db. 家庭作业项目使用ASP.NET,并且正在尝试使用数据库对db中的内容进行搜索。 (The database is supposed to be from a .bak file, but I had to upload a .bacpac file into azure and then connect back to it, since the .bak file keeps saying it's corrupt). (该数据库应该来自.bak文件,但是我不得不将.bacpac文件上传到azure中,然后再连接回它,因为.bak文件一直在说它已损坏)。

This is a code block that I have been told to put into the Global.asax.cs file: 这是我被告知放入Global.asax.cs文件中的代码块:

protected void Application_Start()
{
    // For Spatial types, i.e. DbGeography
    SqlServerTypes.Utilities.LoadNativeAssemblies(Server.MapPath("~/bin"));
    // This next line is a fix that came from:       https://stackoverflow.com/questions/13174197/microsoft-sqlserver-types-version-10-or-higher-could-not-be-found-on-azure/40166192#40166192
    SqlProviderServices.SqlServerTypesAssemblyName = typeof (SqlGeography).Assembly.FullName;

    AreaRegistration.RegisterAllAreas();
    FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
    RouteConfig.RegisterRoutes(RouteTable.Routes);
    BundleConfig.RegisterBundles(BundleTable.Bundles);
}

I have looked at the documentation , and the darned thing just says: 我看了看文档 ,胆怯的东西只是说:

Microsoft.SqlServer.Types Microsoft.SqlServer.Types

Allows you to use SQL Server spatial types on a machine without SQL Server installed. 允许您在未安装SQL Server的计算机上使用SQL Server空间类型。 Enables Entity Framework spatial types to be used (DbGeography and DbGeometry). 启用要使用的实体框架空间类型(DbGeography和DbGeometry)。

Which I think just means that this package enables us to use c expression for SQL, but I would like a better explanation. 我认为这只是意味着该软件包使我们能够将c表达式用于SQL,但我希望有一个更好的解释。 I have no clue what DbGeography and DbGeometry do. 我不知道DbGeographyDbGeometry做什么。

Additionally, I would like to know if this is applicable to an azure-based db, and not just a local db made from a .bak file. 另外,我想知道这是否适用于基于天蓝色的数据库,而不仅是由.bak文件制成的本地数据库。

I have no clue what DbGeography and DbGeometry do. 我不知道DbGeography和DbGeometry做什么。

It's simple. 这很简单。 SQL Server has spatial types . SQL Server具有空间类型 .NET does not. .NET没有。

Microsoft.SqlServer.Types is a library you can add to your .NET project to work with SQL Server geography and geometry data types in your .NET project. Microsoft.SqlServer.Types是一个库,您可以将其添加到.NET项目中,以与.NET项目中的SQL Server geographygeometry数据类型一起使用。 Without this library you can only read and write SQL Server spatial types by converting them to text in the WKT format. 没有此库,您只能通过将SQL Server空间类型转换为WKT格式的文本来读取和写入SQL Server空间类型。

For most of the other data types supported by SQL Server there's a corresponding .NET type that works. 对于SQL Server支持的大多数其他数据类型,有一个适用的.NET类型。 Eg SQL Server has int .NET has System.Int32 , etc. 例如,SQL Server具有int .NET具有System.Int32等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ASP NET Core中的Microsoft.SqlServer.Types - Microsoft.SqlServer.Types in ASP NET Core 应用程序无法加载Microsoft.SqlServer.Types版本13 - Application cannot load Microsoft.SqlServer.Types Version 13 检索多边形几何对象(Microsoft.SqlServer.Types)并获取有关坐标的信息 - Retrieve a polygon Geometry object(Microsoft.SqlServer.Types) and get the information about the coordinates Microsoft.SqlServer.Types:加载msvcr120.dll时出错(ErrorCode:5) - Microsoft.SqlServer.Types: Error loading msvcr120.dll (ErrorCode: 5) C#MVC无法加载文件或程序集'Microsoft.SqlServer.Types - C# MVC Could not load file or assembly 'Microsoft.SqlServer.Types 无法加载文件或程序集“Microsoft.SqlServer.Types, Version=12.0.0.0, Culture=neutral, PublicKeyToken=myKey”或其依赖项之一。 - Could not load file or assembly 'Microsoft.SqlServer.Types, Version=12.0.0.0, Culture=neutral, PublicKeyToken=myKey' or one of its dependencies. 在Microsoft Ajax中,$ find究竟做了什么? - In Microsoft Ajax, what exactly does $find do? IIS 由什么组成,它是如何工作的? - What does IIS consist of and how does it work? Microsoft.SqlServer.Types.SqlGeography 反序列化错误 - Microsoft.SqlServer.Types.SqlGeography Deserialize Error Microsoft.Extensions.Logging 如何为完整的 .net 框架工作? - How does Microsoft.Extensions.Logging work for full .net framework?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM