简体   繁体   English

在Entity Framework中使用EntityDataSource和ObjectDataSource的优缺点?

[英]Pros and cons of using EntityDataSource vs ObjectDataSource in Entity Framework?

在基于实体框架asp.net的应用程序中使用EntityDataSource与ObjectDataSource有什么优缺点?

Basically EntityDataSource is build to support Entity Framework entities for features like sorting, filtering, inserting, deleting etc... If you use the ObjectDataSource you will have to do this on your own. 基本上构建EntityDataSource是为了支持实体框架实体,用于排序,过滤,插入,删除等功能......如果使用ObjectDataSource ,则必须自己完成。

One huge disadvantage of EDS controls that I just discovered the hard way, is that they want to update the database immediately and each such control has its own EF object context, its own database connection, and even after I wrote a handler to share a context, share a db connection and turn off all immediate inserting, updating and deleting, so that I could do the final SaveChanges() at the end when the user hit the final "submit" button, the EDS control uses EF in such a fashion that it still fetches deleted records. EDS控件的一个巨大缺点是我刚刚发现了困难,他们想要立即更新数据库,每个这样的控件都有自己的EF对象上下文,自己的数据库连接,甚至在我编写处理程序来共享上下文之后,共享数据库连接并关闭所有立即插入,更新和删除,这样当用户点击最后的“提交”按钮时,我可以在最后执行最终的SaveChanges() ,EDS控件以这样的方式使用EF它仍然提取已删除的记录。 and does not fetch inserted records. 并且不会获取插入的记录。 SO I am going to convert where I use EDS controls to use ODS controls instead and thus allow me to interject another object model in between my radgird views and EF in order to have the grid show inserted records and not show deleted records and be able to allow the user the delayed commit back to the database. 所以我将转换我使用EDS控件来代替使用ODS控件,从而允许我在我的radgird视图和EF之间插入另一个对象模型,以便让网格显示插入记录而不显示已删除的记录并且能够允许用户将延迟提交返回数据库。 As far as I can tell, there is no other way to have web grids use EDS controls and to delay this final commit as well as show inserted records or not show deleted records. 据我所知,没有其他方法可以让网格使用EDS控件并延迟最终提交以及显示插入的记录或不显示已删除的记录。 I would love to be proven wrong on these facts.e 我希望在这些事实上被证明是错误的

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM