问题描述
我在想动我的开发团队,LINQ和实体框架。如果我这样做,我应该想删除的SP?
I'm thinking about moving my development team to LINQ and the Entity framework. If I do, should I be thinking about removing SPs?
通常情况下我们的架构是(按顺序);
Typically our architecture is (in order);
SQL -> SPs -> Data Access Layer -> Business Objects -> GUI
我应该搬到类似于:
Should I be moving to something similar to:
SQL -> Entity Framework Layer -> Business Objects (probably inherited from EF layer) -> GUI
我会看到尽可能多的好处,如果我离开的SP吗?还有什么是最好的做法是什么?
Will I see as much benefit if I leave SPs in? Also what are the best practices?
推荐答案
不,他们没有多余的
我们使用实体框架的90%,我们的数据访问code。
We use Entity Framework for 90% of our data access code.
10%是用在以下情况:
That 10% is used in the following scenarios:
- 当code是有分量的逻辑(过于复杂)
- 在当前表现至关重要
- 当多条记录需要受到影响单个事务
LINQ的实体(和LINQ,一般)是一个辉煌的和一致的框架,但有时在SQL翻译并不像你想象得那么理想 - 额外的JOIN的,CASE的,等等。有时在这些情况下是明智的跳过EX pression树翻译和直行到本地SQL。
LINQ-Entities (and LINQ, in general) is a brilliant and consistent framework, but there are times that the SQL translated is not as optimal as you expect - extra JOIN's, CASE's, etc. Sometimes in these scenarios it's wise to skip the expression tree translation and go straight to native SQL.
更重要的是,实体框架的推出的存储过程。你可以将它们映射在模型上,你甚至可以直接映射程序,CRUD操作上的实体。
What's more, Entity Framework promotes stored procedures. You can map them on your model, and you can even map procedures directly to CRUD operations on your entities.
因此,在一般情况下,使用EF对于大多数简单的操作(如CRUD),并使用存储过程时的性能和复杂的因素。
So in general, use EF for most simple operations (e.g CRUD), and use stored procedures when performance and complexity are factors.
HTH。
这篇关于是SP的冗余如果使用LINQ和EF(最佳实践)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!