Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where does "it" come from in this example of ObjectSet<T>.SelectValue?

productQuery1.SelectValue<Int32>("it.ProductID");

How would I know what "it" means here?

Whole example from MSDN docs

using (AdventureWorksEntities context =
    new AdventureWorksEntities())
{
    string queryString =
        @"SELECT VALUE product FROM 
            AdventureWorksEntities.Products AS product";

    ObjectQuery<Product> productQuery1 =
        new ObjectQuery<Product>(queryString,
            context, MergeOption.NoTracking);

    ObjectQuery<Int32> productQuery2 =
        productQuery1.SelectValue<Int32>("it.ProductID");

    foreach (Int32 result in productQuery2)
    {
        Console.WriteLine("{0}", result);
    }
}
like image 839
Aaron Anodide Avatar asked Sep 29 '11 18:09

Aaron Anodide


1 Answers

It's more like this.

It's a convention in query builder methods.

In a query builder method, you refer to the current ObjectQuery command by using an alias. By default, the string "it" is the alias that represents the current command...

like image 136
Craig Stuntz Avatar answered Sep 24 '22 09:09

Craig Stuntz