Click or drag to resize

ObjectTransactionGetTObject Method

Searches both the uncommitted and committed objects for the object with the specified type and object id.

Namespace:  Aloe.SystemFrameworks.Domain
Assembly:  Aloe.SystemFrameworks.Domain (in Aloe.SystemFrameworks.Domain.dll) Version: 20.1.3.5
Syntax
public TObject Get<TObject>(
	Guid id
)
where TObject : EntityObject

Parameters

id
Type: SystemGuid
The id of the object

Type Parameters

TObject
The type of the entity object

Return Value

Type: TObject
The entity object
Remarks

Get first searches the local cache for the object. If the object is not found, it is loaded from the data source. When the object is not found locally, a reference is returned, which is only initialized with the specified id. No data is loaded from the database initially. Data attributes and object references are lazy loaded upon first reference. Example:

//this will get a reference to a Customer object, but it will not "touch" the database
Customer c = tran.Get<Customer>(custId);

//this will load the customer
Console.WriteLine(c.IsActive);

Lazy loading also ensures, that everything is loaded as lazy as possible. Check this example:

//The SalesOrder object is not loaded, just lazy initialized
SalesOrder so = tran.Get<SalesOrder>(salesOrderId);

//The SalesOrder is loaded and a new lazy Customer object is initialized
Customer c = so.Customer;

//Nothing is allocated. Accessing the .Id property does not trigger lazy self loader
Guid custId = so.Customer.Id;

//Now the customer object is loaded also
string name = so.Customer.Name;
See Also