通过


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

属性值

一个 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. 在引用方法内部或SelectValue方法内Where联接中的当前序列时,这非常有用。 有关详细信息,请参阅 查询生成器方法

设置 Name 某个 ObjectQuery<T>属性时,该值将成为连续方法中的别名。

属性的值 Name 必须以字母开头,并且可以包含字母、数字和下划线。

适用于

另请参阅