Knight Data Access Layer
LoadWithChildren<T>(Object) Method
Example 




KellermanSoftware.NetDataAccessLayer Namespace > IDataHelper Interface > LoadWithChildren Method : LoadWithChildren<T>(Object) Method
Generic class type
The primary key value to search for
Load a record by the primary key with all parents and children
Syntax
Overloads Function LoadWithChildren(Of T As {Class, New})( _
   ByVal primaryKeyValue As Object _
) As T
Dim instance As IDataHelper
Dim primaryKeyValue As Object
Dim value As T
 
value = instance.LoadWithChildren(Of T)(primaryKeyValue)
T LoadWithChildren<T>( 
   object primaryKeyValue
)
where T: class, new()
T* LoadWithChildren<T>( 
   Object* primaryKeyValue
) 
where T: ref class, gcnew()
T^ LoadWithChildrengeneric<typename T>
( 
   Object^ primaryKeyValue
) 
where T: ref class, gcnew()

Parameters

primaryKeyValue
The primary key value to search for

Type Parameters

T
Generic class type

Return Value

A single record with all parents and children populated
Example
//Get the current thread static safe instance of the helper
IDataHelper db = DataHelper.SessionFactory();
 
//Specify User Name and License Key from the receipt, leave blank for trial mode
//db.UserName = "John Smith 1234";
//db.LicenseKey = "asdfl219==";
 
//Open the database connection
db.OpenConnection();
 
Order order = new Order
                   {
                       Notes = "Test order",
                       OrderDetails = new List<OrderDetail>()
                   };
order.OrderDetails.Add(new OrderDetail
                           {
                               Order = order,
                               Notes = "First order detail"
                           });
order.OrderDetails.Add(new OrderDetail
                           {
                               Order = order,
                               Notes = "Second order detail"
                           });
 
// Insert records
db.SaveWithChildren(order);
 
Order testOrder = db.LoadWithChildren<Order>(order.OrderId);
 
//Close the connection
db.CloseConnection();
'Get the current thread static safe instance of the helper
Dim db As IDataHelper = DataHelper.SessionFactory()
 
'Specify User Name and License Key from the receipt, leave blank for trial mode
'db.UserName = "John Smith 1234"
'db.LicenseKey = "asdfl219=="
 
'Open the database connection
db.OpenConnection()
 
Dim order As Order = New Order With {.Notes = "Test order", .OrderDetails = New List(Of OrderDetail)()}
order.OrderDetails.Add(New OrderDetail With {.Order = order, .Notes = "First order detail"})
order.OrderDetails.Add(New OrderDetail With {.Order = order, .Notes = "Second order detail"})
 
' Insert records
db.SaveWithChildren(order)
 
Dim testOrder As Order = db.LoadWithChildren(Of Order)(order.OrderId)
 
'Close the connection
db.CloseConnection()
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

IDataHelper Interface
IDataHelper Members
Overload List