EntityDataSource control and SELECT TOP(N)

3.6k views Asked by At

i use asp.net 4 and EF.

I have a EntityDataSource and I would like select only the TOP 10 records from my DataBase, Example SELECT TOP(10).

Here my code, how can I do it? Thanks

<asp:EntityDataSource ID="uxEntityDataSourceEndingSponsoredContents" runat="server"
    ConnectionString="name=CmsConnectionStringEntityDataModel" 
    DefaultContainerName="CmsConnectionStringEntityDataModel" EntitySetName="CmsSponsoredContents"
    OrderBy="it.EffectiveEndDate ASC" EnableFlattening="False" CommandText="" 
    EntityTypeFilter="">
</asp:EntityDataSource>
2

There are 2 answers

1
Bart On BEST ANSWER

You have to use top(n)

Select="top(10) Name, Address"
0
GBK On

Select="top(10) it.Name, it.Address"

in my case, it must be used 'it' as alias.