This is a migrated thread and some comments may be shown as answers.

Some question

3 Answers 16 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
john
Top achievements
Rank 1
john asked on 16 Sep 2012, 06:50 AM
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?

3 Answers, 1 is accepted

Sort by
0
PetarP
Telerik team
answered on 19 Sep 2012, 02:57 PM
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!
0
john
Top achievements
Rank 1
answered on 19 Sep 2012, 03:02 PM
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.
0
PetarP
Telerik team
answered on 24 Sep 2012, 02:09 PM
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!
Tags
General Discussions
Asked by
john
Top achievements
Rank 1
Answers by
PetarP
Telerik team
john
Top achievements
Rank 1
Share this question
or