Hi,
we are using LLBLGen 5.10.1 (Adapter), net4.8/net6.0. Our database is Oracle 11/19 and our target .net version 4.8/netstandard2.0.
We are currently migrating from self-servicing to adapter to be able to run our logic against different databases. So far we are using lazy loading at many places and we have update those spots to use prefetch paths where possible.
In my research of the different use cases where we have to update from lazy loading to prefetch, I've came across some odd behaviors which seem bugs to me. All include a projection and a combination with prefetch paths and/or in-memory method executions. I've created seperate threads for each of them.
FYI: All below behaviors use Adapter. Also I updated all types to be types from the Northwind database to make the examples easier to understand. However I never executed it against Northwind but only to our Entities/database. I hope I didn't make an error though.
1. How to prefetch an entity property which is used inside an in-memory function call? / Prefetch path is ignored.
Consider this code:
bool CustomerHasOrders(CustomerEntity customer)
{
return customer.Orders.Any();
}
var customerModel =
(from c in metaData.Customer.With(c => Orders)
select new
{
Customer = c,
HasOrders = CustomerHasOrders(c)
})
.First();
If I do this neither the customer.Order entities inside of CustomerHasOrders() are prefetched (resulting in HasOrders = false always) nor the order entities in the result model (customerModel.Customer.Orders). It seems that the prefetch is completely ignored. This happens regardless if I use Linq query syntax or linq methods and with With() or WithPath(). It also seems to break down to: prefetch is ignored when having a projection (Select) to a non entity type, because customerModel.Customer.Order is still not prefetched even if I omit the CustomerHasOrders() call.
Is this behavior expected or a bug?