Barefoot learning LINQ (005): join query between data tables

Source: Internet
Author: User

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

There is no explicitly modeled sequence Association in the data source created by the join operation. For example, you can perform connections to find all customers that meet the following criteria: in Paris, and order products from a supplier located in London. In LINQ, the join clause always runs on an object set instead of a database table. In LINQ, you do not need to use join as frequently as in SQL, because the foreign key in LINQ is represented as an attribute that contains the item set in the object model. For example, a customer object contains a set of order objects. You do not need to perform the join operation. You only need to use the dot notation to access the order:

Northwinddatacontext DB = new northwinddatacontext (); var allcustomers = from customer in dB. customers select customer; foreach (VAR customer in allcustomers) {console. writeline ("---------------------"); console. writeline ("Customer ID: {0}", customer. customerid); console. writeline ("customer name: {0}", customer. contactname); foreach (VAR order in customer. orders) {console. writeline ("Order ID: {0}", order. orderid );}}

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.