Đang chuẩn bị liên kết để tải về tài liệu:
ASP.NET 4 Unleased - p 102

Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ

Bạn có thể xây dựng các biểu thức LINQ để truy vấn SQL động bằng cách tận dụng các lớp System.Linq.Expressions.Expression. Lớp này có tất cả các phương pháp để xây dựng các biểu thức truy vấn năng động. Đây là danh sách (rất một phần) các phương pháp hỗ trợ của lớp này. | 984 CHAPTER 20 Data Access with LINQ to SQL You can build LINQ to SQL query expressions dynamically by taking advantage of the System.Linq.Expressions.Expression class. This class contains all the methods for building query expressions dynamically. Here is a very partial list of methods supported by this class Add Creates an expression that represents addition. And Creates an expression that represents a logical AND. Condition Creates an expression that represents a condition. Constant Creates an expression that represents a constant value. Convert Creates an expression that represents a conversion from one type to another. Divide Creates an expression that represents division. Equal Creates an expression that represents whether two expressions are equal. Field Creates an expression that represents a field. Lambda Creates a lambda expression. Multiply Creates an expression that represents multiplication. Or Creates an expression that represents a logical OR. Parameter Creates an expression that represents a function parameter. Property Creates an expression that represents accessing a property. PropertyOrField Creates an expression that represents accessing a property or field. Subtract Creates an expression that represents subtraction. Again this is not a complete list of methods supported by the Expression class. However it should give you some idea of how you can go about building expressions. Let s discuss a real-world situation in which you need dynamic LINQ to SQL expressions sorting. If you want to enable sorting when using a GridView control with LINQ to SQL you have a choice. You can create a switch SELECT CASE block to sort by every possible column that a user can click or you can create a dynamic LINQ to SQL expression. The class in Listing 20.29 contains a method called GetDynamicSort that returns a dynamic lambda expression that can be used with either the OrderBy or OrderByDescending method. LISTING 20.29 Standard App Code Movie.cs using System using

TÀI LIỆU LIÊN QUAN
crossorigin="anonymous">
Đã 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.