gpt4 book ai didi

c# - DbContext 和 ObjectContext 有什么区别

转载 作者:IT王子 更新时间:2023-10-29 04:48:55 26 4
gpt4 key购买 nike

来自MSDN:

Represents a combination of the Unit-Of-Work and Repository patterns and enables you to query a database and group together changes that will then be written back to the store as a unit. DbContext is conceptually similar to ObjectContext.

虽然 DbContext 仅处理与数据库的连接以及针对数据库工作的线程数。

现在我明白它包含跟踪机制了吗?我以为这是在 ObjectContext 中。

那么(用简单的英语来说)它们之间的区别是什么?

最佳答案

DbContext 是 ObjectContext 类的轻量级版本,它几乎位于 ObjectContext 之上(甚至有一种方法可以仅从 DbContext 访问 ObjectContext)。它也更易于使用,IMO,并使 CRUD 操作变得轻而易举。

要获得更好的信息,谁比 Julie Lerman 更好有关差异的更多信息,如已引入 EF 4.1。

关于c# - DbContext 和 ObjectContext 有什么区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14857915/

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