Professional LINQ phần 10

Chúng ta hãy xem xét làm việc với các đối tượng đại diện cho các loại thực thể được định nghĩa bởi một mô hình dữ liệu thực thể. Ví dụ sau đây minh họa làm thế nào để sử dụng các mô hình dữ liệu thực thể cập nhật và chèn dữ liệu:Truy vấn các mô hình dữ liệu thực thể là khá dễ dàng và hiệu quả. | Appendix B LINQ to Entities The Entity Framework foreach SalesOrderHeader order in .SalesOrderHeader Order Date 0 Total 0 foreach SalesOrderDetail item in Product 0 Quantity 1 Querying the entity data model is quite easy and efficient. Working with Objects Let s take a look at working with objects that represent entity types defined by an entity data model. The following example illustrates how to use the entity data model to update and insert data string ln Kleinerman productSalesContext new AdventureWorksEntities Contact con @lastname new ObjectParameter lastname ln .First 1 Contact newcon new Contact asdf 1 Scott Klein L false asdf adsf 555-555-5555 Mr. Geek As you saw earlier you can also bind objects to controls like this ObjectQuery Contact salesPerson 5000 .OrderBy SalesOrderHeader 341 Appendix B LINQ to Entities The Entity Framework .SalesOrderDetail LastName A best practice is to detach objects from the ObjecContext when they are no longer needed. Object Services lets you accomplish this via the Detach method. This decreases the amount of memory being used. Object Services implemented via the and namespaces is a component of the .NET Entity Framework that enables you to perform CRUD operations that are expressed as strongly .

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
30    262    2    01-06-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.