Pros and cons for using ADO.Net entity model

孤者浪人 提交于 2020-01-03 17:48:29

问题


HI

What are the pros and cons for using ADO.NET entity model as a data layer? And should i use LINQ if i'm going to use this technology?

Thanks


回答1:


First of all: you don't have to use LINQ to use the Entity Framework (EF), but it certainly helps. EF is based upon something the EF team calls Entity SQL, so what really happens when you use LINQ to Entities is that the LINQ expressions are being translated to Entity SQL, which again are translated to whatever SQL dialect your database uses (T-SQL for SQL Server).

Pros and cons for EF is a bit of a controversial subject as most people don't particularly like EF, but I will try to keep it neutral.

Pros

  • Together with LINQ to SQL (L2S), LINQ to Entities (L2E) and EF are currently the best data access API that Microsoft offers. Despite all their shortcomings, they are way better than 'traditional' ADO.NET for most scenarios.
  • While L2S is simpler, L2E has been tagged as the future of Microsoft's data access API, so if you want to stay in the mainstream Microsoft API slipstream, you should use L2E. It doesn't look like L2S will see much new development.
  • EF will receive quite a boost in capabilities and flexibility in .NET 4

Cons

  • Working with EF is hard. It's pretty brittle when it comes to schema changes, and it's a bitch to update it when the underlying schema changes
  • The T-SQL generated by EF is horrible (although this should change in .NET 4)
  • Persistence Ignorance isn't possible (until .NET 4)
  • Lots of LINQ methods are not implemented, so the API is more limited than it looks like.
  • It's not nearly as flexible an API as one could wish

In short, use it if you can use only what's baked into the BCL, or, if you are on .NET 4, give it a try; otherwise, there are better alternatives in the form of open source libraries.




回答2:


Here are some pro's about ADO.NET. I've found no cons yet. Edit: and some more about ADO.NET, including cons: Here

About LINQ: no one will force you to use LINQ (except maybe an employer), but it has certainly benefits in combination with ADO.NET. See also: Here.

Sorry for the bunch of links, but it's a lot of text to C/P. Happy reading :).



来源:https://stackoverflow.com/questions/1867377/pros-and-cons-for-using-ado-net-entity-model

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!