Search code examples
asp.netentity-frameworkcountentitydatasource

EntityDataSource where association count > 0


I'm trying to get Items that has at least 1 Chart, Items and Charts have a 1 to many relation.

I tryed this :

<asp:EntityDataSource ID="EntityDataSource1" ContextTypeName="Entities"
EntitySetName="Items" Where="Count(it.ItemCharts) > 0" runat="server" />

But i get the error message :

No overload of canonical aggregate function 'Edm.Count' is compatible with the arg...

How do I do this without using code behind?

Thanks for the help!


Solution

  • You should use EXISTS to determine whether a collection/association is empty:

    <asp:EntityDataSource ID="EntityDataSource1" ContextTypeName="Entities"
    EntitySetName="Items" Where="EXISTS(it.ItemCharts)" runat="server" />