使用 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 查询与存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!