Ticket Q333116
Visible to All Users

GridView - How to use large datasets with LINQ-to-SQL classes and Stored Procedures

created 14 years ago

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

Comments (3)

    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?

      DevExpress Support Team 14 years ago

        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

        Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

        Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.