TAILIEUCHUNG - Microsoft SQL Server 2008 R2 Unleashed- P187

Microsoft SQL Server 2008 R2 Unleashed- P187:SQL Server 2005 provided a number of significant new features and enhancements over what was available in SQL Server 2000. This is not too surprising considering there was a five-year gap between these major SQL Server 2008 is not as much of a quantum leap forward from SQL Server 2005 | 1814 CHAPTER 45 SQL Server and the .NET Framework new AdventureWorks2008Entities _svcUri ProductReview P p ProductReviewId .FirstOrDefault if P null string OldComments NewComments P Success Updated comments to 0 put old comments back OldComments P return P Notice the use of the NewContext object. It is of type AdventureWorks2008Entities a DataServiceContext derivative that was generated when you added your service reference. You must use this class rather than the original _ctx object to perform any CRUD query other than a retrieval. Walking through the code in Listing you first select your desired ProductReview entity and then update its Comments property. Then you call UpdateObject and SaveChanges to commit your changes to the database through your service. Next up Listing illustrates how to perform an insert of a new ProductReview related to an existing Product using ADODS. Under the hood it uses the HTTP POST verb to accomplish its goal. In this example you first fetch your Product to which you associate your new ProductReview then set the properties of your ProductReview add that new object PR to the current list via set the Product property on PR and then call SetLink to tell your context that you have made this association. Finally you call SaveChanges to commit your work. Using Data Services 1815 LISTING An Insert Query Using the Data Services Client Library public ProductReview AddProductReview int ToProductId string Comments AdventureWorks2008Entities NewContext new AdventureWorks2008Entities _svcUri Product P from p in where ToProductId select p .FirstOrDefault ProductReview PR null if P null PR new ProductReview Comments Comments EmailAddress .

TỪ KHÓA LIÊN QUAN
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.