LLBLGen Pro 2.6 Available
Version 2.6 of my favourite Object Relational Mapper, LLBLGen Pro, is now available.
The main addition to V2.6 is support for a full Linq provider, so writing queries in LLBLGen just became a lot easier. V2.6 also includes a new Prefetching API which I wrote during the 2.6 beta period, which Frans then included in the product.
For example, to eagerly load a Customer -> Orders relationship prior to v2.6, you'd have to do something like this:
EntityCollection<CustomerEntity> customers = new EntityCollection<CustomerEntity>(new CustomerEntityFactory()); PrefetchPath2 prefetcher = new PrefetchPath2(EntityType.Customer); prefetcher.Add(CustomerEntity.PrefetchPathOrders); using(DataAccessAdapter adapter = new DataAccessAdapter()) { adapter.FetchEntityCollection(customers, null, prefetcher); }
Now, with the lambda prefetching API you can do this:
using(var adapter = new DataAccessAdapter()) { var linq = new LinqMetaData(adapter); var customers = (from c in linq.Customers select c) .WithPath(path => path.Prefetch(c => c.Orders)); }
Likewise, if you wanted to filter the prefetched orders (eg, only return orders costing more than £10) and prefetch each order's OrderDetail, you'd need to do something like this:
EntityCollection<CustomerEntity> customers = new EntityCollection<CustomerEntity>(new CustomerEntityFactory()); PrefetchPath2 prefetcher = new PrefetchPath2(EntityType.Customer); prefetcher.Add(CustomerEntity.PrefetchPathOrders, 0, new PredicateExpression(OrderFields.TotalCost > 10)) .SubPath.Add(OrderEntity.PrefetchPathOrderDetail); using(DataAccessAdapter adapter = new DataAccessAdapter()) { adapter.FetchEntityCollection(customers, null, prefetcher); }
using(var adapter = new DataAccessAdapter()) { var linq = new LinqMetaData(adapter); var customers = (from c in linq.Customers select c) .WithPath(path => path.Prefetch<OrderEntity>(c => c.Orders) .FilterOn(o => o.TotalCost > 10) .SubPath(orderPath => orderPath.Prefetch(o => o.OrderDetail)) ); }
Written on June 8, 2008