Why FetchTypedListwith page size and page number, return all existing data rows!

Posts   
 
    
Stranger
User
Posts: 23
Joined: 22-Nov-2005
# Posted on: 27-Jan-2008 17:01:05   

I have a Query like this :

adapter.FetchTypedList( fields, dynamicList, bucket, pageSize, null, false, null, pageNumber, pageSize);

pageNumber = 1 and pageSize = 22 and I have a bucket with many JOIN ...

Why it returns all existing data rows in DB instead of 22 row? Is there any problem? In which condition this problem will occur?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 27-Jan-2008 21:42:02   
David Elizondo | LLBLGen Support Team
Stranger
User
Posts: 23
Joined: 22-Nov-2005
# Posted on: 28-Jan-2008 08:12:55   

Here is my code :

            fields.DefineField(ItemFieldIndex.ItemID,
                0, ItemFieldIndex.ItemID.ToString());

            fields.DefineField(ItemFieldIndex.Name,
                1, ItemFieldIndex.Name.ToString());

            fields.DefineField(ItemFieldIndex.ItemStatus,
                2, ItemFieldIndex.ItemStatus.ToString());

            fields.DefineField(ItemBarcodeFieldIndex.Barcode,
                3, ItemBarcodeFieldIndex.Barcode.ToString());

            fields.DefineField(ItemFieldIndex.TypeCode,
                4, ItemFieldIndex.TypeCode.ToString());

            fields.DefineField(StockItemFieldIndex.StockItemTypeCode,
                5, "StockItemSubType");

            fields.DefineField(ServiceItemFieldIndex.TypeCode,
                6, "SeriveItemSubType");

            fields.DefineField(TranslationItemFieldIndex.Description,
                7, TranslationItemFieldIndex.Description.ToString());

            bucket.Relations.Add(new ItemRelations().ItemBarcodeEntityUsingItemID, JoinHint.Left);
            bucket.Relations.Add(new ItemRelations().StockItemEntityUsingItemID, JoinHint.Left);
            bucket.Relations.Add(new ItemRelations().ServiceItemEntityUsingItemID, JoinHint.Left);
            bucket.Relations.Add(new ItemRelations().TranslationItemEntityUsingItemID, JoinHint.Left);

            expression = new PredicateExpression();
            predicate = new FieldCompareValuePredicate(
                EntityFieldFactory.Create(ItemBarcodeFieldIndex.IsDefaultBarcode),
                null,
                ComparisonOperator.Equal,
                true);
            expression.Add(predicate);

predicate = new FieldCompareNullPredicate(              EntityFieldFactory.Create(ItemBarcodeFieldIndex.IsDefaultBarcode), null);
            expression.AddWithOr(predicate);
            bucket.PredicateExpression.Add(expression);

            expression = new PredicateExpression();
            predicate = new FieldCompareValuePredicate(
                EntityFieldFactory.Create(TranslationItemFieldIndex.LanguageID),
                null,
                ComparisonOperator.Equal,
                language.Trim());
            expression.Add(predicate);

            predicate = new FieldCompareNullPredicate(
                EntityFieldFactory.Create(TranslationItemFieldIndex.LanguageID), null);
            expression.AddWithOr(predicate);
            bucket.PredicateExpression.Add(expression);

            if (pageNumber != -1 && pageSize != -1)
            {
                DALAdapter.FetchTypedList(
                    fields, dynamicList, bucket, pageSize, sortExpression, false, null, pageNumber, pageSize);
            }

I expect to return just limited data rows (= pagesize), but it returns all existing dat rows in DB that fulfills the defined criteria!

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 28-Jan-2008 10:07:11   

Please post the generated SQL query, and the llblgen runtime library version used.

Which database are you using? If it's SQL server, have you set the SqlServer compatibility mode?

Stranger
User
Posts: 23
Joined: 22-Nov-2005
# Posted on: 28-Jan-2008 11:20:53   

