public class Product
{
    public int ProductID { get; set; }
    public string ProductName { get; set; }
    public string Category { get; set; }
    public decimal UnitPrice { get; set; }
    public int UnitsInStock { get; set; }
}
    
public class Order
{
    public int OrderID { get; set; }
    public DateTime OrderDate { get; set; }
    public decimal Total { get; set; }
}

public class Customer
{
    public string CustomerID { get; set; }
    public string CompanyName { get; set; }
    public string Address { get; set; }
    public string City { get; set; }
    public string Region { get; set; }
    public string PostalCode { get; set; }
    public string Country { get; set; }
    public string Phone { get; set; }
    public string Fax { get; set; }
    public Order[] Orders { get; set; }
}
        
public class Supplier
{
    public string SupplierName { get; set; }
    public string Address { get; set; }
    public string City { get; set; }
    public string Country { get; set; }
}
        
public class CaseInsensitiveComparer : IComparer<string>
{
    public int Compare(string x, string y)
    {
        return string.Compare(x, y, StringComparison.OrdinalIgnoreCase);
    }
}
        
private class AnagramEqualityComparer : IEqualityComparer<string>
{
    public bool Equals(string x, string y)
    {
        return getCanonicalString(x) == getCanonicalString(y);
    }

    public int GetHashCode(string obj)
    {
        return getCanonicalString(obj).GetHashCode();
    }

    private string getCanonicalString(string word)
    {
        char[] wordChars = word.ToCharArray();
        Array.Sort<char>(wordChars);
        return new string(wordChars);
    }
}
        
owenG
home learn tableau about
divider
LINQ quiz








divider element

public class Product
{
    public int ProductID { get; set; }
    public string ProductName { get; set; }
    public string Category { get; set; }
    public decimal UnitPrice { get; set; }
    public int UnitsInStock { get; set; }
}

public class Order
{
    public int OrderID { get; set; }
    public DateTime OrderDate { get; set; }
    public decimal Total { get; set; }
}

public class Customer
{
    public string CustomerID { get; set; }
    public string CompanyName { get; set; }
    public string Address { get; set; }
    public string City { get; set; }
    public string Region { get; set; }
    public string PostalCode { get; set; }
    public string Country { get; set; }
    public string Phone { get; set; }
    public string Fax { get; set; }
    public Order[] Orders { get; set; }
}

public class Supplier
{
    public string SupplierName { get; set; }
    public string Address { get; set; }
    public string City { get; set; }
    public string Country { get; set; }
}

