-
Notifications
You must be signed in to change notification settings - Fork 55
Closed
Description
I have parent table called Location and a child table LocationSortOrder, i have used linked entities with left outer join and trying to sort the entities first by LocationSortOrder.SortOrderValue column and then the Location.LocationCode column. I have below code which does not give the desired result.
(Table: Columns)
Location: LocationCode, Description
LocationSortOrder: LocationCode, SortOrderValue
var parentQueryExpression = new QueryExpression(locationEntityName)
{
ColumnSet = new ColumnSet(columns),
NoLock = true
};
var linkedEntity = new LinkEntity
{
LinkFromEntityName = locationEntityName,
LinkToEntityName = locationSortOrderEntityName,
LinkFromAttributeName = locationIDName,
LinkToAttributeName = locationCodeName,
JoinOperator = JoinOperator.LeftOuter,
EntityAlias = "locationSortOrder",
Columns = new ColumnSet(columnNames)
};
//(1)//linkedEntity.Orders.Add(new OrderExpression("sortOrderValue", OrderType.Ascending, "Location1SortOrder", locationSortOrderEntityName));
parentQueryExpression.LinkEntities.Add(linkedEntity);
var orderExpressionCollection = new Collection<OrderExpression>
{
//(2)//new OrderExpression("sortOrderValue", OrderType.Ascending, "Location1SortOrder", locationSortOrderEntityName),
new OrderExpression(locationCodeName, OrderType.Ascending, "LocationCode", locationEntityName)
};
parentQueryExpression.Orders.AddRange(orderExpressionCollection);
Uncommenting //(2)// gives binding error for column 'sortOrderValue'. Uncommenting //(1)// does not sort the column first by 'sortOrderValue' and then by 'locationCode'.
Note: Sorting on locationCode in LocationSortOrder table is not an option because not every record from Location is present in LocationSortOrder table.
Metadata
Metadata
Assignees
Labels
No labels