Entitydatasource NOT IN抛出异常

时间:2015-10-30 19:36:46

标签: sql entity-framework

有人能告诉我在entitydatasource WHERE子句中如何使用NOT IN吗?这就是我现在所拥有的:

 </asp:EntityDataSource>
                    <asp:EntityDataSource
                         ID="EntityDataSource5" 
                        runat="server" 
                        ConnectionString="name=NUGENPISKYDDI" 
                        DefaultContainerName="NUGENPISKYDDI" 
                        EnableDelete="True" EnableFlattening="False" 
                        EnableInsert="True" EnableUpdate="True" 
                        EntitySetName="OperationsInfomations" 
                         OrderBy="it.OperateId Desc" 
                        Where="it.FermNumber = 4 and it.sampleage NOT IN ('BeerWell')">
        </asp:EntityDataSource>

和例外:

     [EntitySqlException: The right argument of the set expression must be of                  CollectionType. Near parenthesized expression, line 6, column 43.]
         System.Web.UI.WebControls.EntityDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +1340
   System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments,      DataSourceViewSelectCallback callback) +21
   System.Web.UI.WebControls.DataBoundControl.PerformSelect() +138
   Telerik.Web.UI.GridTableView.PerformSelect() +38
   System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +30
   Telerik.Web.UI.GridTableView.DataBind() +389
   Telerik.Web.UI.RadGrid.DataBind() +191
   System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +105
   System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() +75
   System.Web.UI.Control.EnsureChildControls() +83
   System.Web.UI.Control.PreRenderRecursiveInternal() +42
   System.Web.UI.Control.PreRenderRecursiveInternal() +155
   System.Web.UI.Control.PreRenderRecursiveInternal() +155
   System.Web.UI.Control.PreRenderRecursiveInternal() +155
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +974

1 个答案:

答案 0 :(得分:0)

尝试

Where="it.FermNumber = 4 and it.sampleage NOT IN {'BeerWell'}">

注意大括号。