Sorting on Prefetch

Posts   
 
    
Posts: 9
Joined: 19-May-2006
# Posted on: 19-May-2006 21:10:22   

Hi. My problem is that i want to use a ISortExpression on a PrefetchPatch, but it´s doesn´t work. I mean, it doesn´t have any effect at all, the collection is in the exact same order... this is the code:

-- We have "Weapons" that have catalogs, and each "Catalog" has a "Model". -- So, when fetching weapons to show up on a gridview, we make this... -- (sorter is correctly created and initialized before this code)

IPrefetchPathElement2 catalogPath = prefetch.Add(WeaponEntity.PrefetchPathCatalog,0,null,null,sorter,new CatalogEntityFactory());

catalogPath.SubPath.Add(CatalogEntity.PrefetchPathModel, 0, null, null,modelSortExpression,new ModelEntityFactory());

Any idea? Probably a known bug?

Thank´s.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39928
Joined: 17-Aug-2003
# Posted on: 19-May-2006 21:22:58   

On which field are you sorting? Couldyou paste teh code for the sortexpression as well?

Frans Bouma | Lead developer LLBLGen Pro
Posts: 9
Joined: 19-May-2006
# Posted on: 19-May-2006 21:33:25   

-- Ok but i get the clauses from the "sortExpression" parameter on the -- function rage , then it´s something like this

... ISortClause sortClause = sortExpression[i]; //because a 'for' statement simple_smile ISortExpression modelSortExpression = new SortExpression(sortClause); ...

And i´m sorting on the "Description" field from ModelEntity.

Posts: 9
Joined: 19-May-2006
# Posted on: 19-May-2006 21:34:43   

sorry, it´s:

... ISortClause sortClause = sortExpression[index .]; //because a 'for' statement Regular Smiley ISortExpression modelSortExpression = new SortExpression(sortClause); ...

bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 20-May-2006 02:26:00   

Can you post the trace for the sql that the prefetch generates.

Posts: 9
Joined: 19-May-2006
# Posted on: 22-May-2006 20:50:52   

Ok I suppose this is the SQL related to the prefetch.

Generated Sql query: 
Query: SELECT [Weapon].[dbo].[Brand].[BrandId], [Weapon].[dbo].[Brand].[Description] FROM [Weapon].[dbo].[Brand]  WHERE ( [Weapon].[dbo].[Brand].[BrandId] IN (@BrandId1, @BrandId2, @BrandId3, @BrandId4, @BrandId5, @BrandId6, @BrandId7, @BrandId8, @BrandId9, @BrandId10))
Parameter: @BrandId1 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 0.
Parameter: @BrandId2 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 0.
Parameter: @BrandId3 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 27.
Parameter: @BrandId4 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 0.
Parameter: @BrandId5 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 0.
Parameter: @BrandId6 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 0.
Parameter: @BrandId7 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 6.
Parameter: @BrandId8 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 6.
Parameter: @BrandId9 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 0.
Parameter: @BrandId10 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 0.

>>>The ModelEntity Prefetch (where I added the sort Clause but it didn't work :(  )

Generated Sql query: 
Query: SELECT [Weapon].[dbo].[Model].[ModelId], [Weapon].[dbo].[Model].[Description] FROM [Weapon].[dbo].[Model]  WHERE ( [Weapon].[dbo].[Model].[ModelId] IN (@ModelId1, @ModelId2, @ModelId3, @ModelId4, @ModelId5, @ModelId6)) ORDER BY [Weapon].[dbo].[Model].[Description] ASC
Parameter: @ModelId1 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 0.
Parameter: @ModelId2 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 8.
Parameter: @ModelId3 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 37.
Parameter: @ModelId4 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 1.
Parameter: @ModelId5 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 37.
Parameter: @ModelId6 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 49.




Generated Sql query: 
Query: SELECT [Weapon].[dbo].[WeaponType].[TypeId], [Weapon].[dbo].[WeaponType].[Description] FROM [Weapon].[dbo].[WeaponType]  WHERE ( [Weapon].[dbo].[WeaponType].[TypeId] IN (@TypeId1, @TypeId2, @TypeId3, @TypeId4, @TypeId5, @TypeId6))
Parameter: @TypeId1 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 17.
Parameter: @TypeId2 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 3.
Parameter: @TypeId3 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 2.
Parameter: @TypeId4 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 7.
Parameter: @TypeId5 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 1.
Parameter: @TypeId6 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 9.



Query: SELECT [Weapon].[dbo].[Caliber].[CaliberId], [Weapon].[dbo].[Caliber].[Description] FROM [Weapon].[dbo].[Caliber]  WHERE ( [Weapon].[dbo].[Caliber].[CaliberId] IN (@CaliberId1, @CaliberId2, @CaliberId3, @CaliberId4, @CaliberId5, @CaliberId6))
Parameter: @CaliberId1 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 26.
Parameter: @CaliberId2 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 14.
Parameter: @CaliberId3 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 29.
Parameter: @CaliberId4 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 19.
Parameter: @CaliberId5 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 31.
Parameter: @CaliberId6 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 20.
Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 23-May-2006 09:08:40   

The ModelEntity Prefetch (where I added the sort Clause but it didn't work

When you say that the sort clause generated does not work, is it related to the following thread: http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=6004

And I didn't understand the following post:

... ISortClause sortClause = sortExpression[index .]; //because a 'for' statement Regular Smiley ISortExpression modelSortExpression = new SortExpression(sortClause); ...

Posts: 9
Joined: 19-May-2006
# Posted on: 24-May-2006 14:54:18   

Ok, it seems to be the same problem. Thank you.