Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > .NET 3.5 and Visual Studio. 2008 > .NET Framework 3.5
|
.NET Framework 3.5 For discussion of the Microsoft .NET Framework 3.5.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the .NET Framework 3.5 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 5th, 2010, 11:06 PM
Authorized User
 
Join Date: Mar 2009
Posts: 74
Thanks: 5
Thanked 0 Times in 0 Posts
Default Hi all, I need your opinions, which is better and why

I want to understand which is better between using stored procedures to query my database then using Linq to Sql to connect to the stored procedures or just use LINQ itself to query the database without any stored procedures..which is a better approach and why? thanks.
 
Old June 6th, 2010, 05:04 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Smile

hello there:
what do u mean by BETTER?
SP always is much faster that plaint SQL bc of stored Execution plan
& I guess SP much organized! & im sure it depends on ur senario & bussiness
Im going to add some usefull notes from
Wrox Professional ADO NET 3.5 with LINQ and the Entity Framework by Roger Jennings
Chapter 1: Taking a New Approach to Data Access in ADO . NET 3.5
Page 15
Quote:
The advantage of moving from the relational model of tables, rows, and keys to the entity model of entity classes, entity instances, and associations is that entities can — and usually do — represent business objects, such as customers, partners, vendors, employees, products, and services. If your databases are highly normalized, like the AdventureWorks sample database, you ’ ll probably need one or more joins and WHERE clause criteria to represent a customer or employee. Adopting an entity model enables developers to design real - world objects with custom properties, associations, and behaviors suited to the organization ’ s business processes.
HTH
__________________
Always,
Hovik Melkomian.
The Following User Says Thank You to melvik For This Useful Post:
ysfkay (June 6th, 2010)
 
Old June 6th, 2010, 06:19 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Quote:
SP always is much faster that plaint SQL bc of stored Execution plan
This is a common misconception about sprocs, and generally not true.

Quote:
The cached execution plan used to give stored procedures a performance advantage over queries. However, for the last couple of versions of SQL Server, execution plans are cached for all T-SQL batches, regardless of whether or not they are in a stored procedure. Therefore, performance based on this feature is no longer a selling point for stored procedures. Any T-SQL batch with static syntax that is submitted frequently enough to prevent its execution plan from aging out of memory will receive identical performance benefits. The "static" part is key; any change, even something as insignificant as the addition of a comment, will prevent matching with a cached plan and thereby prevent plan re-use.
For more details: http://msdn.microsoft.com/en-us/library/ms973918.aspx

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
ysfkay (June 6th, 2010)
 
Old June 6th, 2010, 08:42 PM
Authorized User
 
Join Date: Mar 2009
Posts: 74
Thanks: 5
Thanked 0 Times in 0 Posts
Default Thanks

Thanks for the information, you have compared between stored procedures and T-SQL in application layer, is this comparison thesame with comparing Stored procedures and Linq queries ? thanks...

Last edited by ysfkay; June 6th, 2010 at 08:46 PM..
 
Old June 7th, 2010, 03:08 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

From a querying perspective, the answer is probably yes.

However, LINQ comes with overhead of its own as it needs to create object instances out of the database data. This means it will run slower than just retrieving data. However, when not using LINQ you need to turn the database data into something your application can work with and that takes time as well.

My advise if you want to know the nitty gritty of LINQ performance? Measure, measure, measure, and Google: http://www.google.com/#hl=en&q=linq+...f11b3472c963b9

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
ysfkay (June 7th, 2010)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Give your opinions about WebForms or MVC Rushino ASP.NET 4 General Discussion 3 May 6th, 2010 12:33 AM
Opinions sought re Captcha image use?? jimibt BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 6 April 9th, 2007 05:52 PM
Opinions Wanted about XML Data Storage kwilliams XML 7 September 2nd, 2005 12:03 PM
Access or MSDE - Opinions? johnm73 VB Databases Basics 0 July 20th, 2005 03:48 AM
Opinions About Contribute harpua Dreamweaver (all versions) 4 December 1st, 2004 05:47 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.