tailieunhanh - Apress pro LINQ Language Integrated Query in C# 2008 phần 8

Mũi tên giữa 4 lớp thực thể (entity) ở trên biểu diễn những mối liên kết/ những mối liên hệ (associations/relationships) giữa những thực thể khác nhau. Có những mối quan hệ được làm mẫu một cách đặc trưng bằng việc sử dụng primary-key/foreign-key trong csdl. Hướng của những mũi tên trong bề mặt thiết kế chỉ định có hay không sự liên kết là một mối quan hệ one-to-one hay one-to-many. | PART 5 CHAPTER 12 LINQ to SQL Introduction Listing 12-1 . A Simple Example Updating the ContactName of a Customer in the Northwind Database Create a DataContext. Northwind db new Northwind @ Data Source . SQLEXPRESS Initial Catalog Northwind Retrieve customer LAZYK. Customer cust from c in where LAZYK select c .Single Customer Update the contact name. Ned Plimpton try Save the changes. Detect concurrency conflicts. catch ChangeConflictException Resolve conflicts. Note This example requires generation of entity classes which I will cover later in this chapter. In Listing 12-1 I used LINQ to SQL to query the record whose CustomerlD field is LAZYK from the Northwind database Customers table and to return a Customer object representing that record. I then updated the Customer object s ContactName property and saved the change to the Northwind database by calling the SubmitChanges method. That s not much code considering it is also detecting concurrency conflicts and resolving them if they occur. Run Listing 12-1 by pressing Ctrl F5. There is no console output but if you check the database you should see that the ContactName for customer LAZYK is now Ned Plimpton . .

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.