Otis wrote:
You should specify the filter on the prefetch path definition. E.g. the SubPath.Add() call allows you to specify a filter for that node.
Please specify the code you used so we can give you hints what to do. (and what version you're using etc.)
Thank you for the reply. What I needed to achieve is doing something like this:
I have 3 Tables: Customer, Order, OrderDetails
Relationship: Customer-Order (OrderId), Order-OrderDetails (DetailsId)
I am using QueryParameters to FetchEntityCollection() in which I need to use Relation or DynamicRelation on the QueryParameters.RelationToUse. In order to filter with the OrderTable, I must get the Original LLBL Relationship and set to this QueryParameters.RelationToUse. By doing this, now the fields from Order can be set at the WHERE clause. I understand that FetchEntityCollection will only based on the EntityType that will be the Customer, and fetch the fields based on Customer Table only. But with this “workaround”, I can manage to use fields from Order. The Pseudo-SQL below shows how LLBL is generated.
SELECT Customer.* FROM Customer
LEFT JOIN Order ON Customer.OrderId = Order.OrderId WHERE Order.Name = “…”
The result returned.
But now I want to prefetch OrderDetails with the Customer. OrderDetails is under Order Table. I still can get the LLBL Relationship and set to the QueryParameters.RelationToUse. But it says that “Relation at Index 1 doesn't contain an entity already added to the FROM clause. Bad alias?” error.
Because this relation cannot be generated the WHERE clause using OrderDetails cannot be done.
SELECT Customer.* FROM Customer
LEFT JOIN Order ON Customer.OrderId = Order.OrderId
LEFT JOIN OrderDetails ON Order.DetailsId = OrderDetails.DetailsId
WHERE OrderDetails.Details = "..."
Hope to have your reply. Thank you.