// We will call various methods here!
Console.ReadLine();
}
Basic Selection Syntax
Because LINQ query expressions are validated at compile time, you need to remember that the
ordering of these operators is critical. In the simplest terms, every LINQ query expression is built
using the from, in, and select operators:
var result = from item in container select item;
In this case, our query expression is doing nothing more than selecting every item in the con-
tainer (similar to a Select * SQL statement). Consider the following:
static void BasicSelection(Car[] myCars)
{
// Get everything.
Console.WriteLine("All cars:");
var allCars = from c in myCars select c;
foreach (var c in allCars)
{
Console.WriteLine(c.ToString());
}
}
Again, this query expression is not entirely useful, given that our subset is identical to that of
the data in the incoming parameter. If we wish, we could use this incoming parameter to extract
only the PetName values of each car using the following selection syntax:
Do'stlaringiz bilan baham: |