gpt4 book ai didi

.net - System.Data.SQLite 与 Microsoft.Data.Sqlite

转载 作者:行者123 更新时间:2023-12-03 17:31:43 25 4
gpt4 key购买 nike

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

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

一个比另一个有什么优势?

最佳答案

System.Data.SQLite 的一个优点是它是由 SQLite 团队开发的,该团队已声明长期致力于支持它。
Microsoft.Data.Sqlite 的一个优点是它是由 Microsoft 开发的,并且可以假设它已通过 Entity Framework、.NET Core 等进行了良好的测试。
我为我的项目选择了 System.Data.SQLite,原因之一是我使用了 Microsoft.Data.Sqlite 中“不支持”的 GetBytes() DataReader 方法。
我没有测试过性能,但是如果 Microsoft.Data.Sqlite 获胜,我不会感到惊讶,因为它声称是一个更薄的包装器。见下文。
此处 Microsoft.Data.Sqlite 开发人员之一 Brice Lambson 发表了一篇内容丰富的评论:https://www.bricelam.net/2018/05/24/microsoft-data-sqlite-2-1.html#comment-3980760585
他说,

"There are three main differences between Microsoft.Data.Sqlite andSystem.Data.SQLite.

"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 wasto create a lighter-weight, modernized version of .NET. That goal of.NET Core has largely been abandoned in favor of adding as many APIsas possible to make it easier to port from other .NET runtimes.However, the goal of Microsot.Data.Sqlite is still just to provide abasic ADO.NET implementation sufficient to support modern data accessframeworks like EF Core, Dapper, etc. We tend not to add API forthings that can be done using SQL. For example, see this comment forSQL alternatives to connection string keywords.

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

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

关于.net - System.Data.SQLite 与 Microsoft.Data.Sqlite,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52687402/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com