PropertyExpression 类
定义
提供一种方法,用于使用 WhereParameters 集合中的参数创建 Where 子句。Provides a way to create a Where clause from parameters in a WhereParameters collection.
public ref class PropertyExpression : System::Web::UI::WebControls::Expressions::ParameterDataSourceExpression
public class PropertyExpression : System.Web.UI.WebControls.Expressions.ParameterDataSourceExpression
type PropertyExpression = class
inherit ParameterDataSourceExpression
Public Class PropertyExpression
Inherits ParameterDataSourceExpression
- 继承
示例
下面的示例演示如何在 AdventureWorks 数据库的 Products 表中搜索其 MakeFlag 属性 (布尔值列设置为) 的产品 true 。The following example shows how to search the Products table of the AdventureWorks database for products whose MakeFlag property (a Boolean column) is set to true. 布尔值参数在复选框中设置。The Boolean value parameter is set in a check box. 从控件返回的查询的结果 LinqDataSource 显示在 GridView 控件中。The result of the query that is returned from the LinqDataSource control is displayed in a GridView control.
此代码示例是在 演练:使用声明性语法筛选网页中的数据中提供的一个更大示例的一部分。This code example is part of a larger example that is provided in Walkthrough: Filtering Data in a Web Page Using Declarative Syntax.
注解
PropertyExpression类与控件一起用于 QueryExtender 筛选数据字段中的数据。The PropertyExpression class is used with the QueryExtender control to filter data in data fields. PropertyExpression类将列的属性值与指定的值进行比较。The PropertyExpression class compares a property value of a column to a specified value. 例如,可以将一个布尔值与数据库中 Products 表的 "中止" 列中的值进行比较。For example, you can compare a Boolean value to the value in the discontinued column of a Products table in a database.
PropertyExpression类为每个参数的值和数据对象的相应属性创建一个等于 (= =) 比较 IQueryable 。The PropertyExpression class creates an equals (==) comparison for the value of each parameter and the corresponding property of the IQueryable data object. 如果提供多个参数,则使用逻辑运算符组合参数 AND 。If you provide more than one parameter, the parameters are combined using the logical AND operator. 包含空值的参数不会添加到子句中 Where 。Parameters that contain an empty value are not added to the Where clause.
构造函数
| PropertyExpression() |
初始化 PropertyExpression 类的新实例。Initializes a new instance of the PropertyExpression class. |
属性
| Context |
获取所有者控件的 HttpContext 实例。Gets the HttpContext instance of the owner control. (继承自 DataSourceExpression) |
| DataSource |
获取与所有者控件关联的数据源对象。Gets the data source object that is associated with the owner control. (继承自 DataSourceExpression) |
| IsTrackingViewState |
获取一个值,该值指示数据源表达式对象是否跟踪其视图状态更改。Gets a value that indicates whether a data source expression object is tracking its view state changes. (继承自 DataSourceExpression) |
| Owner |
获取所有者控件。Gets the owner control. (继承自 DataSourceExpression) |
| Parameters |
获取与此 DataSourceExpression 对象关联的参数。Gets the parameters that are associated with this DataSourceExpression object. (继承自 ParameterDataSourceExpression) |
| ViewState |
获取 StateBag 类的一个实例,其中包含当前的视图状态信息。Gets an instance of the StateBag class that contains the current view state information. (继承自 DataSourceExpression) |
方法
| Equals(Object) |
确定指定对象是否等于当前对象。Determines whether the specified object is equal to the current object. (继承自 Object) |
| GetHashCode() |
作为默认哈希函数。Serves as the default hash function. (继承自 Object) |
| GetQueryable(IQueryable) |
使用指定的 PropertyExpression 数据源对象应用一个 IQueryable 对象。Applies a PropertyExpression object by using the specified IQueryable data source object. |
| GetType() |
获取当前实例的 Type。Gets the Type of the current instance. (继承自 Object) |
| LoadViewState(Object) |
加载必须持久化的 ParameterDataSourceExpression 对象中值的状态。Loads the state of the values in the ParameterDataSourceExpression object that must be persisted. (继承自 ParameterDataSourceExpression) |
| MemberwiseClone() |
创建当前 Object 的浅表副本。Creates a shallow copy of the current Object. (继承自 Object) |
| SaveViewState() |
保存 ParameterDataSourceExpression 对象的当前视图状态。Saves the current view state of the ParameterDataSourceExpression object. (继承自 ParameterDataSourceExpression) |
| SetContext(Control, HttpContext, IQueryableDataSource) |
使用指定的所有者控件、上下文和数据源来执行表达式。Executes the expression by using the specified owner control, context, and data source. (继承自 ParameterDataSourceExpression) |
| SetDirty() |
标记 DataSourceExpression 对象,以便在视图状态中保存其状态。Marks the DataSourceExpression object so that its state will be saved in view state. (继承自 DataSourceExpression) |
| ToString() |
返回表示当前对象的字符串。Returns a string that represents the current object. (继承自 Object) |
| TrackViewState() |
跟踪 ParameterDataSourceExpression 对象的视图状态更改,以使这些更改可以存储在该对象的 StateBag 对象中。Tracks view-state changes of the ParameterDataSourceExpression object so that the changes can be stored in the StateBag object for the object. (继承自 ParameterDataSourceExpression) |
显式接口实现
| IStateManager.IsTrackingViewState |
由类实现时,获取一个值,该值指示数据源表达式对象是否跟踪其视图状态更改。When implemented by a class, gets a value that indicates whether a data source expression object is tracking its view state changes. (继承自 DataSourceExpression) |
| IStateManager.LoadViewState(Object) |
由类实现时,加载数据源表达式对象以前保存的视图状态。When implemented by a class, loads the previously saved view state of the data source expression object. (继承自 DataSourceExpression) |
| IStateManager.SaveViewState() |
由类实现时,保存 DataSourceExpression 对象的当前视图状态。When implemented by a class, saves the current view state of the DataSourceExpression object. (继承自 DataSourceExpression) |
| IStateManager.TrackViewState() |
由类实现时,跟踪 DataSourceExpression 对象的视图状态更改,以使这些更改可以存储在数据源表达式对象的 StateBag 对象中。When implemented by a class, tracks view state changes of the DataSourceExpression object so that the changes can be stored in the StateBag object for the data source expression object. (继承自 DataSourceExpression) |