ObjectQuery<T>.Name 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定這個物件查詢的名稱。
public:
property System::String ^ Name { System::String ^ get(); void set(System::String ^ value); };
public string Name { get; set; }
member this.Name : string with get, set
Public Property Name As String
屬性值
這個 string 值就是這個 ObjectQuery<T>名稱。
例外狀況
設定中指定的值並不有效。
範例
此範例將第一個 ObjectQuery<T> 的名稱設為「product」,並在後續 OrderBy 方法中使用此別名。
int cost = 10;
// Return Product objects with a standard cost
// above 10 dollars.
ObjectQuery<Product> productQuery =
context.Products
.Where("it.StandardCost > @cost", new ObjectParameter("cost", cost));
// Set the Name property for the query and then
// use that name as the alias in the subsequent
// OrderBy method.
productQuery.Name = "product";
ObjectQuery<Product> filteredProduct = productQuery
.OrderBy("product.ProductID");
備註
物件查詢的名稱在建構查詢建置方法時,透過名稱識別序列中目前的物件查詢。 預設情況下,查詢名稱為 it。 這在方法內 Where 或方法中 SelectValue 參考當前序列時非常有用。 欲了解更多資訊,請參閱 查詢建構方法。
當你設定 Name 屬性 ObjectQuery<T>時,該值在後續方法中即為別名。
房產價值 Name 必須以字母開頭,且可包含字母、數字和底線。