Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > ASP.NET 4 General Discussion
|
ASP.NET 4 General Discussion For ASP.NET 4 discussions not relating to a specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 4 General Discussion 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 November 28th, 2010, 04:48 PM
Friend of Wrox
 
Join Date: Mar 2010
Posts: 99
Thanks: 21
Thanked 6 Times in 4 Posts
Post Avoid database hits while using runtime databinding

Hello.

I am using LINQ for binding a grid at runtime (specially a devexpress grid, but they work probably the same ways). The problem is that each time i perform action on the grid such callbacks like sorting a column, it do a round trip to the server. Is there a way to avoid database hits such using cache or anything? is there any solution to this ?

Thanks!
 
Old November 29th, 2010, 03:59 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

I guess it depends on the data source you bind it to. Some data sources, like the SqlDataSource have built-in caching capabilities. If you manually bind, you can use the Cache programmatically to store your own data.

However, it's worth considering if you really want to cache the data. Especially with sorting and paging scenarios for a GridView, caching may be counter-productive. Imagine you have a data set of 100,000 records and a GridView that displays 10 at a time. Do you really want to cache those 100,000 records on the first hit and select the 10 you need to display when a paging or sorting event occurs?

In most cases, doing paging and sorting at the database level (which is what LINQ to SQL does by default when you do it right (assuming you are referring to L2S with LINQ)) will give you much better performance as you're only selecting and transferring 10 instead of 100,000 records.

Hope this helps,

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!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Word search - Count Hits bonekrusher XSLT 5 January 2nd, 2008 10:26 AM
Changing database at runtime joerage BOOK: Professional Crystal Reports for VS.NET 3 December 15th, 2006 05:55 PM
Changing Database Location in Runtime jstokes8447 Crystal Reports 0 December 28th, 2004 06:37 PM
Creating Access database at runtime in C# janigorse General .NET 0 September 18th, 2004 06:24 AM
Page Hits Problem eddiema Classic ASP Professional 3 October 10th, 2003 12:46 PM





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