实体数据源,其中不在
本文关键字:数据源 实体 | 更新日期: 2024-11-03 18:23:07
我需要正确的语法才能完成这项工作。
编辑:
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 ";
}
尝试使用 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 ";
}