System.Data.SQLite与Microsoft.Data.Sqlite [英] System.Data.SQLite vs Microsoft.Data.Sqlite

查看:1171
本文介绍了System.Data.SQLite与Microsoft.Data.Sqlite的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

System.Data.SQLite和Microsoft.Data.Sqlite有什么区别?

What are the differences between System.Data.SQLite and Microsoft.Data.Sqlite?

我了解System.Data.SQLite较旧,并且获得了.NETStandard支持在Microsoft.Data.Sqlite之后,但现在它们都支持.NETStandard 2。

I understand that System.Data.SQLite is older and got .NETStandard support after Microsoft.Data.Sqlite, but now both of them support .NETStandard 2.

一个相对于另一个有什么优势?

What are the advantages of one over the other?

推荐答案

System.Data.SQLite的一个优点是它是由SQLite团队开发的,他们表示将长期致力于保持其支持。

An advantage of System.Data.SQLite is that it is developed by the SQLite team who have stated a long-term commitment to keeping it supported.

Microsoft.Data.Sqlite的一个优点是它是由Microsoft开发的,可以假定已通过Entitity Framework,.NET Core等进行了很好的测试。

An advantage of Microsoft.Data.Sqlite is that it is developed by Microsoft and can be assumed to be well tested with Entitity Framework, .NET Core etc.

我为项目选择了System.Data.SQLite,原因之一是我使用了Microsoft.Data.Sqlite中不支持的GetBytes()DataReader方法。

I chose System.Data.SQLite for my project, one reason being that I use the GetBytes() DataReader method which is "not supported" in Microsoft.Data.Sqlite.

我尚未测试性能,但是如果Microsoft.Data.Sqlite获胜,这并不会让我感到惊讶,因为它声称是一个较薄的包装器。见下文。

I have not tested performance, however it would not surprise me if Microsoft.Data.Sqlite wins since it claims to be a thinner wrapper. See below.

这里是Microsoft.Data.Sqlite开发人员之一Brice Lambson的有益评论:

There is an informative comment by Brice Lambson, one of the Microsoft.Data.Sqlite developers here:

https://www.bricelam .net / 2018/05/24 / microsoft-data-sqlite-2-1.html#comment-3980760585

他说:有三个Microsoft.Data.Sqlite和System.Data.SQLite之间的主要区别。

He says, "There are three main differences between Microsoft.Data.Sqlite and System.Data.SQLite.

首先,我们不打算成为功能齐全的ADO.NET提供程序。 Microsoft.Data.Sqlite是为.NET Core 1.0创建的,当时的目标是创建更轻量级的.NET现代化版本。 .NET Core的目标在很大程度上已被放弃,而希望添加尽可能多的API,以便更轻松地从其他.NET运行时进行移植。但是,Microsot.Data.Sqlite的目标仍然只是提供一个足以支持现代数据访问框架(如EF Core,Dapper等)的基本ADO.NET实现。对于使用SQL可以完成的事情,我们倾向于不添加API 。例如,有关连接字符串关键字的SQL替代方法,请参见此注释。

"First, we don't aim to be a feature-complete ADO.NET provider. Microsoft.Data.Sqlite was created for .NET Core 1.0 when the goal was to create a lighter-weight, modernized version of .NET. That goal of .NET Core has largely been abandoned in favor of adding as many APIs as possible to make it easier to port from other .NET runtimes. However, the goal of Microsot.Data.Sqlite is still just to provide a basic ADO.NET implementation sufficient to support modern data access frameworks like EF Core, Dapper, etc. We tend not to add API for things that can be done using SQL. For example, see this comment for SQL alternatives to connection string keywords.

第二个大区别是我们与本地SQLite的行为更加接近。尝试弥补SQLite的任何古怪之处,例如System.Data.SQLite在列类型名称中添加了.NET语义,甚至还必须解析每个SQL语句,然后再将其发送到本机驱动程序以处理用于指定的自定义SQL语句结果的列类型不是直接来自表列(即SELECT子句中的表达式),而是包含SQLite仅支持四种基本类型(INTEGER,REAL,TEXT和BLOB)并实现ADO.NET API的事实。

"The second big difference is that we're much closer to the native SQLite behavior. We don't try to compensate for any of SQLite's quirkiness. For example, System.Data.SQLite adds .NET semantics to column type names. They even have to parse every SQL statement before sending it to the native driver to handle a custom SQL statement for specifying the column type of results not coming directly from a table column (i.e. expressions in the SELECT clause). Instead, we embrace the fact that SQLite only supports four primitive types (INTEGER, REAL, TEXT, and BLOB) and implement ADO.NET APIs in a way that helps you coerce values between these and .NET types.

最后,我们不是10年前写的。 :-)这使我们可以创建更多现代的API,这些API在现代惯用的C#中感觉更自然。用于注册用户定义函数的API就是最好的例子。

"Finally, we weren't written 10 years ago. :-) This allow us to create more modern APIs that feel more natural in modern, idiomatic C#. The API for registering user-defined functions is the best example of this."

这篇关于System.Data.SQLite与Microsoft.Data.Sqlite的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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