我需要正确的语法来完成这项工作。
修改
XAML:
<asp:EntityDataSource ID="EntityDataSource2" runat="server" ConnectionString="name=Entities"
DefaultContainerName="Entities" EnableDelete="True" EnableFlattening="False"
EnableInsert="True" EnableUpdate="True" EntitySetName="Plans" AutoGenerateWhereClause="true">
<WhereParameters>
<asp:ControlParameter ControlID="tbxSearch" Name="Name" Type="String" />
</WhereParameters>
</asp:EntityDataSource>
代码背后:
if (string.IsNullOrEmpty(tbxSearch.Text))
{
this.EntityDataSource1.Where =
"NOT it.Id IN (SELECT Id FROM Plans_PendingChange) ";//getting all the records instead of getting the proper records
}
else
{
this.EntityDataSource1.Where = "it.Name = @Name ";
}
答案 0 :(得分:2)
尝试使用NOT it.Id IN
代替it.Id NOT IN
,如下所示:
this.EntityDataSource1.WhereParameters.Clear();
if (string.IsNullOrEmpty(tbxSearch.Text))
{
this.EntityDataSource1.Where = "NOT it.Id IN (SELECT Id FROM Plans_PendingChange) ";
}
else
{
this.EntityDataSource1.Where = "it.Name = @Name ";
}