Hi Dustin,
Here are some ways: http://llblgen.com/TinyForum/Messages.aspx?ThreadID=11839&StartAtMessage=0𐄀
In your case I would recommend to use M:N prefetchPaths. Here is an example (assuming Adpater scenario) using Product --(1:n)--> OrderDetail --(m:1)--> Order. So there's a M:N relation between Product and Order:
// setup my fetch
ProductEntity product = new ProductEntity(1);
PrefetchPath2 path = new PrefetchPath2((int)EntityType.ProductEntity);
path.Add(ProductEntity.PrefetchPathOrdersCollectionViaOrderDetails));
// fetch the stuff
using (DataAccessAdapter adapter = new DataAccessAdapter())
{
adapter.FetchEntity(product, path);
}
// example of accessing the related m:n collection
Console.WriteLine(product.OrdersCollectionViaOrderDetails.Count);
Or you can fetch the collection using a filter based on the corresponding product:
// the corresponding product. Could be in-memory or fetched
ProductEntity product = new ProductEntity(1);
// setup my fetch
IRelationPredicateBucket filter = new RelationPredicateBucket();
filter.Relations.Add(OrderEntity.Relations.OrderDetailEntityUsingOrderId);
filter.PredicateExpression.Add(OrderDetailFields.ProductId == product.ProductId);
// fetch the stuff
EntityCollection<OrderEntity> orders = new EntityCollection<OrderEntity>();
using (DataAccessAdapter adapter = new DataAccessAdapter())
{
adapter.FetchEntityCollection(orders, filter);
}
// example of accessing the fetched relation
Console.WriteLine(orders.Count);
Is very similar with SelfServicing.
You also could fetch the m:n relation directly from a fetched entity. (read this on the m:n relation title for more info).
Please come back if you need further help