为什么我使用Linq与Store程序? [英] why i use Linq with Store procedure ?

查看:76
本文介绍了为什么我使用Linq与Store程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在目前的项目中使用Linq,工作正常,



但现在问题是我的团队负责人对我说,

为什么我不在我的项目中使用存储过程,并且他们想要将整个项目linq查询更改为Store produre,



我研究这么多文章(Linq with商店程序),



但我注意到,当我使用Store产品时,所有查询都是用Ado.net编写的,

和linq只是用来调用商店产品,



所以我的问题是我在哪里使用Linq查询,



i think使用Store produre整个项目在Ado.net Project中转换,



所以plz建议我能做什么,并告诉我使用Linq的一些优势与Store produr

I use Linq in my current project, which work fine,

But now problem is my Team Leader said to me that,
why i not use store procedure in my project,and they want to change whole project linq queries into Store produre,

I study So many article for this(Linq with Store procedure),

But i notice that,when i use Store produre, All queries is written in Ado.net,
and linq is just use to call that store produre,

so my question is where i use Linq queries,

i think After use of Store produre whole project is convert in Ado.net Project,

so plz advice me what can i do,And tell me some Advantage of using Linq with Store produr

推荐答案

您的团队领导者推广了一种过时的方法。不是因为它不是一个好的,而是因为它与dot.net不是最好的。

SP是DAL的一部分,但它们也代表了业务逻辑,所以如果你想要要做好关注点分离,使用SP会打破这个。 LINQ,更确切地说是Entity Framework和Linq to EF,旨在通过将您的业务模型用作托管类型,为您提供在托管代码中构建BL的适当工具。如果您有一些不能使用托管代码的特殊任务,SP很好。啊,你也有CLR集成的SP,所以你可以选择的工具范围非常大。如果你以正确的方式管理访问,使用SP来隐藏表是没有用的。

即使是微软也在推广EF高于其他所有工具。

有趣的部分正在放置轮胎。如果您可以在数据存储附近安装基于EF的BL轮胎(从网络吞吐量的角度来看,例如:在同一台服务器上),您甚至可以获得比应用程序更好的性能。但即使你不是,你仍然可以获得可维护的代码。这在生命周期管理中很重要。
Your team leader promotes a quite outdated approach. Not because it is not a good one, but because it is not the best in conjunction with dot.net.
SPs are part of the DAL, but they represent business logic as well, so if you want to do a good separation of concerns, using SPs will break this. LINQ, more precisely Entity Framework and Linq to EF is meant to give you the proper tools to build BL in managed code by using your business model as managed types. SPs are good if you have some special tasks where you can''t use managed code. Ah, and you have CLR integrated SPs too, so the range of tools you can choose from is quite large. Using SPs just to hide tables is of no real use, if you manage access in the proper manner.
Even Microsoft is promoting EF above all other tools.
The interesting part is placing the tires. If you can install the BL tire built on EF near the data store (from network throughput point of view, ex: on the same server) you can even get better performance out of your application than with SPs. But even if you don''t, you still get a maintainable code. That is important in life-cycle management.


Linq是在ADO.NET的顶部创建的。其中一个主要的Linq优势是你可以写 Type Safe 查询比ADO.NET更无错误。使用Linq存在一些性能问题。如果您正在处理复杂的查询,我的建议是使用ADO.NET。



希望这有帮助
Linq is created on the top of ADO.NET.One of the main Advantage of Linq is you can write Type Safe Queries that is more error free than ADO.NET. There are some performance issue by using Linq. If you are working on a complex query, my suggestion is going with ADO.NET.

Hope this helps


代码应该仅通过存储过程访问数据库,不应直接访问表。这样,我们可以强制执行抽象,SP成为数据库的接口。这将数据库视为一个单独的实体,因此编写SP始终被视为访问数据库的理想方式。因此项目可能已经处理了linq或ADO,存储过程应该是Application和Database之间的桥梁。 每次进行任何项目时都要写SP。
Code should only access the database through stored procedures and should not have direct access to the tables. This way, we can enforce abstraction and the SPs become the interface to the database. This treats the database as a separate entity so writing SPs are always considered as an ideal way of accessing the databases. So the project might have been dealt with linq or ADO, store procedure should be the bridge between the Application and Database. Do write SPs every time you undertake any project.


这篇关于为什么我使用Linq与Store程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