ObjectQuery<T>.Name プロパティ

定義

このオブジェクト クエリの名前を取得または設定します。

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

プロパティ値

この ObjectQuery<T> の名前を表す string 値。

例外

設定時に指定された値が無効です。

この例では、最初の 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 メソッド内で、現在のシーケンスを参照する際に便利です。 詳細については、「 Query Builder メソッド」を参照してください。

NameObjectQuery<T> プロパティを設定すると、その値が後続のメソッドで別名として使用されます。

Name プロパティの値は、先頭を英字にする必要があり、英字、数字、およびアンダースコアを含めることができます。

適用対象

こちらもご覧ください