Question about LINQ

Discussion of open issues, suggestions and bugs regarding LinqConnect – Devart's LINQ to SQL compatible ORM
Post Reply
crazypit
Posts: 163
Joined: Wed 15 Apr 2009 08:43

Question about LINQ

Post by crazypit » Wed 26 Aug 2009 14:59

Hello all,

I have a situation and i want your help.

I use LINQ to query some tables where one of them is "CUSTOMERS". I join with other tables and i create the final query incrementally according to the fields provided by the user (last name, first name etc.). The final IQueryable is passed to a special grid (Dev Express). The grid uses the IQueryable to do automatic Server-side processing, retrieving records a few at a time as the User scrolls down the relevant scrollbar.

Everything works ok. But...

I need to dynamically change the "CUSTOMERS" table with a View which brings a subset of the Customers table and which is custom defined by the user. The name of the view is stored in a table in the database.

Therefore, i cannot have a direct implementation of the view as a method on my datacontext.

I cannot use the ExecuteQuery method because this actually executes the query and results in an IEnumerable. I can't use that as a feed to my grid, because it expects an IQueryable in order to do its thing.

Im stuck... I just want to change the resulted table name and i don;t have a way to do it!!

Can anyone help?

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Tue 01 Sep 2009 11:04

The same LINQ query is converted in the same (appropriate) SQL every execution. So it is necessary to create and assign a new query every time.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Tue 01 Sep 2009 16:52

We will implement

Code: Select all

public IQueryable Query(string query)
in DataContext in the next build. It will work like DataContext.ExecuteQuery but return IQueryable with all its advantages.

Post Reply