Search code examples
.netentitydatasource

Does EntityDatasource perform "order by" before or after query extender


Does The following entity datasource will perform orderby after filtered in each CustomExpression in queryextender or it will perform orderby first then go into each query extender before selection.

<asp:EntityDataSource ID="edsMembers" runat="server" 
    ConnectionString="name=MOSContainer" DefaultContainerName="MOSContainer" 
    EnableFlattening="False" EntitySetName="Members" EntityTypeFilter="Member"
    OrderBy="it.UserName" EnableDelete="True" ondeleted="edsMembers_Deleted">
</asp:EntityDataSource>
<asp:QueryExtender ID="qedMembers" runat="server" TargetControlID="edsMembers">
<asp:CustomExpression OnQuerying="FilterMembersActivatedEmail"></asp:CustomExpression>
<asp:CustomExpression OnQuerying="FilterMembersOccupationType"></asp:CustomExpression>
</asp:QueryExtender>

Solution

  • The QueryData source order by clauses are applied on PageInit and therefore come before the one applied from the actual data source. There is also a problem here - Since the query extender and the data source create two separate order by clauses only one of them is respected and that is the last one that is applied (the one from the data source). The same works with Linq to SQL data source. Here is a link to similar question of mine.