Good day,
I consider myself new to Linq and only have done a few basic queries with no problem with the exception of this last one.
My question is pretty simple, how I should write the following low-level API as Linq with Lambda expression:
var filter = new RelationPredicateBucket(OrderFields.Number == number);
var path = new PrefetchPath2(SBC.DAL.EntityType.OrderEntity);
path.Add(OrderEntity.PrefetchPathOrderDetails).SubPath.Add(OrderDetailEntity.PrefetchPathInventory).SubPath.Add(InventoryEntity.PrefetchPathProduct)
.SubPath.Add(ProductEntity.PrefetchPathProductUnit);
path.Add(OrderEntity.PrefetchPathCustomer);
path.Add(OrderEntity.PrefetchPathEmployee);
path.Add(OrderEntity.PrefetchPathCompany);
I don't have a problem with the above code and it works flawlessly, I'm just asking since I would like to know how to do it the other way.
This is what I have done so far:
var metaData = new LinqMetaData(adapter);
var q = (from o in metaData.Order
where o.Number == number
select o).WithPath(orderPath => orderPath
.Prefetch<OrderDetailEntity>(o => o.OrderDetails)
.SubPath(orderDetailPath => orderDetailPath
.Prefetch<InventoryEntity>(od => od.Inventory)
.SubPath(inventoryPath => inventoryPath
.Prefetch<ProductEntity>(i => i.Product)
.SubPath(productPath => productPath
.Prefetch<ProductUnitEntity>(p => p.ProductUnit)))));
Which translates to this:
var filter = new RelationPredicateBucket(OrderFields.Number == number);
var path = new PrefetchPath2(SBC.DAL.EntityType.OrderEntity);
path.Add(OrderEntity.PrefetchPathOrderDetails).SubPath.Add(OrderDetailEntity.PrefetchPathInventory).SubPath.Add(InventoryEntity.PrefetchPathProduct)
.SubPath.Add(ProductEntity.PrefetchPathProductUnit);
Thanks in advance,
Dave