Otis wrote:
Why would you want to know? There isn't any data... so that thus means: there's no data.
Do you want to know this because you then can save a roundtrip to the db? If that's the case, isn't that solvable by scheduling the work differently? I mean by that: - fetch data, call method, process data available, return.
I would want to know because the entity graph that is initially loaded by a particular use case may not satisfy the requirements of subsequent use cases that may occur.
For example, you retrieve a list of customers to present to the user - there is no point is retrieving more than what you need to present the customer list as you do not know what the user will subsequently do. The user may then select a customer and choose to view its orders. The code that will present the orders is passed a customer entity and, ideally, would like to be able to prefetch the required order graph for that customer if it is not already populated - being modular and decoupled, it does not know the internals of the code that performed the original customer entity fetch and so does not know whether the orders were fetched or not. It would be helpful to have a test for whether that is necessary (i.e. has an attempt been made to fetch Customer.Orders?).
Thinking about it, what would be really great would be to have a method that, given an entity graph and a prefetch path, would ensure that the graph is populated to meet the prefetch path, i.e. load all the bits that are not already loaded...
EnsureGraph(RootEntity, DesiredPrefetchPath)
That way, a use case could present the specification of its data requirements and let LL satisfy them. Just an idea...
Jascha