TAILIEUCHUNG - Apress Expert C sharp 2005 (Phần 10)

Tham khảo tài liệu 'apress expert c sharp 2005 (phần 10)', 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ả | 2 26 06 10 02 PM Page 424 424 CHAPTER 8 BUSINESS OBJECT IMPLEMENTATION Notice how the code directly alters the instance fields of the object. For instance the _id field is set to a new Guid value. Since the Id property is read-only this is the only way to load the Id property with a new value. While the Started property is read-write and could be set through the property it is more efficient and consistent to directly set the _started field. Since not all properties can be set it is best to be consistent and always set fields directly. Additionally the call will apply all the validation rules in the entire object. Setting a property causes the validation rules for that property to be checked so setting property values would cause validation rules to be run twice which is wasteful. Setting the fields and then calling CheckRules means validation rules are run only once. Of course the default values set in a new object might not conform to the object s validation rules. In fact the Name property starts out as an empty string value which means it is invalid since that is a required property. Remember that this was specified in the AddBusinessRules method by associating this property with the StringRequired rule method. To ensure that all validation rules are run against the newly created object s data is called. Calling this method with no parameters causes it to run all the validation rules associated with all properties of the object as defined in the object s AddBusinessRules method. The end result is that the new object has been loaded with default values and those values have been validated. The new object is then returned by the data portal to the factory method NewProject in this case which typically returns it to the UI code. DataPortal_Fetch More interesting and complexis the DataPortal_Fetch method which is called by the data portal to tell the object that it should load its data from .

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.