[LINQ] subset 부분 집합 구하기
Selecting a Subset of each Source Element
There are two primary ways to select a subset of each element in the source sequence:
To select just one member of the source element, use the dot operation. In the following example, assume that a Customer object contains several public properties including a string named City. When executed, this query will produce an output sequence of strings.
var query = from cust in Customers select cust.City;
To create elements that contain more than one property from the source element, you can use an object initializer with either a named object or an anonymous type. The following example shows the use of an anonymous type to encapsulate two properties from each Customer element:
var query = from cust in Customer select new {Name = cust.Name, City = cust.City};
For more information, see Object and Collection Initializers (C# Programming Guide) and Anonymous Types (C# Programming Guide).