New Posts New Posts RSS Feed: Subquery.AddOrderBy doesn't order so well...
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Subquery.AddOrderBy doesn't order so well...

 Post Reply Post Reply Page  <12
Author
jozza View Drop Down
Newbie
Newbie


Joined: 11-Jul-2007
Posts: 25
Post Options Post Options   Quote jozza Quote  Post ReplyReply Direct Link To This Post Topic: Subquery.AddOrderBy doesn't order so well...
    Posted: 28-Aug-2007 at 12:00am

Hi

 
There seems to be an issue with the AddOrderBy method. I have the following query:
 

EntityQuery query = new EntityQuery(typeof(Shifts));

//Match on cost centre and roster name using the relationship.

EntitySubquery subQuery = query.AddSubquery(EntityRelations.ShiftFilter_Shifts);

subQuery.AddClause(ShiftFilter.RosterIDEntityColumn, EntityQueryOp.EQ, rosterName);

subQuery.AddClause(ShiftFilter.CostCentreIDEntityColumn, EntityQueryOp.EQ, costCentreId);

subQuery.Top = 100;

subQuery.AddOrderBy(ShiftFilter.OrderEntityColumn, System.ComponentModel.ListSortDirection.Ascending);

EntityList<Shifts> result = m_PersistenceManager.GetEntities<Shifts>(query);

When i look in the DebugLog.Xml it generates the following SQL:
select TOP 100 * from "dbo"."MIC_CC_Shift_Edit" where ((("dbo"."MIC_CC_Shift_Edit"."NM_SHIFT" in (select "dbo"."MIC_Shifts"."NM_SHIFT" from "dbo"."MIC_Shifts" where ("dbo"."MIC_Shifts"."NM_SHIFT" in (select TOP 100 "NM_SHIFT" from "dbo"."MIC_CC_Shift_Edit" where (("dbo"."MIC_CC_Shift_Edit"."ID_COST_CENTRE"=@v3 and "dbo"."MIC_CC_Shift_Edit"."NM_ROSTER"=@v2)) ORDER BY "dbo"."MIC_CC_Shift_Edit"."No_Order_Number" ASC))) and "dbo"."MIC_CC_Shift_Edit"."ID_COST_CENTRE"=@v1) and "dbo"."MIC_CC_Shift_Edit"."NM_ROSTER"=@v0)) ORDER BY "dbo"."MIC_CC_Shift_Edit"."No_Order_Number" ASC
 
 
When I pump this sql directly into query analyser, it returns the items in the correct order. However, the EntityList<Shifts> result does not receive the data in the correct order. We've prototyped using this approach in the past on older versions of devforce, but in 3.5.3 this doesn't work (unfortunately we don't have the old prototype code to test against 3.5.3). However, I would expect that the entitylist should contain the records in the order that they are returned from SQL.
 
Cheers
 
Jacob
Back to Top
 Post Reply Post Reply Page  <12

Forum Jump Forum Permissions View Drop Down