Hi
Using LLBLgen Pro 1.0.2005.1 final, released may 2nd, 2006
I have two tables
TBLcommerce_item
TBLcommerce_itemGroupItem
Both tables contains a column called SortOrder
Now I want to sort my collection on TBLcommerce_itemGroupItem.SortOrder.
So I make this code:
CommerceItemCollection itemCollection = new CommerceItemCollection();
IPredicateExpression filter = new PredicateExpression();
filter.Add(CommerceItemFields.SiteGuid == 10217);
filter.AddWithAnd(CommerceItemGroupItemFields.ItemGroupGuid == 2704);
IRelationCollection relations = new RelationCollection();
relations.Add(CommerceItemEntity.Relations.CommerceItemGroupItemEntityUsingItemGuid);
itemCollection.GetMulti(filter, 0, sortExpression, relations);
This will give me an SQL query like this:
exec sp_executesql N'SELECT [dbo].[TBLcommerce_item].[guid] AS [Guid], [dbo].[TBLcommerce_item].[siteGuid] AS [SiteGuid], [dbo].[TBLcommerce_item].[itemNo] AS [ItemNo], [dbo].[TBLcommerce_item].[sortOrder] AS [SortOrder]
FROM ( [dbo].[TBLcommerce_item] INNER JOIN [dbo].[TBLcommerce_itemGroupItem] [LPA_I1] ON [dbo].[TBLcommerce_item].[guid]=[LPA_I1].[itemGuid])
WHERE ( ( [dbo].[TBLcommerce_item].[siteGuid] = @SiteGuid1 AND [LPA_I1].[itemGroupGuid] = @ItemGroupGuid1))
ORDER BY [LPA_I1].[sortOrder] ASC', N'@SiteGuid1 int,@ItemGroupGuid2 int', @SiteGuid1 = 10217, @ItemGroupGuid2 = 2704
SQL result like this:
42167 10217 Calvin Klein D1257E Bh 0
42200 10217 Calvin Klein D1264E String 0
42209 10217 Calvin Klein D1267E Pants 0
The correct result should have been:
42167 10217 Calvin Klein D1257E Bh 0
42200 10217 Calvin Klein D1264E String 0
42209 10217 Calvin Klein D1267E Pants 0
The sqlquery actually do the sorting on [dbo].[TBLcommerce_item].[sortOrder] instead of [LPA_I1].
If I modify the SQL it will work correctly when:
1. I Remove [dbo].[TBLcommerce_item].[sortOrder] AS [SortOrder] from select.
2. Change [dbo].[TBLcommerce_item].[sortOrder] AS [SortOrder] to [dbo].[TBLcommerce_item].[sortOrder] AS [SortOrderForSomethingElse]
3. Adds [LPA_I1].[sortOrder] to select.
So my question is:
Is it possibly to do something so I can execute the LLBLgen code above without changing one of the fieldnames i LLBLgen Designer?