LLBLGen Pro have full support for that. Let's see some examples:
In these examples I have three tables (_Product --(1:n)--> OrderDetail --(m:1)--> Order_) so there exists an M:N relation Products-->Order.
At LLBLGen Designer, for each M:N relation, a **FieldOnRelation **is created. In our example it resides on _Product _entity. We renamed from _OrderCollectionViaOrderDetails _to Orders, so at generated code we will have some _product.Order_s collection.
Let's retrieve all orders which contain the purchase of a product X with productID 10. We're not interested in the product entity itself so that's not fetched. We pass the Orders collection directly without storing it into another reference variable.
ProductEntity product = new ProductEntity(10);
DataAccessAdapter adapter = new DataAccessAdapter();
adapter.FetchEntityCollection(product.Orders, product.GetRelationInfoOrders());
Now an example with a product collection with some filter. Then we want to prefetch its related Orders (M:N).
EntityCollection<ProductEntity> products = new EntityCollection<ProductEntity>();
IRelationPredicateBucket filter = new RelationPredicateBucket(ProductFields.UnitPrice > 100);
// include the M:N path
IPrefetchPath2 path = new PrefetchPath2((int)EntityType.ProductEntity);
path.Add(ProductsEntity.PrefetchPathOrders);
// fetch the collection
adapter.FetchEntityCollection(products, filter, path);
// example iterating to access the M:N entities
foreach (ProductsEntity p in products)
{
Console.WriteLine(p.OrdersCollectionViaOrderDetails.Count);
foreach (OrdersEntity od in p.OrdersCollectionViaOrderDetails)
{
Console.WriteLine(od.CustomerId);
}
}