TAILIEUCHUNG - Microsoft ADO .NET 4 Step by Step - p 29

Chạy truy vấn SQL thực thể Khung thực thể bao gồm hai cách quan trọng của việc sử dụng thực thể truy vấn SQL để truy cập dữ liệu entitymanaged: sử dụng một thể ObjectQuery để truy vấn các đối tượng trong bối cảnh trực tiếp hoặc bằng cách sử dụng một giao diện cung cấp dịch vụ truyền thống như. | 256 Microsoft 4 Step by Step Running Entity SQL Queries The Entity Framework includes two key ways of using Entity SQL queries to access entitymanaged data using an ObjectQuery instance to query the entities within the context directly or using a more traditional provider-like interface. Running Queries Using an ObjectQuery The Of T class-processes an Entity SQL statement against an open EF context and returns the results as a collection of either named or anonymous instances. C ---- SalesOrderEntities is an Entity Container. using SalesOrderEntities context new SalesOrderEntities GetConnectionStringO ObjectQuery Customer query New ObjectQuery Customer sqlText context . Other code as needed . Visual Basic ------ SalesOrderEntities is an Entity Container. Using context As New SalesOrderEntities GetConnectionString Dim query As New ObjectQuery Of Customer sqlText context . Other code as needed . End Using You must keep the context around as long as you need to access the ObjectQuery object s data especially if the retrieved data includes content accessed through a navigation property. The generic ObjectQuery type works like a typical generic collection object but it s not a true collection. When you create the ObjectQuery instance the Entity Framework delays processing of the query until you specifically request data. Even then it might decide to retrieve only the requested portion of the data. Keeping the context around during the entire data-retrieval process enables the ObjectQuery to fulfill any data requests you give it over time. Chapter 15 Querying Data in the Framework 257 Note The object context and its related entity container in the conceptual model expose a LazyLoadingEnabled property. Changing this Boolean value alters the way that the Entity Framework loads data at the other end of a navigation property. Models built with the visual designer set this property to True by default keeping unused navigation .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.