Frage Complicated WHERE clause

  • Friday, September 21, 2012 10:40 PM
     
      Has Code
    <asp:EntityDataSource ID="edsOrganizations" runat="server" 
                        ConnectionString="name=NRECSEntities" DefaultContainerName="NRECSEntities" EnableFlattening="true" EntitySetName="organizations" 
    EntityTypeFilter="" 
    Include="applicationOrganizations.application, applicationOrganizations, applicationOrganizations.application.person"                     
    OrderBy="it.organizationName"     
    Where="EXISTS(SELECT VALUE t FROM it.applicationOrganizations AS t WHERE t.application.person.NRECSUserId = @UserId)">   
    <WhereParameters>  
    <asp:QueryStringParameter Type="Int16" Name="UserId" />  
    </WhereParameters>  
              
    </asp:EntityDataSource>

    Here is the Entity data source I'm trying to create. It does not throw an error but instead returns zero rows instead of the 3 it should.

    If I remove the "Where" the data source works fine and returns all organizations.

    So, what am I trying to do? A person can have 1 application that covers many organizations. I have a listView that should list all Organizations but on the rows where the person did apply to an organization I will display more info from applicationOrganization...(worry about that later in the listview Databound).

    I need to return all organizations with the necessary collections of applicationOrganizations for the given UserId (From the Person). Help!

All Replies