Professional ASP.NET 3.5 in C# and Visual Basic Part 52

Professional in C# and Visual Basic Part 52. 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 Next the code uses a very simple LINQ query to select all of the Movie objects from the generic movies collection. Notice that this specific LINQ query utilizes new language keywords like from and select in the query statement. These syntax additions are first class members of the .NET languages therefore Visual Studio 2008 can offer you development assistance such as strong type checking and IntelliSense making it easier for you to find and fix problems in your code. The query also defines a new variable m. This variable is used in two ways in the query. First by defining it in the from statement from m we are telling LINQ to make m represent the individual collection item which in this case is a Movie object. Telling LINQ this enables it to understand the structure of the objects we are querying and as you will see later also gives us IntelliSense to help create the query. The second use of m in the query is in the select statement. Using m in the select statement tells LINQ to output a projection that matches the structure of m. In this case that means LINQ creates a projection that matches the Movie object structure. We could just have easily created our own custom projection by explicitly defining the fields we wanted returned from the query using the new keyword along with the select operator. This is shown below in Listing 9-7. Listing 9-7 Creating a custom projection with LINQ VB Protected Sub Page_Load ByVal sender As Object ByVal e As Dim movies GetMovies Dim query From m In movies _ Select New With query End Sub C protected void Page_Load object sender EventArgs e var movies GetMovies var query from m in movies select new query Notice that rather than simply selecting m we have defined a new projection containing only the Title and Genre values. You can even go so far as to .

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
21    63    2    17-05-2024
5    55    1    17-05-2024
3    490    1    17-05-2024
94    790    1    17-05-2024
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.