开发者

LINQ and performance

I use a stored procedure to fetch data and modifications from the database. If i use LINQ for the same job will there be any performance issue? I mean will I get better performance or not? I 开发者_StackOverflow社区saw that LINQ syntax is bit complicated, so is there any tool which help me to generate LINQ syntax.

thanks


There is a slight performance impact against using Linq2Sql VS calling stored procedures; for one, the stored procedure can be compiled and stored so subsequent calls are quicker, and you have more control and options in T-SQL land VS having Linq2Sql generate the statements for you.

However, unless your site is getting heavy traffic, theres no reason not to use it if you are looking for an easy way to get your site set up.


In general, LINQ will not beat the performance of a stored procedure. After all, Linq2Sql generates SQL and that will never be better than a well-written stored procedure.

Linq2sql, if not used properly, can harm performance. That is often caused by developers that do not understand the deferred loading principle and that can lead to a LOT of queries.

Where it WILL create performance issues is with bulk operations. This is an area where you do not want to use Linq2Sql but you need SqlBulkCopy or stored procedures.

Nevertheless, I use it a lot and am happy in general.


LinqPad is a free program and can be a way to learn LINQ. It comes loaded with 500 examples.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