TAILIEUCHUNG - Lập trình .net 4.0 và visual studio 2010 part 27

Khi bạn thay đổi cơ sở dữ liệu của bạn thì bạn cũng sẽ cần phải cập nhật EDM của bạn. Để cập nhật các mô hình đơn giản là nhấn chuột phải trên bề mặt thiết kế và chọn Update Model từ cơ sở dữ liệu. Visual Studio sau đó sẽ mang đến một hộp thoại cho phép bạn bổ sung thêm các bảng và các lĩnh vực (Hình 8-8). Lưu ý rằng lần này của EF cải thiện việc giải quyết xung đột / yếu tố mô hình mồ côi trong cửa sổ trình duyệt mô hình:. | CHAPTER 8 ENTITY FRAMEWORK What Happens If My Database Structure Changes When you make changes to your database then you will also need to update your EDM. To update the model simply right-click on the design surface and select Update Model from Database. Visual Studio will then bring up a dialog box allowing you to add additional tables and fields Figure 8-8 . Note that this release of EF improves the resolution of conflicts orphaned model elements in the model browser window Figure 8-8. Update Model from Database Querying Data EF allows you to query objects in a number of different ways LINQ to Entities L2E ObjectQuery methods Entity SQL Whichever query method you use the query gets transformed into the same query tree structure that is then processed by your model s data source provider. LINQ to Entities LINQ to Entities L2E is probably the easiest query method. L2E gives you rich query functionality and Intellisense support and it is very easy to use. Lets write some code to iterate through our Orders and Orderitem tables displaying information about these entries. 185 CHAPTER 8 ENTITY FRAMEWORK 1. Open . 2. Modify the Main method to the following note your entity set will by default be prefixed with the same name as the database in the following example mine is Book . static void Main string args BookEntities ctx new BookEntities var query from o in select o foreach Order order in query Order foreach OrderItem orderItem in Adult Child The results are shown in Figure 8-9. Figure 8-9. Output of LINQ to Entities query 186 CHAPTER 8 ENTITY FRAMEWORK ObjectQuery You can also query EF objects with the ObjectQuery class. Let s take a look at this now. 1. Add the following using directive to using 2. .

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.