Try using the Function Import
.
- Right click on the EntitySet Name (the heading part)
- Choose Add->Function Import
Here is a good blog post for you to check out. ADO.NET Entity Framework Tools: Stored Procedures, by Guy Burstein
Update: Sorry I missed the part about the EntityDataSource
so I don't know of any property exposed to access a function import from the EDS, but your can try to use the CommandText property.
<asp:EntityDataSource ID="SolutionsDataSource" runat="server"
CommandText="DataModel.SearchFunction(@Keywords)"
ConnectionString="name=AdventureWorksEntities">
<CommandParameters>
<asp:ControlParameter Name="Keywords"
ControlID="SearchTextbox" Type="String"/>
</CommandParameters>
</asp:EntityDataSource>
Update: Well it seems that I have some bad news. After using Reflector to dive deep into the EntityDataSource
. The EntityDataSourceView
is constructed using QueryBuilderUtils.ConstructQuery
, which then in turn calls context.CreateQuery<T>
. What you would need to execute the function import is a call to context.ExecuteFunction<T>
. There doesn't seem to be any support for the ExecuteFunction in this release, the blogs I was reading did mention that it was planned, but it didn't make it into this release, whether or not it will be in future releases I can't say.
That being said I would recommend using an ObjectDataSource
, which you can construct in a way that still supports paging, sorting, etc. If you open an ObjectDataSource question on this topic send me a comment here and I'll take a look.