Unions with linq alternatives

Posts   
 
    
Jed
User
Posts: 38
Joined: 08-Oct-2010
# Posted on: 04-May-2011 17:11:04   

I have 4 very big tables (round 1mil records in each).

I use linq to put them into the same class type then i union them in memory.

var t = table1.union(table2)

Is there anyway i can do union within the statement. Doing it in memory is to slow.

Any suggestions welcome

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 04-May-2011 18:29:06   

Union is not supported. Milllions of records to fetch at one time is not a recommended practice by all means.

What you need to do is to fetch them one by one into the same EntityCollection.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39908
Joined: 17-Aug-2003
# Posted on: 05-May-2011 09:13:20   

Why do you need to union 4 million rows?

Frans Bouma | Lead developer LLBLGen Pro
Jed
User
Posts: 38
Joined: 08-Oct-2010
# Posted on: 10-May-2011 16:37:59   

The reason is I need to use a take page on a set of data.

I want to order the data by DateCreated then do a take page on that.

Therefore returning 100 rows of data. Then using the paging on my grid page to the next 100 rows using take page

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 10-May-2011 20:52:18   

You could create a view which UNIONS the 4 tables together, and then use LINQ to query that. Using Skip and Take in the LLBLGen linq provider will be translated to server side paging statements which will be run on the server, which should give acceptable performance.

Matt

Jed
User
Posts: 38
Joined: 08-Oct-2010
# Posted on: 11-May-2011 09:05:35   

Thanks for the responses.

View does seem to be the best route.