Ninja Database Pro
LoadPartial<T> Method
Example 



KellermanSoftware.NinjaDatabasePro Namespace > NinjaDbPro Class : LoadPartial<T> Method
The type to load
The primary key
The properties or fields to load by name
Load only the properties and fields specified. The format is the ClassName.PropertyName Performance is not increased, the properties are simply not populated to be used for synchronization scenarios.
Syntax
Public Function LoadPartial(Of T As {Class, New})( _
   ByVal primaryKey As Long, _
   ByVal propertiesOrFieldsToLoad As List(Of String) _
) As T
Dim instance As NinjaDbPro
Dim primaryKey As Long
Dim propertiesOrFieldsToLoad As List(Of String)
Dim value As T
 
value = instance.LoadPartial(Of T)(primaryKey, propertiesOrFieldsToLoad)
public T LoadPartial<T>( 
   long primaryKey,
   List<string> propertiesOrFieldsToLoad
)
where T: class, new()
public:
T^ LoadPartialgeneric<typename T>
( 
   int64 primaryKey,
   List<String^>^ propertiesOrFieldsToLoad
) 
where T: ref class, gcnew()

Parameters

primaryKey
The primary key
propertiesOrFieldsToLoad
The properties or fields to load by name

Type Parameters

T
The type to load
Example
NinjaDbPro db = new NinjaDbPro("MyDatabaseDirectory", "MyDatabaseName");
         
//Licensed Mode
//db.UserName = "John Smith 101224";
//db.LicenseKey = "aousdf832jasf==";
 
//Set before OpenDatabase. Default storage is IsolatedStorageDatabase. Other options are:
//db.Storage = new MemoryDatabase(); //In memory database
//db.Storage = new FileDatabase();  
        
db.OpenDatabase();
 
//Save a person
Person person = new Person();
person.Name = "Greg";
person.DateCreated = DateTime.Today;
db.Save(person);
 
//Load a Partial
List<string> fieldsOrPropertiesToLoad = new List<string>();
fieldsOrPropertiesToLoad.Add("Person.DateCreated");
 
Person personCopy = db.LoadPartial<Person>(person.PersonId, fieldsOrPropertiesToLoad);
Dim db As New NinjaDbPro("MyDatabaseDirectory", "MyDatabaseName")
 
'Licensed Mode
'db.UserName = "John Smith 101224";
'db.LicenseKey = "aousdf832jasf==";
 
'Set before OpenDatabase. Default storage is IsolatedStorageDatabase. Other options are:
'db.Storage = new MemoryDatabase(); //In memory database
'db.Storage = new FileDatabase();  
 
db.OpenDatabase()
 
'Save a person
Dim person As New Person()
person.Name = "Greg"
person.DateCreated = Date.Today
db.Save(person)
 
'Load a Partial
Dim fieldsOrPropertiesToLoad As New List(Of String)()
fieldsOrPropertiesToLoad.Add("Person.DateCreated")
 
Dim personCopy As Person = db.LoadPartial(Of Person)(person.PersonId, fieldsOrPropertiesToLoad)
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

NinjaDbPro Class
NinjaDbPro Members