2011-09-29 2 views
9
productQuery1.SelectValue<Int32>("it.ProductID"); 

Come faccio a sapere cosa significa "qui"?Da dove viene "it" in questo esempio di ObjectSet <T> .SelectValue?

Tutta esempio da 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); 
    } 
} 

risposta

9

è più come this.

It's a convention in query builder methods.

In un metodo del generatore di query, si fa riferimento al comando ObjectQuery corrente utilizzando un alias. Per impostazione predefinita, la stringa "it" è l'alias che rappresenta il comando corrente ...