<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FC_Sharp%2FLINQ%2FCompound_from</id>
		<title>Csharp/C Sharp/LINQ/Compound from - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FC_Sharp%2FLINQ%2FCompound_from"/>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/C_Sharp/LINQ/Compound_from&amp;action=history"/>
		<updated>2026-04-29T18:03:35Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/C_Sharp/LINQ/Compound_from&amp;diff=458&amp;oldid=prev</id>
		<title> в 15:31, 26 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/C_Sharp/LINQ/Compound_from&amp;diff=458&amp;oldid=prev"/>
				<updated>2010-05-26T15:31:18Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 15:31, 26 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/C_Sharp/LINQ/Compound_from&amp;diff=459&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/C_Sharp/LINQ/Compound_from&amp;diff=459&amp;oldid=prev"/>
				<updated>2010-05-26T11:38:33Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Compound from: identifies ordered pairs of integers==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt; &lt;br /&gt;
using System;&lt;br /&gt;
using System.Collections.Generic;&lt;br /&gt;
using System.Linq;&lt;br /&gt;
using System.Text;&lt;br /&gt;
public class MainClass {&lt;br /&gt;
    public static void Main() {&lt;br /&gt;
        int[] numbersA = { 0, 2, 4, 5, 6, 8, 9 };&lt;br /&gt;
        int[] numbersB = { 1, 3, 5, 7, 8 };&lt;br /&gt;
        var pairs =&lt;br /&gt;
            from a in numbersA&lt;br /&gt;
            from b in numbersB&lt;br /&gt;
            where a &amp;lt; b&lt;br /&gt;
            select new { a, b };&lt;br /&gt;
        Console.WriteLine(&amp;quot;Pairs where a &amp;lt; b:&amp;quot;);&lt;br /&gt;
        foreach (var pair in pairs) {&lt;br /&gt;
            Console.WriteLine(&amp;quot;{0} is less than {1}&amp;quot;, pair.a, pair.b);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Compound from: prints all orders whose total is less that 500==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt; &lt;br /&gt;
using System;&lt;br /&gt;
using System.Collections.Generic;&lt;br /&gt;
using System.Linq;&lt;br /&gt;
using System.Text;&lt;br /&gt;
public class MainClass {&lt;br /&gt;
    public static void Main() {&lt;br /&gt;
        List&amp;lt;Customer&amp;gt; customers = GetCustomerList();&lt;br /&gt;
        var orders =&lt;br /&gt;
            from c in customers&lt;br /&gt;
            from o in c.Orders&lt;br /&gt;
            where o.Total &amp;lt; 500.00M&lt;br /&gt;
            select new { c.CustomerId, o.Id, o.Total };&lt;br /&gt;
        foreach(var p in orders){&lt;br /&gt;
            Console.WriteLine(p.CustomerId);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    static List&amp;lt;Customer&amp;gt; GetCustomerList() {&lt;br /&gt;
        List&amp;lt;Product&amp;gt; empTree = new List&amp;lt;Product&amp;gt;();&lt;br /&gt;
        empTree.Add(new Product { ProductName = &amp;quot;A&amp;quot;, Category = &amp;quot;O&amp;quot;, UnitPrice = 12, UnitsInStock = 5, Total = 36, OrderDate = new DateTime(2005, 1, 1), Id = 1 });&lt;br /&gt;
        empTree.Add(new Product { ProductName = &amp;quot;B&amp;quot;, Category = &amp;quot;O&amp;quot;, UnitPrice = 2, UnitsInStock = 4, Total = 35, OrderDate = new DateTime(2005, 1, 1), Id = 1 });&lt;br /&gt;
        empTree.Add(new Product { ProductName = &amp;quot;C&amp;quot;, Category = &amp;quot;O&amp;quot;, UnitPrice = 112, UnitsInStock = 3, Total = 34, OrderDate = new DateTime(2005, 1, 1), Id = 1 });&lt;br /&gt;
        empTree.Add(new Product { ProductName = &amp;quot;D&amp;quot;, Category = &amp;quot;O&amp;quot;, UnitPrice = 112, UnitsInStock = 0, Total = 33, OrderDate = new DateTime(2005, 1, 1), Id = 1 });&lt;br /&gt;
        empTree.Add(new Product { ProductName = &amp;quot;E&amp;quot;, Category = &amp;quot;O&amp;quot;, UnitPrice = 1112, UnitsInStock = 2, Total = 32, OrderDate = new DateTime(2005, 1, 1), Id = 1 });&lt;br /&gt;
        empTree.Add(new Product { ProductName = &amp;quot;F&amp;quot;, Category = &amp;quot;O&amp;quot;, UnitPrice = 11112, UnitsInStock = 0, Total = 31, OrderDate = new DateTime(2005, 1, 1), Id = 1 });&lt;br /&gt;
        List&amp;lt;Customer&amp;gt; l = new List&amp;lt;Customer&amp;gt;();&lt;br /&gt;
        l.Add(new Customer { CompanyName = &amp;quot;A&amp;quot;, Region = &amp;quot;R1&amp;quot;, UnitsInStock = 1, Orders = empTree, CustomerId = 0 });&lt;br /&gt;
        l.Add(new Customer { CompanyName = &amp;quot;B&amp;quot;, Region = &amp;quot;R2&amp;quot;, UnitsInStock = 2, Orders = empTree, CustomerId = 1 });&lt;br /&gt;
        l.Add(new Customer { CompanyName = &amp;quot;C&amp;quot;, Region = &amp;quot;R3&amp;quot;, UnitsInStock = 3, Orders = empTree, CustomerId = 2 });&lt;br /&gt;
        l.Add(new Customer { CompanyName = &amp;quot;D&amp;quot;, Region = &amp;quot;R4&amp;quot;, UnitsInStock = 4, Orders = empTree, CustomerId = 3 });&lt;br /&gt;
        l.Add(new Customer { CompanyName = &amp;quot;E&amp;quot;, Region = &amp;quot;R5&amp;quot;, UnitsInStock = 5, Orders = empTree, CustomerId = 4 });&lt;br /&gt;
        return l;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
class Customer : IComparable&amp;lt;Customer&amp;gt; {&lt;br /&gt;
    public string CompanyName { get; set; }&lt;br /&gt;
    public string Region { get; set; }&lt;br /&gt;
    public List&amp;lt;Product&amp;gt; Orders { get; set; }&lt;br /&gt;
    public int UnitsInStock { get; set; }&lt;br /&gt;
    public int CustomerId { get; set; }&lt;br /&gt;
    public override string ToString() {&lt;br /&gt;
        return String.Format(&amp;quot;Id: {0}, Name: {1}, Region: {3}&amp;quot;, this.CustomerId, this.rupanyName, this.Region);&lt;br /&gt;
    }&lt;br /&gt;
    int IComparable&amp;lt;Customer&amp;gt;.rupareTo(Customer other) {&lt;br /&gt;
        if (other == null)&lt;br /&gt;
            return 1;&lt;br /&gt;
        if (this.CustomerId &amp;gt; other.CustomerId)&lt;br /&gt;
            return 1;&lt;br /&gt;
        if (this.CustomerId &amp;lt; other.CustomerId)&lt;br /&gt;
            return -1;&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
class Product : IComparable&amp;lt;Product&amp;gt; {&lt;br /&gt;
    public string ProductName { get; set; }&lt;br /&gt;
    public string Category { get; set; }&lt;br /&gt;
    public int UnitPrice { get; set; }&lt;br /&gt;
    public int UnitsInStock { get; set; }&lt;br /&gt;
    public int Total { get; set; }&lt;br /&gt;
    public DateTime OrderDate { get; set; }&lt;br /&gt;
    public int Id { get; set; }&lt;br /&gt;
    public override string ToString() {&lt;br /&gt;
        return String.Format(&amp;quot;Id: {0}, Name: {1} , Category: {3}&amp;quot;, this.Id, this.ProductName, this.Category);&lt;br /&gt;
    }&lt;br /&gt;
    int IComparable&amp;lt;Product&amp;gt;.rupareTo(Product other) {&lt;br /&gt;
        if (other == null)&lt;br /&gt;
            return 1;&lt;br /&gt;
        if (this.Id &amp;gt; other.Id)&lt;br /&gt;
            return 1;&lt;br /&gt;
        if (this.Id &amp;lt; other.Id)&lt;br /&gt;
            return -1;&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==from Assignment: select all orders where the order total is greater than /td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt; &lt;br /&gt;
using System;&lt;br /&gt;
using System.Collections.Generic;&lt;br /&gt;
using System.Linq;&lt;br /&gt;
using System.Text;&lt;br /&gt;
public class MainClass {&lt;br /&gt;
    public static void Main() {&lt;br /&gt;
        List&amp;lt;Customer&amp;gt; customers = GetCustomerList();&lt;br /&gt;
    var orders =&lt;br /&gt;
        from c in customers&lt;br /&gt;
        from o in c.Orders&lt;br /&gt;
        where o.Total &amp;gt;= 35.0M&lt;br /&gt;
        select new { c.CustomerId, o.Id, o.Total };&lt;br /&gt;
        foreach (var p in orders) {&lt;br /&gt;
            Console.WriteLine(p.CustomerId);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    static List&amp;lt;Customer&amp;gt; GetCustomerList() {&lt;br /&gt;
        List&amp;lt;Product&amp;gt; empTree = new List&amp;lt;Product&amp;gt;();&lt;br /&gt;
        empTree.Add(new Product { ProductName = &amp;quot;A&amp;quot;, Category = &amp;quot;O&amp;quot;, UnitPrice = 12, UnitsInStock = 5, Total = 36, OrderDate = new DateTime(2005, 1, 1), Id = 1 });&lt;br /&gt;
        empTree.Add(new Product { ProductName = &amp;quot;B&amp;quot;, Category = &amp;quot;O&amp;quot;, UnitPrice = 2, UnitsInStock = 4, Total = 35, OrderDate = new DateTime(2005, 1, 1), Id = 1 });&lt;br /&gt;
        empTree.Add(new Product { ProductName = &amp;quot;C&amp;quot;, Category = &amp;quot;O&amp;quot;, UnitPrice = 112, UnitsInStock = 3, Total = 34, OrderDate = new DateTime(2005, 1, 1), Id = 1 });&lt;br /&gt;
        empTree.Add(new Product { ProductName = &amp;quot;D&amp;quot;, Category = &amp;quot;O&amp;quot;, UnitPrice = 112, UnitsInStock = 0, Total = 33, OrderDate = new DateTime(2005, 1, 1), Id = 1 });&lt;br /&gt;
        empTree.Add(new Product { ProductName = &amp;quot;E&amp;quot;, Category = &amp;quot;O&amp;quot;, UnitPrice = 1112, UnitsInStock = 2, Total = 32, OrderDate = new DateTime(2005, 1, 1), Id = 1 });&lt;br /&gt;
        empTree.Add(new Product { ProductName = &amp;quot;F&amp;quot;, Category = &amp;quot;O&amp;quot;, UnitPrice = 11112, UnitsInStock = 0, Total = 31, OrderDate = new DateTime(2005, 1, 1), Id = 1 });&lt;br /&gt;
        List&amp;lt;Customer&amp;gt; l = new List&amp;lt;Customer&amp;gt;();&lt;br /&gt;
        l.Add(new Customer { CompanyName = &amp;quot;A&amp;quot;, Region = &amp;quot;R1&amp;quot;, UnitsInStock = 1, Orders = empTree, CustomerId = 0 });&lt;br /&gt;
        l.Add(new Customer { CompanyName = &amp;quot;B&amp;quot;, Region = &amp;quot;R2&amp;quot;, UnitsInStock = 2, Orders = empTree, CustomerId = 1 });&lt;br /&gt;
        l.Add(new Customer { CompanyName = &amp;quot;C&amp;quot;, Region = &amp;quot;R3&amp;quot;, UnitsInStock = 3, Orders = empTree, CustomerId = 2 });&lt;br /&gt;
        l.Add(new Customer { CompanyName = &amp;quot;D&amp;quot;, Region = &amp;quot;R4&amp;quot;, UnitsInStock = 4, Orders = empTree, CustomerId = 3 });&lt;br /&gt;
        l.Add(new Customer { CompanyName = &amp;quot;E&amp;quot;, Region = &amp;quot;R5&amp;quot;, UnitsInStock = 5, Orders = empTree, CustomerId = 4 });&lt;br /&gt;
        return l;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
class Customer : IComparable&amp;lt;Customer&amp;gt; {&lt;br /&gt;
    public string CompanyName { get; set; }&lt;br /&gt;
    public string Region { get; set; }&lt;br /&gt;
    public List&amp;lt;Product&amp;gt; Orders { get; set; }&lt;br /&gt;
    public int UnitsInStock { get; set; }&lt;br /&gt;
    public int CustomerId { get; set; }&lt;br /&gt;
    public override string ToString() {&lt;br /&gt;
        return String.Format(&amp;quot;Id: {0}, Name: {1}, Region: {3}&amp;quot;, this.CustomerId, this.rupanyName, this.Region);&lt;br /&gt;
    }&lt;br /&gt;
    int IComparable&amp;lt;Customer&amp;gt;.rupareTo(Customer other) {&lt;br /&gt;
        if (other == null)&lt;br /&gt;
            return 1;&lt;br /&gt;
        if (this.CustomerId &amp;gt; other.CustomerId)&lt;br /&gt;
            return 1;&lt;br /&gt;
        if (this.CustomerId &amp;lt; other.CustomerId)&lt;br /&gt;
            return -1;&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
class Product : IComparable&amp;lt;Product&amp;gt; {&lt;br /&gt;
    public string ProductName { get; set; }&lt;br /&gt;
    public string Category { get; set; }&lt;br /&gt;
    public int UnitPrice { get; set; }&lt;br /&gt;
    public int UnitsInStock { get; set; }&lt;br /&gt;
    public int Total { get; set; }&lt;br /&gt;
    public DateTime OrderDate { get; set; }&lt;br /&gt;
    public int Id { get; set; }&lt;br /&gt;
    public override string ToString() {&lt;br /&gt;
        return String.Format(&amp;quot;Id: {0}, Name: {1} , Category: {3}&amp;quot;, this.Id, this.ProductName, this.Category);&lt;br /&gt;
    }&lt;br /&gt;
    int IComparable&amp;lt;Product&amp;gt;.rupareTo(Product other) {&lt;br /&gt;
        if (other == null)&lt;br /&gt;
            return 1;&lt;br /&gt;
        if (this.Id &amp;gt; other.Id)&lt;br /&gt;
            return 1;&lt;br /&gt;
        if (this.Id &amp;lt; other.Id)&lt;br /&gt;
            return -1;&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Multiple from: filtering on value list can be done before selecting their orders==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt; &lt;br /&gt;
using System;&lt;br /&gt;
using System.Collections.Generic;&lt;br /&gt;
using System.Linq;&lt;br /&gt;
using System.Text;&lt;br /&gt;
public class MainClass {&lt;br /&gt;
    public static void Main() {&lt;br /&gt;
        List&amp;lt;Customer&amp;gt; customers = GetCustomerList();&lt;br /&gt;
        DateTime cutoffDate = new DateTime(2005, 1, 1);&lt;br /&gt;
        var orders =&lt;br /&gt;
            from c in customers&lt;br /&gt;
            where c.Region == &amp;quot;R1&amp;quot;&lt;br /&gt;
            from o in c.Orders&lt;br /&gt;
            where o.OrderDate &amp;gt;= cutoffDate&lt;br /&gt;
            select new { c.CustomerId, o.Id };&lt;br /&gt;
    }&lt;br /&gt;
    static List&amp;lt;Customer&amp;gt; GetCustomerList() {&lt;br /&gt;
        List&amp;lt;Product&amp;gt; empTree = new List&amp;lt;Product&amp;gt;();&lt;br /&gt;
        empTree.Add(new Product { ProductName = &amp;quot;A&amp;quot;, Category = &amp;quot;O&amp;quot;, UnitPrice = 12, UnitsInStock = 5, Total = 36, OrderDate = new DateTime(2005, 1, 1), Id = 1 });&lt;br /&gt;
        empTree.Add(new Product { ProductName = &amp;quot;B&amp;quot;, Category = &amp;quot;O&amp;quot;, UnitPrice = 2, UnitsInStock = 4, Total = 35, OrderDate = new DateTime(2005, 1, 1), Id = 1 });&lt;br /&gt;
        empTree.Add(new Product { ProductName = &amp;quot;C&amp;quot;, Category = &amp;quot;O&amp;quot;, UnitPrice = 112, UnitsInStock = 3, Total = 34, OrderDate = new DateTime(2005, 1, 1), Id = 1 });&lt;br /&gt;
        empTree.Add(new Product { ProductName = &amp;quot;D&amp;quot;, Category = &amp;quot;O&amp;quot;, UnitPrice = 112, UnitsInStock = 0, Total = 33, OrderDate = new DateTime(2005, 1, 1), Id = 1 });&lt;br /&gt;
        empTree.Add(new Product { ProductName = &amp;quot;E&amp;quot;, Category = &amp;quot;O&amp;quot;, UnitPrice = 1112, UnitsInStock = 2, Total = 32, OrderDate = new DateTime(2005, 1, 1), Id = 1 });&lt;br /&gt;
        empTree.Add(new Product { ProductName = &amp;quot;F&amp;quot;, Category = &amp;quot;O&amp;quot;, UnitPrice = 11112, UnitsInStock = 0, Total = 31, OrderDate = new DateTime(2005, 1, 1), Id = 1 });&lt;br /&gt;
        List&amp;lt;Customer&amp;gt; l = new List&amp;lt;Customer&amp;gt;();&lt;br /&gt;
        l.Add(new Customer { CompanyName = &amp;quot;A&amp;quot;, Region = &amp;quot;R1&amp;quot;, UnitsInStock = 1, Orders = empTree, CustomerId = 0 });&lt;br /&gt;
        l.Add(new Customer { CompanyName = &amp;quot;B&amp;quot;, Region = &amp;quot;R2&amp;quot;, UnitsInStock = 2, Orders = empTree, CustomerId = 1 });&lt;br /&gt;
        l.Add(new Customer { CompanyName = &amp;quot;C&amp;quot;, Region = &amp;quot;R3&amp;quot;, UnitsInStock = 3, Orders = empTree, CustomerId = 2 });&lt;br /&gt;
        l.Add(new Customer { CompanyName = &amp;quot;D&amp;quot;, Region = &amp;quot;R4&amp;quot;, UnitsInStock = 4, Orders = empTree, CustomerId = 3 });&lt;br /&gt;
        l.Add(new Customer { CompanyName = &amp;quot;E&amp;quot;, Region = &amp;quot;R5&amp;quot;, UnitsInStock = 5, Orders = empTree, CustomerId = 4 });&lt;br /&gt;
        return l;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
class Customer : IComparable&amp;lt;Customer&amp;gt; {&lt;br /&gt;
    public string CompanyName { get; set; }&lt;br /&gt;
    public string Region { get; set; }&lt;br /&gt;
    public List&amp;lt;Product&amp;gt; Orders { get; set; }&lt;br /&gt;
    public int UnitsInStock { get; set; }&lt;br /&gt;
    public int CustomerId { get; set; }&lt;br /&gt;
    public override string ToString() {&lt;br /&gt;
        return String.Format(&amp;quot;Id: {0}, Name: {1}, Region: {3}&amp;quot;, this.CustomerId, this.rupanyName, this.Region);&lt;br /&gt;
    }&lt;br /&gt;
    int IComparable&amp;lt;Customer&amp;gt;.rupareTo(Customer other) {&lt;br /&gt;
        if (other == null)&lt;br /&gt;
            return 1;&lt;br /&gt;
        if (this.CustomerId &amp;gt; other.CustomerId)&lt;br /&gt;
            return 1;&lt;br /&gt;
        if (this.CustomerId &amp;lt; other.CustomerId)&lt;br /&gt;
            return -1;&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
class Product : IComparable&amp;lt;Product&amp;gt; {&lt;br /&gt;
    public string ProductName { get; set; }&lt;br /&gt;
    public string Category { get; set; }&lt;br /&gt;
    public int UnitPrice { get; set; }&lt;br /&gt;
    public int UnitsInStock { get; set; }&lt;br /&gt;
    public int Total { get; set; }&lt;br /&gt;
    public DateTime OrderDate { get; set; }&lt;br /&gt;
    public int Id { get; set; }&lt;br /&gt;
    public override string ToString() {&lt;br /&gt;
        return String.Format(&amp;quot;Id: {0}, Name: {1} , Category: {3}&amp;quot;, this.Id, this.ProductName, this.Category);&lt;br /&gt;
    }&lt;br /&gt;
    int IComparable&amp;lt;Product&amp;gt;.rupareTo(Product other) {&lt;br /&gt;
        if (other == null)&lt;br /&gt;
            return 1;&lt;br /&gt;
        if (this.Id &amp;gt; other.Id)&lt;br /&gt;
            return 1;&lt;br /&gt;
        if (this.Id &amp;lt; other.Id)&lt;br /&gt;
            return -1;&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==prints the customer number and orderID for every order in the list==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt; &lt;br /&gt;
using System;&lt;br /&gt;
using System.Collections.Generic;&lt;br /&gt;
using System.Linq;&lt;br /&gt;
using System.Text;&lt;br /&gt;
public class MainClass {&lt;br /&gt;
    public static void Main() {&lt;br /&gt;
        List&amp;lt;Customer&amp;gt; customers = GetCustomerList();&lt;br /&gt;
        var customerOrders =&lt;br /&gt;
            customers.SelectMany(&lt;br /&gt;
                (cust, custIndex) =&amp;gt;&lt;br /&gt;
                cust.Orders.Select(o =&amp;gt; &amp;quot;Customer #&amp;quot; + (custIndex + 1) +&lt;br /&gt;
                                        &amp;quot; has a peoduct  with ProductID &amp;quot; + o.Id));&lt;br /&gt;
        foreach (var v in customerOrders) {&lt;br /&gt;
            Console.WriteLine(v);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    static List&amp;lt;Customer&amp;gt; GetCustomerList() {&lt;br /&gt;
        List&amp;lt;Product&amp;gt; empTree = new List&amp;lt;Product&amp;gt;();&lt;br /&gt;
        empTree.Add(new Product { ProductName = &amp;quot;A&amp;quot;, Category = &amp;quot;O&amp;quot;, UnitPrice = 12, UnitsInStock = 5, Total = 36, OrderDate = new DateTime(2005, 1, 1), Id = 1 });&lt;br /&gt;
        empTree.Add(new Product { ProductName = &amp;quot;B&amp;quot;, Category = &amp;quot;O&amp;quot;, UnitPrice = 2, UnitsInStock = 4, Total = 35, OrderDate = new DateTime(2005, 1, 1), Id = 1 });&lt;br /&gt;
        empTree.Add(new Product { ProductName = &amp;quot;C&amp;quot;, Category = &amp;quot;O&amp;quot;, UnitPrice = 112, UnitsInStock = 3, Total = 34, OrderDate = new DateTime(2005, 1, 1), Id = 1 });&lt;br /&gt;
        empTree.Add(new Product { ProductName = &amp;quot;D&amp;quot;, Category = &amp;quot;O&amp;quot;, UnitPrice = 112, UnitsInStock = 0, Total = 33, OrderDate = new DateTime(2005, 1, 1), Id = 1 });&lt;br /&gt;
        empTree.Add(new Product { ProductName = &amp;quot;E&amp;quot;, Category = &amp;quot;O&amp;quot;, UnitPrice = 1112, UnitsInStock = 2, Total = 32, OrderDate = new DateTime(2005, 1, 1), Id = 1 });&lt;br /&gt;
        empTree.Add(new Product { ProductName = &amp;quot;F&amp;quot;, Category = &amp;quot;O&amp;quot;, UnitPrice = 11112, UnitsInStock = 0, Total = 31, OrderDate = new DateTime(2005, 1, 1), Id = 1 });&lt;br /&gt;
        List&amp;lt;Customer&amp;gt; l = new List&amp;lt;Customer&amp;gt;();&lt;br /&gt;
        l.Add(new Customer { CompanyName = &amp;quot;A&amp;quot;, Region = &amp;quot;R1&amp;quot;, UnitsInStock = 1, Orders = empTree, CustomerId = 0 });&lt;br /&gt;
        l.Add(new Customer { CompanyName = &amp;quot;B&amp;quot;, Region = &amp;quot;R2&amp;quot;, UnitsInStock = 2, Orders = empTree, CustomerId = 1 });&lt;br /&gt;
        l.Add(new Customer { CompanyName = &amp;quot;C&amp;quot;, Region = &amp;quot;R3&amp;quot;, UnitsInStock = 3, Orders = empTree, CustomerId = 2 });&lt;br /&gt;
        l.Add(new Customer { CompanyName = &amp;quot;D&amp;quot;, Region = &amp;quot;R4&amp;quot;, UnitsInStock = 4, Orders = empTree, CustomerId = 3 });&lt;br /&gt;
        l.Add(new Customer { CompanyName = &amp;quot;E&amp;quot;, Region = &amp;quot;R5&amp;quot;, UnitsInStock = 5, Orders = empTree, CustomerId = 4 });&lt;br /&gt;
        return l;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
class Customer : IComparable&amp;lt;Customer&amp;gt; {&lt;br /&gt;
    public string CompanyName { get; set; }&lt;br /&gt;
    public string Region { get; set; }&lt;br /&gt;
    public List&amp;lt;Product&amp;gt; Orders { get; set; }&lt;br /&gt;
    public int UnitsInStock { get; set; }&lt;br /&gt;
    public int CustomerId { get; set; }&lt;br /&gt;
    public override string ToString() {&lt;br /&gt;
        return String.Format(&amp;quot;Id: {0}, Name: {1}, Region: {3}&amp;quot;, this.CustomerId, this.rupanyName, this.Region);&lt;br /&gt;
    }&lt;br /&gt;
    int IComparable&amp;lt;Customer&amp;gt;.rupareTo(Customer other) {&lt;br /&gt;
        if (other == null)&lt;br /&gt;
            return 1;&lt;br /&gt;
        if (this.CustomerId &amp;gt; other.CustomerId)&lt;br /&gt;
            return 1;&lt;br /&gt;
        if (this.CustomerId &amp;lt; other.CustomerId)&lt;br /&gt;
            return -1;&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
class Product : IComparable&amp;lt;Product&amp;gt; {&lt;br /&gt;
    public string ProductName { get; set; }&lt;br /&gt;
    public string Category { get; set; }&lt;br /&gt;
    public int UnitPrice { get; set; }&lt;br /&gt;
    public int UnitsInStock { get; set; }&lt;br /&gt;
    public int Total { get; set; }&lt;br /&gt;
    public DateTime OrderDate { get; set; }&lt;br /&gt;
    public int Id { get; set; }&lt;br /&gt;
    public override string ToString() {&lt;br /&gt;
        return String.Format(&amp;quot;Id: {0}, Name: {1} , Category: {3}&amp;quot;, this.Id, this.ProductName, this.Category);&lt;br /&gt;
    }&lt;br /&gt;
    int IComparable&amp;lt;Product&amp;gt;.rupareTo(Product other) {&lt;br /&gt;
        if (other == null)&lt;br /&gt;
            return 1;&lt;br /&gt;
        if (this.Id &amp;gt; other.Id)&lt;br /&gt;
            return 1;&lt;br /&gt;
        if (this.Id &amp;lt; other.Id)&lt;br /&gt;
            return -1;&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==uses a compound from clause to select all orders where the order was made in r later.==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt; &lt;br /&gt;
using System;&lt;br /&gt;
using System.Collections.Generic;&lt;br /&gt;
using System.Linq;&lt;br /&gt;
using System.Text;&lt;br /&gt;
public class MainClass {&lt;br /&gt;
    public static void Main() {&lt;br /&gt;
        List&amp;lt;Customer&amp;gt; customers = GetCustomerList();&lt;br /&gt;
        var orders =&lt;br /&gt;
            from c in customers&lt;br /&gt;
            from o in c.Orders&lt;br /&gt;
            where o.OrderDate &amp;gt;= new DateTime(1998, 1, 1)&lt;br /&gt;
            select new { c.CustomerId, o.Id, o.OrderDate };&lt;br /&gt;
        foreach (var p in orders) {&lt;br /&gt;
            Console.WriteLine(p.CustomerId);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    static List&amp;lt;Customer&amp;gt; GetCustomerList() {&lt;br /&gt;
        List&amp;lt;Product&amp;gt; empTree = new List&amp;lt;Product&amp;gt;();&lt;br /&gt;
        empTree.Add(new Product { ProductName = &amp;quot;A&amp;quot;, Category = &amp;quot;O&amp;quot;, UnitPrice = 12, UnitsInStock = 5, Total = 36, OrderDate = new DateTime(2005, 1, 1), Id = 1 });&lt;br /&gt;
        empTree.Add(new Product { ProductName = &amp;quot;B&amp;quot;, Category = &amp;quot;O&amp;quot;, UnitPrice = 2, UnitsInStock = 4, Total = 35, OrderDate = new DateTime(2005, 1, 1), Id = 1 });&lt;br /&gt;
        empTree.Add(new Product { ProductName = &amp;quot;C&amp;quot;, Category = &amp;quot;O&amp;quot;, UnitPrice = 112, UnitsInStock = 3, Total = 34, OrderDate = new DateTime(2005, 1, 1), Id = 1 });&lt;br /&gt;
        empTree.Add(new Product { ProductName = &amp;quot;D&amp;quot;, Category = &amp;quot;O&amp;quot;, UnitPrice = 112, UnitsInStock = 0, Total = 33, OrderDate = new DateTime(2005, 1, 1), Id = 1 });&lt;br /&gt;
        empTree.Add(new Product { ProductName = &amp;quot;E&amp;quot;, Category = &amp;quot;O&amp;quot;, UnitPrice = 1112, UnitsInStock = 2, Total = 32, OrderDate = new DateTime(2005, 1, 1), Id = 1 });&lt;br /&gt;
        empTree.Add(new Product { ProductName = &amp;quot;F&amp;quot;, Category = &amp;quot;O&amp;quot;, UnitPrice = 11112, UnitsInStock = 0, Total = 31, OrderDate = new DateTime(2005, 1, 1), Id = 1 });&lt;br /&gt;
        List&amp;lt;Customer&amp;gt; l = new List&amp;lt;Customer&amp;gt;();&lt;br /&gt;
        l.Add(new Customer { CompanyName = &amp;quot;A&amp;quot;, Region = &amp;quot;R1&amp;quot;, UnitsInStock = 1, Orders = empTree, CustomerId = 0 });&lt;br /&gt;
        l.Add(new Customer { CompanyName = &amp;quot;B&amp;quot;, Region = &amp;quot;R2&amp;quot;, UnitsInStock = 2, Orders = empTree, CustomerId = 1 });&lt;br /&gt;
        l.Add(new Customer { CompanyName = &amp;quot;C&amp;quot;, Region = &amp;quot;R3&amp;quot;, UnitsInStock = 3, Orders = empTree, CustomerId = 2 });&lt;br /&gt;
        l.Add(new Customer { CompanyName = &amp;quot;D&amp;quot;, Region = &amp;quot;R4&amp;quot;, UnitsInStock = 4, Orders = empTree, CustomerId = 3 });&lt;br /&gt;
        l.Add(new Customer { CompanyName = &amp;quot;E&amp;quot;, Region = &amp;quot;R5&amp;quot;, UnitsInStock = 5, Orders = empTree, CustomerId = 4 });&lt;br /&gt;
        return l;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
class Customer : IComparable&amp;lt;Customer&amp;gt; {&lt;br /&gt;
    public string CompanyName { get; set; }&lt;br /&gt;
    public string Region { get; set; }&lt;br /&gt;
    public List&amp;lt;Product&amp;gt; Orders { get; set; }&lt;br /&gt;
    public int UnitsInStock { get; set; }&lt;br /&gt;
    public int CustomerId { get; set; }&lt;br /&gt;
    public override string ToString() {&lt;br /&gt;
        return String.Format(&amp;quot;Id: {0}, Name: {1}, Region: {3}&amp;quot;, this.CustomerId, this.rupanyName, this.Region);&lt;br /&gt;
    }&lt;br /&gt;
    int IComparable&amp;lt;Customer&amp;gt;.rupareTo(Customer other) {&lt;br /&gt;
        if (other == null)&lt;br /&gt;
            return 1;&lt;br /&gt;
        if (this.CustomerId &amp;gt; other.CustomerId)&lt;br /&gt;
            return 1;&lt;br /&gt;
        if (this.CustomerId &amp;lt; other.CustomerId)&lt;br /&gt;
            return -1;&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
class Product : IComparable&amp;lt;Product&amp;gt; {&lt;br /&gt;
    public string ProductName { get; set; }&lt;br /&gt;
    public string Category { get; set; }&lt;br /&gt;
    public int UnitPrice { get; set; }&lt;br /&gt;
    public int UnitsInStock { get; set; }&lt;br /&gt;
    public int Total { get; set; }&lt;br /&gt;
    public DateTime OrderDate { get; set; }&lt;br /&gt;
    public int Id { get; set; }&lt;br /&gt;
    public override string ToString() {&lt;br /&gt;
        return String.Format(&amp;quot;Id: {0}, Name: {1} , Category: {3}&amp;quot;, this.Id, this.ProductName, this.Category);&lt;br /&gt;
    }&lt;br /&gt;
    int IComparable&amp;lt;Product&amp;gt;.rupareTo(Product other) {&lt;br /&gt;
        if (other == null)&lt;br /&gt;
            return 1;&lt;br /&gt;
        if (this.Id &amp;gt; other.Id)&lt;br /&gt;
            return 1;&lt;br /&gt;
        if (this.Id &amp;lt; other.Id)&lt;br /&gt;
            return -1;&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>