Some question

4 posts, 0 answers
  1. john
    john avatar
    67 posts
    Member since:
    Jan 2012

    Posted 16 Sep 2012 Link to this post

    I have a RadGrid which is enable paging and filtering feature. The RadGrid is bound with ObjectDataSource.  My select method is defined as below:
     public List<FunctionField> GetFieldData(string filterExpressions, int maximumRows, int startRowIndex)
            {
                using (var context = new MaintainRuleDA())
                {
                    IQueryable<FunctionField> source = from p in context.FunctionFields
                                                       where !p.IsDeleted
                                                       select p;


                    if (!string.IsNullOrEmpty(filterExpressions))
                    {
                        source = source.Where(filterExpressions);
                    }

                     source = source.OrderBy(p => p.FieldName);
                    totalCount = source.Count();
                    return source.Skip(startRowIndex).Take(maximumRows).ToList();
                }
            }

    I have two questions:
    1.Whether the above code will have performance issue?
    2.Currently, my RadGrid will have a column Function Name which is from another table(Function table). I need to retrieve the Function Name based on FunctionFields.FunctionId from DB in ItemDataBound event. My question is whether there is a way to return the function name in above method?
  2. PetarP
    Admin
    PetarP avatar
    754 posts

    Posted 19 Sep 2012 Link to this post

    Hi john,

     The call to source.Count() will actually execute the query and return all the data to your client. What this means is that the next call to .Skip and .Take will actually be executed on the client rather then the server which in turn can bring some performance penalties. 

    You can have a custom object that contains all the data you need to return and use our ADO api implementation to populate it with a given query. Using this you will be able to retrieve information form several tables in a single object. Additional information can be found in our online documentation here.

    Greetings,
    Petar
    the Telerik team
    Follow @OpenAccessORM Twitter channel to be the first one to get the latest updates on new releases, tips and tricks and sneak peeks at our product labs!
  3. DevCraft banner
  4. john
    john avatar
    67 posts
    Member since:
    Jan 2012

    Posted 19 Sep 2012 Link to this post

    For your first answer, could you give me the good practice for good performance about my code because the method is used to return the paging data and total record count.
  5. PetarP
    Admin
    PetarP avatar
    754 posts

    Posted 24 Sep 2012 Link to this post

    Hi john,

     I am afraid I might have misled you in my first post. The .Count query actually results in a count statement on the server side and thus no additional records are returned. This said the query you are using so far should be perfectly fine and should not pose any performance overhead to your application. 

    All the best,
    Petar
    the Telerik team
    Follow @OpenAccessORM Twitter channel to be the first one to get the latest updates on new releases, tips and tricks and sneak peeks at our product labs!
Back to Top