Video: Using LINQ with ASP.NET in VS "Orcas" (Part 1)
One of my goals this year is to use video more with my blog. My theory is that video is often a better medium than text to walkthrough how something works, and can also help you avoid the tedium of reading though some of my really long blog posts... :-)
Over the next few months I'm going to try and create a new video every other week or so on various topics. Many of these videos are going to involve first looks at some of the new features coming with Visual Studio "Orcas", which is our new release that will ship later this year. For today's video I decided to focus on introducing LINQ - which I think is one of the most exciting features coming with "Orcas".
At a high-level, LINQ makes the concept of query a first class programming concept within .NET. Using LINQ you can easily query relational databases, XML files, as well as any plain-old .NET object. You can also easily use your own data source abstractions with LINQ to provide rich domain models for various data providers (for a great example of this check out Fabrice's LINQ to Amazon implementation that supports LINQ queries against Amazon data exposed via web-services). Both VB and C# include rich language integration with LINQ as part of the "Orcas" release, including full intellisense, compile-time checking, and debugging support.
Watch or Download the Video
This first video starts with a new project, and then demonstrates the basics of using LINQ against a SQL Database to build a simple data reporting page (including support for aggregate values computed from multiple tables, and efficient server-side paging within the database).
You can watch the video online here (it is 24 minutes in length). Or you can download a .zip version of it here if you want to save and watch it locally. Note that it might take 30-60 seconds to buffer (since it is a large video). In the event that my server is swamped with requests, I'll update the location and post it on one of the Microsoft video servers later this week.
For more information on LINQ (including the slide deck for a "Building ASP.NET Data Driven Application Using LINQ" talk of mine), please check out my previous post here. For other ASP.NET 2.0 Tips, Tricks and Tutorials please check out my ASP.NET Tips and Tricks summary listing page.
Specifics Topics Covered in this Video
My walkthrough in this video illustrates a number of new features:
1) A brief demonstration of some of the new WYSIWYG HTML designer capabilities (including split-view and a brief look at the new CSS manager - both of which I'll cover in more detail in the future in a separate video):
2) How to create classes that model data using the new VS "Orcas" ORM designer for LINQ to SQL:
3) How to use the new LINQ intellisense support within the VS "Orcas" code editor to get full intellisense and compilation support for queries:
4) How to use LINQ to SQL to create a data report that combines Product entity data with aggregate unit and revenue values computed from OrderDetail entities associated with the Product entities. This data report uses server side database paging to efficiently retrieve only 10 rows of data at a time (so that with a 100,000 row products table you only ever retrieve 10 rows of data from the database regardless of which page index you are on within a report):
Future Videos
I'll be drilling into LINQ some more with future videos (I barely scratched the surface with this one). Additional segments will include content on:
- Type inference and the "var" keyword (and why that is so cool)
- Supporting Insert, Update and Deletes scenarios using LINQ to SQL
- Validation rules and logic within LINQ Data Models
- Using SPROCs with LINQ to SQL
- Richer JOIN support with LINQ to SQL
- LINQ to XML and LINQ to Objects
- Using the new LINQDataSource controls and other ASP.NET Data Controls to easily create Web UI with LINQ
I'll also obviously have many more ASP.NET and web-related video topics to cover including:
- The new HTML WYSIWYG Designer and CSS support
- Client-JavaScript Intellisense
- JavaScript Debugging
- ASP.NET AJAX Extender Support
- Database Dump and Upload Integration
- Unit Testing
- Multi-targeting support (showing how you can use VS "Orcas" to build ASP.NET 2.0 projects - without having to upgrade your framework/server)
Hope this helps,
Scott
P.S. If you have other topics and/or subjects you'd like me to drill in on with videos, please post them in the comments section of this post.