Home » Blog

rounded header

Eager Loading

tag icon Tagged as LightSpeed

LightSpeed was designed to provide flexibility to developers that want to have fine grained control how how eager and lazy loading works. This post highlights how basic loading can be manipulated and then covers some of the more advanced load graph management features in LightSpeed.

Always Lazy Loading
If an association has no EagerLoad attribute applied to it, by default, it will be lazily loaded.

private readonly EntityCollection _users = new EntityCollection();

Always Eager Loading
By specifying an EagerLoad attribute with no parameters, the association will always be eagerly loaded.

[EagerLoad]
private readonly EntityCollection _users = new EntityCollection();

Eager Loading Based on Aggregate Name
If an association has an EagerLoad attribute specified, with an AggregateName parameter on it, the association will only be eagerly loaded if the Query object has the same value for AggregateName. If the values are different, the association will be lazily loaded.

[EagerLoad(AggregateName = "Detail")]
private readonly EntityCollection _users = new EntityCollection();

Then, it is just a matter of setting the AggregateName property.

query.AggregateName = "Detail"; // Causes the _users association to be eager loaded.
query.AggregateName = "NotDetail"; // Causes the _users association to be lazy loaded.

Named Aggregates provide an extremely flexible way of managing eager load graphs. To make this feature even more powerful, multiple named aggregates can be applied to a single field. This powerful feature is just one of the many ways that LightSpeed is different and more effective than many other frameworks that exist.

– JD

One Response to “Eager Loading”

  1. [...] LightSpeed’s system of eager and lazy loading provides an extremely convenient and efficient way to tune performance without troubling application code with the details of when and how to access the database. The key concept here is that of named aggregates, an abstraction layer which allows an application to say what it wants to use the entity for, and lets the entity designer map that down to specific fields to load. [...]

Leave a Reply

Data Products Visual Controls Community Store
LightSpeed ORM
NHibernate Designer
SimpleDB Tools
SharePoint Tools
WPF Elements
WPF Diagrams
Silverlight Elements
Forums
Blog
Register
Login
Subscribe to newsletter
Buy Now
My Account
Volume Discounts
Purchase Orders
Contact Us