Jacek Jurkowski wrote:
Why is it so slow? I really like
that queries but using DataReader
i have done my task's much more faster
than ising LINQ...
Read this series and you might start thinking otherwise:
http://blogs.msdn.com/ricom/archive/...ce-part-1.aspx
There's a cost, obviously, and you will never get faster than using a raw
DataReader, but the performance overhead can be brought down considerably.
Did you use CompiledQuery and time multiple executions?
If the problem is not in the reflection and code generation of LINQ, you may
want to have a look at what SQL output you're actually generating. It may
not be optimal for a variety of reasons. LINQ abstracts considerably over
queries so you don't have to, but it's not perfect, and it can especially
break down if you mix in other constructs with LINQ to Objects. You can use
a tool like LINQPad (
http://www.linqpad.net/) to see what your LINQ queries
are actually compiling to.
Finally, the ease of use of LINQ mean that it'll help you speed up
development even if you don't use LINQ to generate the actual queries. LINQ
works just as well with stored procedures, so if you have a particularly
tough query that needs careful optimization, you can stick it in a sproc and
use a few lines of declarative code (or a drag and drop from the Server
Explorer) to get a strongly-typed method for it.
--
J.