如何为 Linq to 实体使用不同的提供程序?

发布于 2024-09-03 02:19:53 字数 571 浏览 0 评论 0 原文

我正在尝试让自己更熟悉数据库编程,并且正在研究为应用程序创建数据访问层的不同方法。我尝试了几种方法,但不同的数据库技术如此之多,我不知道该学什么。例如,我尝试将数据集与表适配器一起使用。使用它,我可以相当轻松地切换数据提供者(通过针对 IDbConnection 等接口进行编程)。这是我想要实现的一件事。但我也知道每个人都在谈论 LINQ,并且我也在努力更好地了解这一点。因此,我也尝试使用 Linq to Sql 类作为数据访问层,但显然这不是独立于提供程序的(仅适用于 SQL Server)。

然后我读到了有关 Entity Framework 的内容(就像 Linq to SQL 显然已经受到了攻击一样……)。每个人都说它应该是独立于提供商的,但是如何呢?我尝试了创建实体数据模型的教程,但唯一可供选择的提供程序是 SQL Server/Express。出于学习目的,我想知道如何将实体框架与 MS Access/OleDb 一起使用。

另外,我希望能提供一些有关数据访问的首选数据库技术的意见。经过这么多的抨击之后,它仍然是 LINQ,还是应该只使用数据集,因为它们是独立于提供者的?任何有关学习内容的指示都会很棒,因为如果我最终不打算使用它,那么学习所有内容就太多了......!

I'm trying to familiarize myself a bit more with database programming, and I'm looking at different ways of creating a data access layer for applications. I've tried out a few ways but there is such a jungle of different database technologies that I don't know what to learn. For instance I've tried using datasets with tableadapters. Using that I am able to switch data provider rather easily (by programming against the interfaces such as IDbConnection). This is one thing I would want to achieve. But I also know everyone's talking about LINQ, and I'm trying to get to know that a bit better too. So I have tried using Linq to Sql classes as the data access layer as well, but apparently this is not provider independent (works only for SQL Server).

So then I read about the Entity Framework (which just as Linq to SQL apparently has gotten its share of bashing already...). It's supposed to be provider independent everybody says, but how? I tried out a tutorial to create an entity data model, but the only providers to choose from were SQL Server/Express. Just for learning purposes, I would like to know how to use the entity framework with MS Access/OleDb.

Also, I would appreciate some input on what is the preferred database technology for data access. Is it LINQ still after all the bashing, or should you just use datasets because they are provider independent? Any pointers for what to learn would be great, because it's just too much to learn it all if I'm not going to use it in the end...!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

自此以后,行同陌路 2024-09-10 02:19:53

唯一可供选择的提供商是 SQL Server/Express

Framework 仅包含 SQL Server 和 SQL Server Compact 的 EF 提供程序。如果需要访问其他DBMS,则需要安装第三方提供程序。例如,有一个免费的 SQLite 提供程序,并提供设计人员支持。还有一些(商业)由 Devart 制作的,用于各种 DBMS。据我所知,没有适用于 OleDB 或 ODBC 的 EF 提供程序...

the only providers to choose from were SQL Server/Express

The .NET Framework only includes EF providers for SQL Server and SQL Server Compact. If you need to access another DBMS, you need to install a third-party provider. For instance, there's a free provider for SQLite, with designer support. There are also a few (commercial) providers made by Devart, for various DBMS. As far as I know, there are no EF providers for OleDB or ODBC...

往昔成烟 2024-09-10 02:19:53

我真的很喜欢 Scott Hanselman< 的比喻< /a>:“我不是水管工,但我确实知道什么是S-Bend 是。”

就我个人而言,我认为您应该具备各种访问数据的方法的实用知识。

ADO.Net、EF、Linq2Sql、txt 文件、xml 等等等。

看看书呆子晚餐音乐商店示例。查看他们访问数据的方式(他们如何进行单元测试、模拟框架、IOC 等)

关于数据提供者,我个人会避免使用 Access。运行 Sql Express 或 Mysql 安装同样容易,并且在您的简历上看起来更好。

(就其价值而言,这个 问题讨论为 EF 设置 mysql。)

I really like the metaphor from Scott Hanselman: "I'm not a plumber, but I do know what an S-Bend is."

Personally, I think you should have a working knowledge of all the variety of ways to access data.

ADO.Net, EF, Linq2Sql, txt files, xml etc etc etc.

Have a look at the Nerd Dinner and the Music Store samples. See the way they access data (how do they do Unit Tests, Mocking framework, IOC etc)

Regarding data providers, personally I would avoid Access. It is just as easy to get a Sql Express or Mysql installation running and looks better on your resume.

(For what its worth, this question discusses setting up mysql for EF.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文