We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Using IQueryable

I'm trying to use the grid to efficiently access the database. I have no need to request/query all the records when I only need a few. However, I can't seem to find a way to correctly work with IQueryable.

This post/sample (106580) uses the following code (which seems ok at first):

    int pagesize = args.PageSize == 0 ? 12 : Convert.ToInt32(args.PageSize);
    IEnumerable data = new NORTHWNDEntities().Orders.Take(200).ToList();
 
    IQueryable ds = data.AsQueryable();
 
For this to truly work as expected - I should be able to build up an SQL statement that I then execute. But that will not work here.
Before you even start, you've already requested 200 records (without any sort of criteria) and then you begin your expressions. Those 200 records may not even have the records I want to filter. 
I tried skipping that part, but it will not run. No records are returned if I try to ToList it at the end.
I'm using MVC4, ASP.NET4, 2013.1
So how does one use IQueryable (with something like EF5/6) to correctly use it's querying features.

2 Replies

TB Tony Basallo April 7, 2013 05:29 PM UTC

It seems I can get what I expect - build up a SQL state and execute just that by finishing up with this:

ds1 = (IQueryable<T>)ds;
Where T is the type being returned. This works perfect.
Not sure how this applies to other ORMs, but with EF, this works as expected.


ES Eswari S Syncfusion Team April 9, 2013 10:33 AM UTC

Hi Tony,

 

Thanks for your interest in Syncfusion products.

 

We have provided response to your query in the incident 106696.

 

Could you please follow up with the incident.

 

Please let us know if you have any queries.

 

Regards,

Eswari.S


Loader.
Live Chat Icon For mobile
Up arrow icon