static void Main(string[] args) { LinqSamples samples = new LinqSamples(); // Comment or uncomment the method calls below to run or not samples.DataSetLinq6(); // This sample uses select to produce a sequence of ints one higher than those in an existing array of ints. samples.DataSetLinq7(); // This sample uses select to return a sequence of just the names of a list of products. Console.ReadKey(); samples.DataSetLinq8(); // This sample uses select to produce a sequence of strings representing the text version of a sequence of ints. Console.ReadKey(); samples.DataSetLinq9(); // This sample uses select to produce a sequence of the uppercase and lowercase versions of each word in the original array. Console.ReadKey(); samples.DataSetLinq10(); // This sample uses select to produce a sequence containing text representations of digits and whether their length is even or odd. Console.ReadKey(); samples.DataSetLinq11(); // This sample uses select to produce a sequence containing some properties of Products... Console.ReadKey(); samples.DataSetLinq12(); // This sample uses an indexed Select clause to determine if the value of ints in an array match their position in the array. Console.ReadKey(); samples.DataSetLinq13(); // This sample combines select and where to make a simple query that returns the text form of each digit less than 5. Console.ReadKey(); samples.DataSetLinq14(); // This sample uses a compound from clause to make a query that returns all pairs of numbers... Console.ReadKey(); samples.DataSetLinq15(); // This sample uses a compound from clause to select all orders where the order total is less than 500.00. Console.ReadKey(); samples.DataSetLinq16(); // This sample uses a compound from clause to select all orders where the order was made in 1998 or later. Console.ReadKey(); samples.DataSetLinq17(); // This sample uses a compound from clause to select all orders where order total is greater than 2000.00... Console.ReadKey(); samples.DataSetLinq18(); // This sample uses multiple from clauses so that filtering on customers can be done before selecting their orders... Console.ReadKey(); samples.DataSetLinq19(); // This sample uses an indexed SelectMany clause to select all orders... Console.ReadKey(); }
static void Main(string[] args) { LinqSamples samples = new LinqSamples(); #region Restriction Operators 1 to 5 samples.Linq1(); // This sample uses the where clause to find all elements of an array with a value less than 5 samples.Linq2(); // This sample uses the where clause to find all products that are out of stock samples.Linq3(); // This sample uses the where clause to find all products that are in stock and cost more than 3.00 per unit samples.Linq4(); // This sample uses the where clause to find all customers in Washington and then it uses a foreach loop to iterate over the orders collection that belongs to each customer samples.Linq5(); // This sample demonstrates an indexed where clause that returns digits whose name is shorter than their value #endregion Restriction Operators 1 to 5 #region Projection Operators 6 to 19 samples.DataSetLinq6(); // This sample uses select to produce a sequence of ints one higher than those in an existing array of ints. samples.DataSetLinq7(); // This sample uses select to return a sequence of just the names of a list of products. samples.DataSetLinq8(); // This sample uses select to produce a sequence of strings representing the text version of a sequence of ints. samples.DataSetLinq9(); // This sample uses select to produce a sequence of the uppercase and lowercase versions of each word in the original array. samples.DataSetLinq10(); // This sample uses select to produce a sequence containing text representations of digits and whether their length is even or odd. samples.DataSetLinq11(); // This sample uses select to produce a sequence containing some properties of Products... samples.DataSetLinq12(); // This sample uses an indexed Select clause to determine if the value of ints in an array match their position in the array. samples.DataSetLinq13(); // This sample combines select and where to make a simple query that returns the text form of each digit less than 5. samples.DataSetLinq14(); // This sample uses a compound from clause to make a query that returns all pairs of numbers... samples.DataSetLinq15(); // This sample uses a compound from clause to select all orders where the order total is less than 500.00. samples.DataSetLinq16(); // This sample uses a compound from clause to select all orders where the order was made in 1998 or later. samples.DataSetLinq17(); // This sample uses a compound from clause to select all orders where order total is greater than 2000.00... samples.DataSetLinq18(); // This sample uses multiple from clauses so that filtering on customers can be done before selecting their orders... samples.DataSetLinq19(); // This sample uses an indexed SelectMany clause to select all orders... #endregion Projection Operators 6 to 19 #region Partitioning Operators 20 to 27 samples.Linq20(); // This sample uses Take to get only the first 3 elements of the array samples.Linq21(); // This sample uses Take to get the first 3 orders from customers in Washington samples.Linq22(); // This sample uses Skip to get all but the first four elements of the array samples.Linq23(); // This sample uses Take to get all but the first 2 orders from customers in Washington samples.Linq24(); // This sample uses TakeWhile to return elements starting from the beginning of the array until a number is read whose value is not less than 6 samples.Linq25(); // This sample uses TakeWhile to return elements starting from the beginning of the array until a number is hit that is less than its position in the array samples.Linq26(); // This sample uses SkipWhile to get the elements of the array starting from the first element divisible by 3 samples.Linq27(); // This sample uses SkipWhile to get the elements of the array starting from the first element less than its position #endregion Partitioning Operators 20 to 27 #region Ordering Operators 28 to 39 samples.Linq28(); // This sample uses orderby to sort a list of words alphabetically samples.Linq29(); // This sample uses orderby to sort a list of words by length samples.Linq30(); // This sample uses orderby to sort a list of products by name. Use the \"descending\" keyword at the end of the clause to perform a reverse ordering samples.Linq31(); // This sample uses an OrderBy clause with a custom comparer to do a case-insensitive sort of the words in an array samples.Linq32(); // This sample uses orderby and descending to sort a list of doubles from highest to lowest samples.Linq33(); // This sample uses orderby to sort a list of products by units in stock from highest to lowest samples.Linq34(); // This sample uses method syntax to call OrderByDescending because it enables you to use a custom comparer samples.Linq35(); // This sample uses a compound orderby to sort a list of digits, first by length of their name, and then alphabetically by the name itself samples.Linq36(); // The first query in this sample uses method syntax to call OrderBy and ThenBy with a // custom comparer to sort first by word length and then by a case-insensitive sort of // the words in an array. The second two queries show another way to perform the same task samples.Linq37(); // This sample uses a compound orderby to sort a list of products, first by category, and then by unit price, from highest to lowest samples.Linq38(); // This sample uses an OrderBy and a ThenBy clause with a custom comparer to sort first // by word length and then by a case-insensitive descending sort of the words in an array samples.Linq39(); // This sample uses Reverse to create a list of all digits in the array whose second letter is 'i' that is reversed from the order in the original array #endregion OrderingOperators # region Grouping Operators 40 to 45