Professional in C# and Visual Basic Part 54. Building on the revolutionary release, adds several key new developer features including AJAX, LINQ, and a new CSS designer in Visual Web Developer 2008. The dramatic reduction in code that developers realized from the more than 50 new server controls in now allows developers the time to make their applications more interactive with AJAX, to work with data in their preferred language with LINQ, and to build visually attractive and consistent standards-based sites with CSS. . | Chapter 9 Querying with LINQ End Sub C protected void Page_Load object sender EventArgs e MoviesDataContext dc new MoviesDataContext var query from m in select m query query Now when you debug the Web site using Visual Studio you can see the SQL query as shown in Figure 9-11. Output H SELECT tO . Title r tO . Director r tO . Genre r tO . Runtime r tO . ReleaseDate FROM dbo . Movies AS tO I i j Call Stack Breakpoints 7 Command Window f Immediate Windowj J Output Pending Checkins Figure 9-11 The SQL query generated by LINQ to SQL As you can see the SQL generated is standard SQL syntax and LINQ is quite good at optimizing the queries it generates even for more complex queries such as the grouping query shown in Listing 9-26. Listing 9-26 Grouping LINQ to SQL data VB Protected Sub Page_Load ByVal sender As Object ByVal e As Dim dc As New MoviesDataContext Dim query From m In _ Group By Into g Group Count query query 486 Chapter 9 Querying with LINQ End Sub C protected void Page_Load object sender EventArgs e MoviesDataContext dc new MoviesDataContext var query from m in group m by into g select new Genre Count query query The generated SQL for this query is shown in Figure 9-12. My Favorite Movies - Windo. 1 iQl - gj http lo alhostS86 X My Favorite Movies Count Genre 10 0 21 1 3 2 Ml Local intranet Protected M 100 Figure 9-12 Grouping SQL data using LINQ to SQL Note that SQL to LINQ generates SQL that is optimized for SQL Server 2005. LINQ also includes a logging option you can enable by setting the Log property of the data context. While LINQ to SQL does an excellent job generating the SQL query syntax there may be times .