Barefoot learning LINQ (034): The thiskey of the definition of the ing relationship

Source: Internet
Author: User

Http://u.115.com/file/f2a1ed628e demo

Demonstration highlights
To establish a ing between two object classes, you only need to correctly set the three attributes of columnattribute: storage, thiskey, and otherkey. If the field of the object class is used rather than the attribute, even the storage attribute can be omitted.
No matter how the ing relationship is established, the most fundamental purpose is to obtain some other objects associated with an object. For example, after obtaining a customer object, we obtain all the order objects associated with it through a set attribute of the customer object. Therefore, if you want to obtain the associated data successfully by using LINQ to SQL, you must provide at least three pieces of information:
1. Data Retrieval conditions. For example, the Order record of the customer to be retrieved.
2. From which table to search. For example, these order records are stored in the data table of the database.
3. Use the search condition to compare the data column. For example, the customer ID is stored in the column of the data table that stores the order record.
When this information is met, the associated data can be correctly obtained.
The thiskey attribute is used to provide the data to be retrieved. This attribute value is actually a key-Value Attribute of the object class, and the attribute value of this key-Value Attribute specifies the data to be retrieved.
Otherkey is used to specify the column to be judged by conditions in the WHERE clause. This attribute value is also a key-Value Attribute of the object class, however, this time, the attribute value of this key-value property is not required, but the name of the data column mapped to this key-value property is required.
As for the data table from which to retrieve the associated data, this determines the object type to be obtained. It is actually the data table mapped by the object class.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.