LINQ queries vs Stored procedures(LINQ 查询与存储过程)
问题描述
使用 linq 查询(以及像 EF 或 linq2sql 这样的 ORM)VS 的优缺点是什么.存储过程(SQL server 2008)查询和更新数据模型?表现?速度?等等……
What are the pros and cons of using linq queries(along with an ORM like EF or linq2sql) VS. Stored Procedures(SQL server 2008) to query and update a data model? Performance? Speed? Etc...
推荐答案
当您在代码中时,Linq 绝对更具可读性.作为开发人员,看到执行名为sp_GetSomething"的 sproc 的调用并不会告诉您任何事情,除非您亲自查看 sproc 的作用.看到像
Linq is definitely more readable when you're in the code. Seeing a call to execute a sproc called "sp_GetSomething" doesn't tell you anything as a developer, unless you go and physically look at what the sproc does. seeing code like
var query = from c in db.TableName
where c.Name == "foo"
select c;
这会告诉您正在提取哪些数据.
That tells you exactly what data is being pulled.
另一方面,如果您决定更改代码,存储过程不需要您重新编译应用程序.如果您决定突然更改where
"子句或更改Order By
- 更改 sproc 很容易.更改 Linq 代码可能更耗时.
Stored procedures on the other hand do not require you to recompile the application if you decide to change the code. If you decide to suddenly change a "where
" clause or change the Order By
- changing a sproc is easy. Changing the Linq code could be more time consuming.
我确定还有很多,但我注意到了这两个.
I'm sure there are plenty more, but these are two I've noticed.
这篇关于LINQ 查询与存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:LINQ 查询与存储过程


基础教程推荐
- 如果条件可以为空 2022-01-01
- 从 C# 控制相机设备 2022-01-01
- 重新排序 WPF TabControl 中的选项卡 2022-01-01
- 在 VB6 或经典 ASP 中使用 .NET 2022-01-01
- 更新 Visual Studio 中的 DataSet 结构以匹配新的 SQL 数据库结构 2022-01-01
- Mono https webrequest 失败并显示“身份验证或解密失败" 2022-01-01
- 将数据集转换为列表 2022-01-01
- SonarQube C# 分析失败“不是指针的有效行偏移" 2022-01-01
- 获取C#保存对话框的文件路径 2022-01-01
- C# 9 新特性——record的相关总结 2023-04-03