Some object databases enable the client application to load partial objects by specifying an "activation-depth". This restricts loading nested objects to a specified depth. For example if you have an object with nested complex types, an activation level of 2 will result in the following:

myobject.Property1.NestedProp1.NestedProp2.NestedProp3….

will load only

myobject.Property1

Setting a global fixed activation level has limited value because in real scenarios you may need for Type A to load only the first level while for Type B to load the first 4 levels. Siaqodb provides complete flexibility by supporting both Partial and Eager loading.

Partial Object Loading

You can use the SiaqodbConfigurator class to indicate that complex properties and fields for a given Type should not be loaded.

SiaqodbConfigurator.LoadRelatedObjects<Order>(false);

With this setting only basic fields and properties are loaded. All complex fields and properties are set to null (Nothing in VB). You can also control Lazy loading per field, for example you can set that only one field/property should be lazy loaded and all the rest will be loaded normally. For example:

SiaqodbConfigurator.LoadRelatedObjects<Order>(true);
....
public class Order
{
    public int OID { get; set; }
    public Customer OrderCustomer { get; set; }
    [Sqo.Attributes.LazyLoad]
    public List Details{get;set;}
    public DateTime OrderDate { get; set; }
    public int OrderNumber { get; set; }
}

In above example when Order will be loaded, every field value will be loaded as normal except the 'Details' property's value which will not be loaded.

Eager Loading

The Include(…) extension method of ISqoQuery will enable any complex field or property to be loaded by specifying the full navigation path:

var query1 = siaqodb.Query().Where(o => o.OrderNumber > 2).Include("OrderCustomer");

Here, the complex Property "OrderCustomer" is loaded from database. For example:

public class Order
{
    public int OID { get; set; }
    public Customer OrderCustomer { get; set; }
    public List Details{get;set;}
    public DateTime OrderDate { get; set; }
    public int OrderNumber { get; set; }
}
public class OrderDetail
{
    public int OID { get; set; }
    public Product DetailProduct { get; set; }
    public decimal Price { get; set; }
    public decimal Quantity { get; set; }
}
public class Product
{
    public int OID { get; set; }
    public string Name { get; set; }
}
public class Customer
{
    public int OID { get; set; }
    public string Name { get; set; }
    public Address Address { get; set; }
}
public class Address
{
    public int OID { get; set; }
    public string Street { get; set; }
    public string City { get; set; }
}
.........
Siaqodb siaqodb = SiaqodbFactory.GetInstance();
SiaqodbConfigurator.LoadRelatedObjects<Order>(false);
SiaqodbConfigurator.LoadRelatedObjects<Customer>(false);
var query1 = siaqodb.Query().Where(o => o.OrderNumber > 2).Include("OrderCustomer");
Log("All orders will have property OrderCustomer loaded(since Customer has LoadRelatedObjects=false, Address will not be loaded)");
foreach (Order order in query1)
{
    Log("Order with nr:" + order.OrderNumber + " is of Customer:" + order.OrderCustomer.Name );
}
var query2 = (from Order o in siaqodb
    where o.OrderNumber > 2
    select o).Include("OrderCustomer").Include("OrderCustomer.Address");
foreach (Order order in query2)
{
    Log("Order with nr:" + order.OrderNumber + " is of Customer:" + order.OrderCustomer.Name +
    " from City:" + order.OrderCustomer.Address.City);
}

Combining the Partial and Eager Loading features provides the client application complete flexibility in loading only required fields and properties – even for complex, nested objects. These techniques can enhance performance of your application considerably.