Muokkaa

Jaa


ObjectQuery<T>.Name Property

Definition

Gets or sets the name of this object query.

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

Property Value

A string value that is the name of this ObjectQuery<T>.

Exceptions

The value specified on set is not valid.

Examples

This example sets the name of the first ObjectQuery<T> to "product" and then uses this alias in the successive OrderBy method.

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");

Remarks

The name of the object query identifies the current object query in the sequence by name when constructing query builder methods. By default, the query name is it. This can be useful when referring to the current sequence in joins inside the Where method or in the SelectValue method. For more information, see Query Builder Methods.

When you set the Name property of an ObjectQuery<T>, that value becomes the alias in successive methods.

The value of the Name property must start with a letter and can contain letters, digits, and underscores.

Applies to

See also