Controlling the Names Used in a Strongly Typed DataSet

[ Team LiB ] Recipe Controlling the Names Used in a Strongly Typed DataSet Problem You want to assign your own names to the classes and properties for strongly typed DataSet classes. Solution Use annotations in the XML schema to control the names of classes and properties in strongly typed DataSet classes. The sample uses one XSD file: CategoriesDS_AnnotatedNa | Team LiB Recipe Controlling the Names Used in a Strongly Typed DataSet Problem You want to assign your own names to the classes and properties for strongly typed DataSet classes. Solution Use annotations in the XML schema to control the names of classes and properties in strongly typed DataSet classes. The sample uses one XSD file The schema used to generate the strongly typed DataSet. The schema is annotated so that you can access the collection of rows in the table by using the Categorys property of the DataSet rather than categories each row by using the Category property of the row collection rather than CategoriesRow and the CategoryName field by using the Name property of the row rather than CategoryName. The annotations are marked in bold in the Example 2-23. Example 2-23. File TypedDataSets xml version standalone yes xs schema id CategoriesDS_AnnotatedName targetNamespace http xmlns mstns http xmlns http xmlns xs http 2001 XMLSchema xmlns msdata urn schemas-microsoft-com xml-msdata xmlns codegen urn schemas-microsoft-com xml-msprop attributeFormDefault qualified elementFormDefault qualified xs element name CategoriesDS_AnnotatedName msdata IsDataSet true xs complexType xs choice maxOccurs unbounded xs element name Categories codegen typedName Category codegen typedPlural Categorys xs complexType xs sequence xs element name CategoryID msdata ReadOnly true msdata AutoIncrement true type xs int xs element name CategoryName type xs string codegen typedName Name xs element name Description type xs string minOccurs 0 xs sequence xs complexType xs element xs choice xs complexType xs unique name Constraint1 msdata PrimaryKey true xs selector xpath . mstns Categories xs field xpath mstns CategoryID xs unique xs element xs schema The sample code .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
Đã 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.