Barefoot learning LINQ (006): Projection

Source: Internet
Author: User

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

SelectClause to generate query results and specify the "shape" or type of each returned element. For example, you can specify whether the result contains the entire customer object, only one member, a subset of the members, or a completely different result type created based on the calculation or new object. When the select clause generates content other than the Source Element copy, this operation is called "projection ". Using Projection to convert data is a powerful function of the LINQ query expression.

Northwinddatacontext DB = new northwinddatacontext (); var allcustomers = from customer in dB. customers select new {customer. contactname, customer. country}; foreach (VAR customer in allcustomers) {console. writeline ("---------------------"); console. writeline ("customer name: {0}", customer. contactname); console. writeline ("Country: {0}", customer. country );}

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.