使用 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模板网!
LINQ to SQL:如何在不检索整个实体的情况下更新唯LINQ to SQL: how to update the only field without retrieving whole entity(LINQ to SQL:如何在不检索整个实体的情况下更新唯一字段)
string1 >= string2 未在 Linq to SQL 中实现,有什string1 gt;= string2 not implemented in Linq to SQL, any workaround?(string1 gt;= string2 未在 Linq to SQL 中实现,有什么解决方法吗?)
如何在条件下使用 RemoveAll 删除列表中的多个项目How to Remove multiple items in List using RemoveAll on condition?(如何在条件下使用 RemoveAll 删除列表中的多个项目?)
转换表达式树Convert Expression trees(转换表达式树)
当 IDENTITY_INSERT 设置为 OFF 时,无法为表“ClientCannot insert explicit value for identity column in table #39;ClientDetails#39; when IDENTITY_INSERT is set to OFF(当 IDENTITY_INSERT 设置为 OFF 时,
Linq 独特的 &最大限度Linq distinct amp; max(Linq 独特的 amp;最大限度)