Đang chuẩn bị liên kết để tải về tài liệu:
Apress Expert C sharp 2005 (Phần 5)
Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Tham khảo tài liệu 'apress expert c sharp 2005 (phần 5)', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | 6323_c04_final.qxd 2 27 06 1 25 PM Page 174 174 CHAPTER 4 DATA ACCESS AND SECURITY In either case it is the DataPortal.Update call that ultimately triggers the data portal infrastructure to move the object to the application server so it can interact with the database. It is important to notice that the Save method returns an instance of the business object. Recall that .NET doesn t actually move objects across the network rather it makes copies of the objects. The DataPortal.Update call causes .NET to copy this object to the server so the copy can update itself into the database. That process could change the state of the object especially if you are using primary keys assigned by the database or timestamps for concurrency . The resulting object is then copied back to the client and returned as a result of the Save method. Note It is critical that the UI update all its references to use the new object returned by Save . Failure to do this means that the UI will be displaying and editing old data from the old version of the object. Data Portal Methods As noted earlier the data portal places certain constraints on business objects. Specifically it needs to know what methods it can invoke on the server. The data portal will invoke the methods listed in Table 4-10 though not all framework base classes need to implement all the methods. Collectively I ll refer to these methods as the DataPortalXYZ methods. Table 4-10. Business Object Methods Invoked by the Data Portal Method Purpose DataPortal_Create An editable business object implements this method to load itself with default values required for a new object. DataPortal_Fetch An editable or read-only business object implements this method to load itself with existing data from the database. DataPortal_Insert An editable business object implements this method to insert its data into the database. DataPortal_Update An editable business object implements this method to update its data in the database. .