Joins and Paging

Posts   
 
    
hitchhiker
User
Posts: 48
Joined: 20-May-2009
# Posted on: 25-Jul-2011 01:30:21   

Hi, as always thanks in advance for the support. simple_smile

I have an issue with paging and joins... Latest libs (3.1) downloaded today. (linq 3.1.11.0518 etc)

As an example..


var lm = new LinqMetaData();

var q = from t1 in lm.Table1
            join t2 in lm.Table2 on t1.ID equals t2.ID
            orderby t2.Sort descending
            select t1;

foreach (var i in q.TakePage(2,10))
    Response.Write(i.ID);

This, and i've tried it as many ways as I could, will not properly return paged data. The db shows a non-paged request. What am I doing wrong?

Btw - I've had a number of problems with paging for a couple of years now, one thing that would be nice is if llblgen could throw errors -- or at least give us the option of a strict mode.. it just seems to 'ignore' paging in certain situations. I remember the same type of thing last year, hours wandering around a query wondering why it sometimes decides to just request an entire table of x million rows etc. It's v. scary simple_smile

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 25-Jul-2011 09:12:33   

When you sort on a field that's not on the select list, Distinct can't be applied. And Paging is done on the client side, which means only required rows are read from the database, and not the entire table as you thought.

This issue was recently discussed here: http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=20055

hitchhiker
User
Posts: 48
Joined: 20-May-2009
# Posted on: 29-Jul-2011 12:58:10   

Thanks Walaa,

When you sort on a field that's not on the select list, Distinct can't be applied.

Distinct doesn't need to be applied here.

I've ended up doing the same thing via a view.. The two tables were joined by a unique constraint, but LLBLGEN doesn't seem to pick up on that. The was no trouble doing it in SQL (with paging ofc). Either a) I couldn't find a way to do it in LINQ/LL b) LINQ/LL can't do it simple_smile

Cheers, Frank.