I am using SQL server ...

when i comment out this line, it is ok.

bucket.Relations.Add(new ItemRelations().TranslationItemEntityUsingItemID, JoinHint.Left);

Item has two subtype in DB named StockItem nd ServiceItem and TranslationItem has relation to Item.

Item --> StockItem (ItemID is PK for both tables) Item --> ServiceItem (ItemID is PK for both tables) TranslationItem((ItemID is FK) --> Item

When I add "ItemRelations().TranslationItemEntityUsingItemID" it returns all!

What is the matter?

Stranger
User
Posts: 23
Joined: 22-Nov-2005
# Posted on: 28-Jan-2008 11:24:16   

also

ItemBarcode (ItemID is FK) --> Item

Stranger
User
Posts: 23
Joined: 22-Nov-2005
# Posted on: 28-Jan-2008 11:31:38   

here is the generated SQL :

exec sp_executesql N'SELECT [CMSDBT].[dbo].[AS_ITM].[ID_ITM] AS [ItemID],[CMSDBT].[dbo].[AS_ITM].[NM_ITM] AS [Name],[CMSDBT].[dbo].[AS_ITM].[ZQ_SC_ST] AS [ItemStatus],[CMSDBT].[dbo].[ZQ_BRCD_ITM].[ZQ_DS_BRCD] AS [Barcode],[CMSDBT].[dbo].[AS_ITM].[TY_ITM] AS [TypeCode],[CMSDBT].[dbo].[AS_ITM_STK].[TY_ITM_STK] AS [StockItemSubType],[CMSDBT].[dbo].[AS_ITM_SV].[TY_ITM_SV] AS [SeriveItemSubType],[CMSDBT].[dbo].[I8_ITM].[DE_ITM_TSL] AS [Description] FROM (((( [CMSDBT].[dbo].[AS_ITM]  LEFT JOIN [CMSDBT].[dbo].[I8_ITM]  ON  [CMSDBT].[dbo].[AS_ITM].[ID_ITM]=[CMSDBT].[dbo].[I8_ITM].[ID_ITM]) LEFT JOIN [CMSDBT].[dbo].[ZQ_BRCD_ITM]  ON  [CMSDBT].[dbo].[AS_ITM].[ID_ITM]=[CMSDBT].[dbo].[ZQ_BRCD_ITM].[ID_ITM]) LEFT JOIN [CMSDBT].[dbo].[AS_ITM_STK]  ON  [CMSDBT].[dbo].[AS_ITM].[ID_ITM]=[CMSDBT].[dbo].[AS_ITM_STK].[ID_ITM]) LEFT JOIN [CMSDBT].[dbo].[AS_ITM_SV]  ON  [CMSDBT].[dbo].[AS_ITM].[ID_ITM]=[CMSDBT].[dbo].[AS_ITM_SV].[ID_ITM]) WHERE ( ( [CMSDBT].[dbo].[ZQ_BRCD_ITM].[ZQ_FL_DFLT] = @IsDefaultBarcode1 Or [CMSDBT].[dbo].[ZQ_BRCD_ITM].[ZQ_FL_DFLT] IS NULL) And ( [CMSDBT].[dbo].[I8_ITM].[ID_LGE] = @LanguageID2 Or [CMSDBT].[dbo].[I8_ITM].[ID_LGE] IS NULL))', N'@IsDefaultBarcode1 bit,@LanguageID2 char(8)', @IsDefaultBarcode1 = 1, @LanguageID2 = 'fa-IR   '
daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 29-Jan-2008 04:12:04   

Could you try putting 0 at maxItemsToReturn instead of pageSize? http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=4021

David Elizondo | LLBLGen Support Team
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39908
Joined: 17-Aug-2003
# Posted on: 29-Jan-2008 11:13:19   

Also please post llblgen pro version number, build nr of runtime lib etc. as pointed out in the guidelines.

Frans Bouma | Lead developer LLBLGen Pro