As I know you cannot use a stored-procedure to make a compiled query, if you do you will get an error message. I have found a pretty good forum topic where someone wrote up the advantages and back draws Linq vs stored procedure. Yes, building the expression tree can slow down your application in some cases.
This can be improved by the compiled queries which provides for compilation and caching of queries for reuse. If you wanna test by your self what is faster, user a Timer. Start it before operation, and stop it just after. Then you will see exactly which is faster, and you will see an actual time. Can you also guide how is performance of Linq with complied quries vs Linq with SQL Server stored prcedures which are again in complied form?
Generally the stored procedures are more performant then querying data directly. But you know I give you a trick to meusure this performance with a practice way. You could build a PerformanceCounter on that object and meusure the both situations where you use query and where you use the stored procedure with the same table.
The content you requested has been removed. Learn More. LINQ2SQL queries will not perform any differently from any other ad-hoc parameterized SQL query, other than the possibility that the generator may not optimize the query in the best fashion.
The common perception is that ad-hoc sql queries perform better than Stored Procedures. However, this is false:. A stored procedure is compiled at execution time, like any other Transact-SQL statement.
Linq should be used at the business logic layer on top of views created in sql or oracle. Linq helps you insert another layer for business logic, maintenance of which is in the hands of coders or non sql guy. It will definitely not perform as well as sql coz its not precompiled and you can perform lots of different things in sps. But you can definitely add a programming detail and segregate the business logic from core sql tables and database objects using Linq.
Unless you are trying to get every millisecond out of your application, whether to use a stored procedure or LINQ may need to be determined by what you expect developers to know and maintainability. Stored procedures will be fast, but when you are actively developing an application you may find that the easy of using LINQ may be a positive, as you can change your query and your anonymous type that is created from LINQ very quickly.
Once you are done writing the application and you know what you need, and start to look at optimizing it, then you can look at other technologies and if you have good unit testing then you should be able to compare different techniques and determine which solution is best. You may find this comparison of various ways for. NET 3. I don't think I would like having my database layer in compiled code. It should be a separate layer not combined. As I develop and make use of Agile I am constantly changing the database design, and the process goes very fast.
Adding columns, removing columns or creating a new tables in SQL Server is as easy as typing into Excel. Normalizing a table or de-normalizing is also pretty fast at the database level. Now with Linq I would also have to change the object representation every time I make a change to the database or live with it not truly reflecting how the data is stored. Deploying LINQ based solution is much simpler than a set of stored procedures.
Dec, 1. May, Koushik is Right U can follow Mr. Koushik Answer 1. Nov, 2. Deploying LINQ based solution is much simpler than a set of stored procedures 0. NET Framework? Developer Programmer Sr.
0コメント