Oh how I remember those days of page through data, using a GridView controller, or any other controller, lots of coding and so easy to make a mistake.
Just take a look at http://www.unboxedsolutions.com/sean/archive/2005/12/28/818/ by Sean Chase, and you will see what I mean.
Things have moved on a bit since those days, and now we have LINQ it is much easier, both directly feeding from LINQ or via methods, both provide the same result.
Here is how to enable paging directly to LINQ, by using the LinqDataSource
How easy could it be?
When it comes to generating your own method you can do this with just a little more coding and take advantange of the Linq Skip and Take methods, the sample below provides an example using a Method.
To use this fully you will need to make a few changes to the webpage, as shown below:
Now that you have everything set on the page all that is left is the code behind and the methods, I am using the partial class in the example, but it does not have to be.
To ensure that the application is Paging correctly I found running the SQL Profiler on the database made sure that only the data page was being returned and nothing else, you may want to perform your own tests too.
I have included a small application using Visual Studio 2008 and .NET 3.5, all you will need to change is the connection string settings to the NorthWind database.
GridPerformance.zip (16.46 kb)
With C# 4.0 going to include Dynamic Language programming, the reports and demos I have seen to date look very impressive.
The only main implementation and useful application was to connect to COM objects, or more to the point to Microsoft Office as this is pure COM, and always been really hard to connect and work with.
I've also seen a demo of using the Dynamic Language to build your own .NET compiler on the fly, so building and running C# code from your own application, how cool is that?
With Dynamic Language for C#, COM should be eaiser to work with.
Microsoft have release the Dynamic Language Runtime on CodePlex so we can start to play with the new features before they are release in C# 4.0
What is the best practice and pattern to use for the DataContext with LINQ to SQL.
While using LINQ to SQL and it's DataContext I have found it is very easy to fall in to a concurrency issues when you try out multiusers, I've not found the answer as yet, but I have come across this article for different methods
Best practice and effective way of using DataContext in Linq to SQL?
One little crip I am having with LINQ to SQL is that when you build the DBML files within Visual Studio 2008, the default values from the database are not taken in to account.
This means that you need to set the default values against your object before it is saved or after the object is created.
This is a pain the the back side.
This articles provides a method to overcome this “Handling Default Values With LINQ to SQL“
List of files and links as part of my Grog talk at DotNetDevNet 2nd December 2008
•VisualStudio Team System 2008 Team Explorer
CodePlex.ppsx (571.84 kb)
CodePlex.ppsx (571.84 kb)
CodePlex.ppt (664.50 kb)