设为首页 收藏本站
查看: 2062|回复: 0

[经验分享] .NET Core Data Access

[复制链接]

尚未签到

发表于 2017-7-1 19:08:33 | 显示全部楼层 |阅读模式
  .NET Core was released a few months ago, and data access libraries for most databases, both relational and NoSQL are now available. In this post, I’ll detail what client libraries are available, as well as show code samples for each of them.
ORM
EF Core
  Entity Framework is Microsoft’s Object-Relational Mapper for .NET, and as such is one of the most-used data access technologies for .NET. EF Core, released simultaneously with .NET Core, is a lightweight and extensible version of Entity Framework that works on both .NET Core and .NET Framework. It has support for Microsoft SQL Server, SQLite, PostgreSQL, MySQL, Microsoft SQL Server Compact Edition, with more, such as DB2 and Oracle, to come.
  What follows is an example of EF Core code accessing a blog’s database. The full tutorial can be found on the EF documentation site.
Dapper
  Dapper is a micro-ORM built and maintained by StackExchange engineers. It focuses on performance, and can map the results of a query to a strongly-typed list, or to dynamic objects. .NET Core support is available.
NPoco
  NPoco is a micro-ORM that also works on .NET Core.
Relational databases
SQL Server
  The Microsoft SQL Server client library is built into .NET Core. You don’t have to use an ORM, and can instead go directly to the metal and talk to a SQL Server instance or to an Azure SQL database using the same APIs from the System.Data.SqlClient package.
PostgreSQL
  PostgreSQL is an open source relational database with a devoted following. The Npgsql client library supports .NET Core.
  Another interesting library for PostgreSQL that is compatible with .NET Core is Marten. Marten uses PostgreSQL storage to implements a document database.
MySQL
  MySQL is one of the most commonly used relational databases on the market and is open source. Support for .NET Core is now available, both through EF Core and directly through the MySQL Connector for .NET Core.
SQLite
  SQLite is a self-contained, embedded relational database that is released in the public domain. SQLite is lightweight (less than 1MB), cross-platform, and is extremely easy to embed and deploy with an application, which explains how it quietly became the most widely deployed database in the world. It’s commonly used as an application file format.
  You can use SQLite with EF Core, or you can talk to a SQLite database directly using the Microsoft.Data.Sqlite library that is maintained by the ASP.NET team.
  There’s another SQLite package that’s compatible with .NET Core called SQLitePCL.raw.
Firebird
  Firebird is a mature relational database with a small footprint. It now has a .NET Core compatible client library.
NoSQL
Azure DocumentDB
  Azure DocumentDB is a NoSQL database service built for fast and predictable performance, high availability, automatic scaling, and ease of development. Its flexible data model, consistent low latencies, and rich query capabilities make it a great fit for web, mobile, gaming, IoT, and many other applications that need seamless scale. Read more in the DocumentDB introduction. DocumentDB databases can now be used as the data store for apps written for MongoDB. Using existing drivers for MongoDB, applications can easily and transparently communicate with DocumentDB, in many cases by simply changing a connection string. The next version of the DocumentDB client library, which will be available around the Connect event, supports .NET Core. The latest version of the DocumentDB SDK supports .NET Core.
MongoDB
  MongoDB is a document database with an official .NET driver that supports .NET Core.
RavenDB
  RavenDB is a document database that is not only compatible with .NET Core, it’s also built with it.
Redis
  Redis is one of the most popular key-value stores.
  StackExchange.Redis is a high performance Redis client that is maintained by the StackExchange team.
  ServiceStack has its own Redis client library, that is compatible with .NET Core, like the rest of ServiceStack.
Cassandra
  Apache Cassandra is a highly scalable and fault-tolerant NoSQL database. DataStax is a C# driver for Cassandra with built-in support for mapping Cassandra data to CLR objects. The latest version is compatible with .NET Core.
CouchBase
  CouchBase is an open source document database that is popular in mobile applications. The offical Couchbase client library is compatible with .NET Core.
CouchDB
  CouchDB is a document database that I personally like a lot for its simplicity. It can scale from small devices such as a Raspberry Pi to cloud applications. It uses a very simple HTTP and JSON-based API, which limits the need for a client library. C# client libraries do exist, but none of them support .NET Core today as far as I can tell except for Kanapa which hasn’t been updated for a while. It’s very easy to interact with the database through its REST API nonetheless.
Neo4j
  Neo4j is a graph database, which means that it establishes relationships not between tables but between data nodes, and treats these relationships as first class semantically rich entities that carry data and can be queried on. Readify has a .NET Core-compatible client for Neo4j called Neo4jClient.
  The full sample can be found in Tugberk Ugurlu’s blog post “Getting Started with Neo4j in .NET with Neo4jClient Library”
RethinkDB
  RethinkDB is a document database that can stream real-time result updates to a query. RethinkDb.Driver is a .NET Core driver for RethinkDB that covers 100% of the features of the official Java driver. One should exercise caution for new project however, as the company behind RetinkDB is shutting down.
YesSql
  YesSql is an interesting library that implements a transactional document database on top of relational stores such as SQL Server.
Lucene.NET
  Finally, I want to mention Lucene.NET. It’s not technically a database, but it’s so useful in setting up full-text search on a data-driven project that a post on data access wouldn’t be complete without it. The team has put a lot of work into the new version of Lucene to implement new features and major improvements, and they also made it compatible with .NET Core. It’s still early, but prerelease packages will soon be available.
What about OLE DB?
  OLE DB has been a great way to access various data sources in a uniform manner, but it was based on COM, which is a Windows-only technology, and as such was not the best fit for a cross-platform technology such as .NET Core. It is also unsupported in SQL Server versions 2014 and later. For those reasons, OLE DB won’t be supported by .NET Core.
Keeping track
  More database support for .NET Core will no doubt become available in the future, and we’ll make sure to highlight new client libraries in our Week in .NET posts as they get announced. In the meantime, I hope this post helps get you started with .NET Core application development.
  原文链接:https://blogs.msdn.microsoft.com/dotnet/2016/11/09/net-core-data-access/

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-390160-1-1.html 上篇帖子: Visual Studio 2017RC 版本相关资料 下篇帖子: 是什么让C#成为最值得学习的编程语言
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表