EntityDataSource.WhereParameters Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets the collection of parameters that are used to create the WHERE clause.
public:
property System::Web::UI::WebControls::ParameterCollection ^ WhereParameters { System::Web::UI::WebControls::ParameterCollection ^ get(); };
[System.ComponentModel.Browsable(false)]
[System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)]
public System.Web.UI.WebControls.ParameterCollection WhereParameters { get; }
[<System.ComponentModel.Browsable(false)>]
[<System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)>]
member this.WhereParameters : System.Web.UI.WebControls.ParameterCollection
Public ReadOnly Property WhereParameters As ParameterCollection
Property Value
The parameters that are used for creating the WHERE clause.
Implements
- Attributes
Examples
The XML markup in the following example, in an .aspx file, retrieves a value from a control and passes it as a parameter to the Where property.
<asp:EntityDataSource ID="SalesOrderHeader" runat="server"
ConnectionString="name=AdventureWorksEntities"
DefaultContainerName="AdventureWorksEntities" EnableDelete="True"
EnableInsert="True" EnableUpdate="True" EntitySetName="SalesOrderHeader"
EntityTypeFilter="" OrderBy="it.TotalDue DESC" Select=""
Where="it.OnlineOrderFlag = TRUE AND it.TotalDue > @ordercost">
<WhereParameters>
<asp:ControlParameter ControlID="costLimit" DbType="Int32"
DefaultValue="2500" Name="ordercost" PropertyName="Text" />
</WhereParameters>
</asp:EntityDataSource>
The previous XML example is the same as the following ObjectQuery<T> named onlineOrders
:
ObjectQuery<SalesOrderHeader> onlineOrders =
context.SalesOrderHeader
.Where("it.OnlineOrderFlag = TRUE AND it.TotalDue > @ordercost",
new ObjectParameter("ordercost", orderCost))
.OrderBy("it.TotalDue DESC");
Remarks
Like the Where method of the ObjectQuery<T> class, parameters can be passed to the predicate assigned to the Where property. The WhereParameters property of the EntityDataSource control specifies a ParameterCollection that contains the parameters to supply to the WHERE clause of the query. The WhereParameters property uses named arguments to refer to the parameters that are specified in the string that is supplied to the Where property.
If the WhereParameters property is not set, no parameter substitution is made. All the parameter names in the WHERE clause preceded by the symbol "@"
must have a matching name in the ParameterCollection. Null values are not allowed for parameters in a ParameterCollection.
Applies to
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기