public static class LinqData
{
  public static List<Product> productList = new List<Product> {
    new Product { ProductID = 1, ProductName = "Chai", Category = "Beverages", UnitPrice = 18.0000M, 
        UnitsInStock = 39 },
    new Product { ProductID = 2, ProductName = "Chang", Category = "Beverages", UnitPrice = 19.0000M, 
        UnitsInStock = 17 },
    new Product { ProductID = 3, ProductName = "Aniseed Syrup", Category = "Condiments", UnitPrice = 10.0000M, 
        UnitsInStock = 13 },
    new Product { ProductID = 4, ProductName = "Chef Anton's Cajun Seasoning", Category = "Condiments", 
        UnitPrice = 22.0000M, UnitsInStock = 53 },
    new Product { ProductID = 5, ProductName = "Chef Anton's Gumbo Mix", Category = "Condiments", UnitPrice = 21.3500M, 
        UnitsInStock = 0 },
    new Product { ProductID = 6, ProductName = "Grandma's Boysenberry Spread", Category = "Condiments", 
        UnitPrice = 25.0000M, UnitsInStock = 120 },
    new Product { ProductID = 7, ProductName = "Uncle Bob's Organic Dried Pears", Category = "Produce", 
        UnitPrice = 30.0000M, UnitsInStock = 15 },
    new Product { ProductID = 8, ProductName = "Northwoods Cranberry Sauce", Category = "Condiments", UnitPrice = 2.0000M, 
        UnitsInStock = 0 },
    new Product { ProductID = 31, ProductName = "Gorgonzola Telino", Category = "Dairy Products", UnitPrice = 12.5000M, 
        UnitsInStock = 0 },
    };

public static List<Supplier> supplierList = new List<Supplier> {
    new Supplier {SupplierName = "New Orleans Cajun Delights", Address = "P.O. Box 78934", 
        City = "New Orleans", Country = "USA"},
    new Supplier {SupplierName = "Grandma Kelly's Homestead", Address = "707 Oxford Rd.", 
        City = "Ann Arbor", Country = "USA"},
    new Supplier {SupplierName = "Nord-Ost-Fisch Handelsgesellschaft mbH", Address = "Frahmredder 112a", 
        City = "Cuxhaven", Country = "Germany"},
    new Supplier {SupplierName = "New England Seafood Cannery", Address = "Order Processing Dept. 2100 Paul Revere Blvd.", 
        City = "Boston", Country = "USA"},
    new Supplier {SupplierName = "Exotic Liquids", Address = "49 Gilbert St.", 
        City = "London", Country = "UK"},
    new Supplier {SupplierName = "Plutzer Lebensmittelgroßmärkte AG", Address = "Bogenallee 51", 
        City = "Frankfurt", Country = "Germany"},
    new Supplier {SupplierName = "Tokyo Traders", Address = "9-8 Sekimai Musashino-shi", 
        City = "Tokyo", Country = "Japan"},
    new Supplier {SupplierName = "Cooperativa de Quesos 'Las Cabras'", Address = "Calle del Rosal 4", 
        City = "Oviedo", Country = "Spain"},
    };


public static List<Customer> customerList =
    new List<Customer> {

    new Customer { CustomerID = "LAZYK", CompanyName = "Lazy K Kountry Store",  Address = "12 Orchestra Terrace", 
        City = "Walla Walla", Region = "WA", PostalCode = "99362", Country = "USA", Phone = "(509) 555-7969", 
        Fax = "(509) 555-6221",
            Orders = new Order[]{
                    new Order { OrderID=10482, OrderDate=Convert.ToDateTime("3/21/1997 12:00:00 AM"), Total=147.00M},
                    new Order { OrderID=10545, OrderDate=Convert.ToDateTime("5/22/1997 12:00:00 AM"), Total=210.00M},
                    }
            },
                
    new Customer { CustomerID = "ALFKI", CompanyName = "Alfreds Futterkiste",  Address = "Obere Str. 57", 
        City = "Berlin", Region = "", PostalCode = "12209", Country = "Germany", Phone = "030-0074321", 
        Fax = "030-0076545",
            Orders = new Order[]{
                    new Order { OrderID=10643, OrderDate=Convert.ToDateTime("8/25/1997 12:00:00 AM"), Total=814.50M},
                    new Order { OrderID=10692, OrderDate=Convert.ToDateTime("10/3/1997 12:00:00 AM"), Total=878.00M},
                    new Order { OrderID=10702, OrderDate=Convert.ToDateTime("10/13/1997 12:00:00 AM"), Total=330.00M},
                    new Order { OrderID=10835, OrderDate=Convert.ToDateTime("1/15/1998 12:00:00 AM"), Total=845.80M},
                    new Order { OrderID=10952, OrderDate=Convert.ToDateTime("3/16/1998 12:00:00 AM"), Total=471.20M},
                    new Order { OrderID=11011, OrderDate=Convert.ToDateTime("4/9/1998 12:00:00 AM"), Total=933.50M},
                    }
            },
    new Customer { CustomerID = "ANATR", CompanyName = "Ana Trujillo helados",  Address = "Avda. de la Constitución 2222", 
        City = "México D.F.", Region = "", PostalCode = "05021", Country = "Mexico", Phone = "(5) 555-4729", 
        Fax = "(5) 555-3745",
            Orders = new Order[]{
                    new Order { OrderID=10308, OrderDate=Convert.ToDateTime("9/18/1996 12:00:00 AM"), Total=88.80M},
                    new Order { OrderID=10625, OrderDate=Convert.ToDateTime("8/8/1997 12:00:00 AM"), Total=479.75M},
                    new Order { OrderID=10759, OrderDate=Convert.ToDateTime("11/28/1997 12:00:00 AM"), Total=320.00M},
                    new Order { OrderID=10926, OrderDate=Convert.ToDateTime("3/4/1998 12:00:00 AM"), Total=514.40M},
                    }
            },
    new Customer { CustomerID = "CACTU", CompanyName = "Cactus Comidas para llevar",  Address = "Cerrito 333", 
        City = "Buenos Aires", Region = "", PostalCode = "1010", Country = "Argentina", Phone = "(1) 135-5555", 
        Fax = "(1) 135-4892",
            Orders = new Order[]{
                    new Order { OrderID=10521, OrderDate=Convert.ToDateTime("4/29/1997 12:00:00 AM"), Total=225.50M},
                    new Order { OrderID=10782, OrderDate=Convert.ToDateTime("12/17/1997 12:00:00 AM"), Total=12.50M},
                    new Order { OrderID=10819, OrderDate=Convert.ToDateTime("1/7/1998 12:00:00 AM"), Total=477.00M},
                    new Order { OrderID=10881, OrderDate=Convert.ToDateTime("2/11/1998 12:00:00 AM"), Total=150.00M},
                    new Order { OrderID=10937, OrderDate=Convert.ToDateTime("3/10/1998 12:00:00 AM"), Total=644.80M},
                    new Order { OrderID=11054, OrderDate=Convert.ToDateTime("4/28/1998 12:00:00 AM"), Total=305.00M},
                    }
            },
    new Customer { CustomerID = "CENTC", CompanyName = "Centro comercial Moctezuma",  Address = "Sierras de Granada 9993", 
        City = "México D.F.", Region = "", PostalCode = "05022", Country = "Mexico", Phone = "(5) 555-3392", 
        Fax = "(5) 555-7293",
            Orders = new Order[]{
                    new Order { OrderID=10259, OrderDate=Convert.ToDateTime("7/18/1996 12:00:00 AM"), Total=100.80M},
                    }
            },

    };
};