I have a working project with MVC grid. I use grouping, sorting and filtering in the grid and it's populated with this code:
C#@Html.DevExpress().GridView(
settings => ...
).BindToLINQ(string.Empty, string.Empty, new EventHandler<DevExpress.Data.Linq.LinqServerModeDataSourceSelectEventArgs>((s, e) =>
{
Phonebook_web.PhonebookDataDataContext context = new Phonebook_web.PhonebookDataDataContext();
//e.QueryableSource = context.inlgVW_Phonebooks; /* THIS ONE WORKS */
e.QueryableSource = context.ilgSP_UsersSearch("kor").AsQueryable(); /* --- PROBLEM --- */
e.KeyExpression = "id";
})).GetHtml()
If I use just a plain view to populate grid everything works. But when I want it to be populated using Stored procedure and I use AsQueryable() then grid is empty. And this code definitely returns rows - context.ilgSP_UsersSearch("kor").AsQueryable().
Is this something unsupported? How can I use stored proc for returning my data AND linq-to-sql for large datasets?
Thank you.
Alex
Hello Alex,
Thank you for contacting us. The stored procedure is a subroutine, which is executed on the database server side. The stored procedure is a subroutine, which is executed on the database server side. This is an important statement because this means that a result of the stored procedure cannot be modified on the application server side before the stored procedure execution. For example, the Server Mode functionality cannot be implemented.
See the ID : K18520 (How to adjust GridView to work with Stored Procedures (EntityFramework)) KB Article and a corresponding linked Code Central example for more information.
It is necessary to translate the StoredProcedure's operator(s) within the LINQ Expression(s) and use a result as e.QueryableSource. Take a look at the Using LINQ with Server-side Data Management (ASP.NET) Video Tutorial to learn more on how to use the LinqServerModeDataSource component in the ASP.NET environment.
See the ID : K18504 (How to implement common scenarios when using ASPxGridView bound with EntityDataSource / Entity Framework) KB Article and a corresponding linked Code Central example for more information.
Regards,
Mike
Thanks for the reply. I watched the video and I read those articles. I understand that using stored procedures in server mode is another story.
What I'm asking is how can I mimic server mode with stored procedures so all grid's features work (filtering, sorting and grouping)? Are there any events I could handle and pass needed parameters to stored procedure?
Hello Alex,
I am uncertain about the following suggestion, but you can try using the OBSOLETE: A possible implementation of IListServer interface to achieve Server Mode functionality in the GridView extension example to see how the Server Mode can be implemented.
To tell you the truth, it would be really hard to implement the grouping and filtering features, because your stored procedure must work with filtering expressions of any complexity.
Thanks,
Vest