0

我需要正确的语法来完成这项工作。

编辑:

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 ";
}
4

1 回答 1

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 ";
}
于 2012-08-08T11:53:18.647 回答