Hi,
I'm trying to prefecth 3 levels in one and filter the 3rd node.
My relation are Order > Order Detail > Voucher and I want to get all orders that contain a voucher with an specific voucherCode and filter by orderNumber.
The problem is that I'm getting all the orders with that orderNumber without regardless the voucherCode, here is my code:
IPredicateExpression predicateExpression = new PredicateExpression(OrdersFields.OrderId == orderNumberCriteria);
IPredicateExpression voucherPredicateExpression = new PredicateExpression(VoucherFields.VoucherCode % voucherCodeCriteria);
IRelationCollection voucherRelations = new RelationCollection();
voucherRelations.Add(OrderDetailEntity.Relations.VoucherEntityUsingOrderDetailId);
IPrefetchPath prefetchPath = new PrefetchPath(EntityType.OrdersEntity);
prefetchPath.Add(OrdersEntity.PrefetchPathOrderDetail)
.SubPath.Add(OrderDetailEntity.PrefetchPathVoucher, 0, voucherPredicateExpression, voucherRelations);
OrdersCollection ordersCollection = new OrdersCollection();
ordersCollection.GetMulti(predicateExpression, prefetchPath);
What I'm doing wrong?