Hi guys and girls,
I am just starting out with the Entity Framework 4.0 and ASP.NET MVC 2 and have a few questions regarding the use of stored procedures and paging.
You can map the Insert, Update, and Delete actions to stored procedures and I have already done this. However for my paging to work I need to map the Select action.
Now is the only / best way I can do this by going to my model browser, right clicking on the stored procedure and "Add Function Import" and adding it.
This results in the following code....
var contactFormSubmissions = _entities.ContactFormSubmission_GetContactFormSubmissions(1, 10);
My issue with this is that it adds it to the global entity container at root level rather than the ContactFormSubmission entity like the Insert / Update and Delete actions.
I would rather something like this but through through a stored procedure...
_entities.ContactFormSubmissions.Select<ContactFormSubmission>(string.Empty, pageParam, pageSizeParam);
This way the select is called in the same way as the other actions and I dont end up with lots of functions in the root of the Entity Container which could get unmanagable.
This is a lesser issue as at least its all working currently.
My next question is how to best implement paging using this function.
All of the examples I have seen on how to accomplish paging using MVC and the Entity Framework have used LINQ and IQueryable. Is there a way of using IQueryable with lazy loading and the LINQ functions Skip / Take with a table based fucntion /sproc?
http://blog.wekeroad.com/2007/12/10/aspnet-mvc-pagedlistt/
Cheers
Steve
PS - any exmaples of paging in MVC with the Entity Framework using SP's would be great!