Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

What are the pros and cons of using EntityDataSource vs ObjectDataSource in Entity Framework asp.net based apps?

like image 687
Abdu Avatar asked Feb 16 '09 23:02

Abdu


2 Answers

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.

like image 123
JohannesH Avatar answered Sep 28 '22 14:09

JohannesH


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. 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. 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. I would love to be proven wrong on these facts.e

like image 38
Dave Avatar answered Sep 28 '22 14:09

Dave