Ninja Database Pro
SavePartial<T> Method
Example 



KellermanSoftware.NinjaDatabasePro Namespace > NinjaDbPro Class : SavePartial<T> Method
Save only the specified fields or properties. The convention is ClassName.PropertyName There is no performance benefit. The purpose is to be used in synchronization scenarios.
Syntax
Public Function SavePartial(Of T As {Class, New})( _
   ByVal value As T, _
   ByVal fieldsOrPropertiesToSave As List(Of String) _
) As T
Dim instance As NinjaDbPro
Dim value As T
Dim fieldsOrPropertiesToSave As List(Of String)
Dim value As T
 
value = instance.SavePartial(Of T)(value, fieldsOrPropertiesToSave)
public T SavePartial<T>( 
   T value,
   List<string> fieldsOrPropertiesToSave
)
where T: class, new()
public:
T^ SavePartialgeneric<typename T>
( 
   T^ value,
   List<String^>^ fieldsOrPropertiesToSave
) 
where T: ref class, gcnew()

Parameters

value
fieldsOrPropertiesToSave

Type Parameters

T
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();
 
Order order = new Order();
order.Notes = "This is a test";
order.Buyer = new Person();
order.Buyer.Name = "John Doe";
order.Buyer.DateCreated = DateTime.Now;
order.OrderDetails = new List<OrderDetail>();
 
OrderDetail detail1 = new OrderDetail();
detail1.Item = new Product();
detail1.Item.Name = "Wizard";
detail1.Item.Cost = 29.98M;
detail1.Quantity = 2;
detail1.Order = order;
order.OrderDetails.Add(detail1);
 
OrderDetail detail2 = new OrderDetail();
detail2.Item = new Product();
detail2.Item.Name = ".NET Caching Library";
detail2.Item.Cost = 199.95M;
detail2.Quantity = 1;
detail2.Order = order;
order.OrderDetails.Add(detail2);
 
db.Save(order);
 
List<string> fieldsOrPropertiesToSave = new List<string>();
fieldsOrPropertiesToSave.Add("Order.Notes");
 
order.Notes = "This is test changed";
detail1.Quantity = 3;
 
db.SavePartial(order, fieldsOrPropertiesToSave);
 
Order orderCopy = db.Load<Order>(order.OrderId);
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()
 
Dim order As New Order()
order.Notes = "This is a test"
order.Buyer = New Person()
order.Buyer.Name = "John Doe"
order.Buyer.DateCreated = Date.Now
order.OrderDetails = New List(Of OrderDetail)()
 
Dim detail1 As New OrderDetail()
detail1.Item = New Product()
detail1.Item.Name = "Wizard"
detail1.Item.Cost = 29.98D
detail1.Quantity = 2
detail1.Order = order
order.OrderDetails.Add(detail1)
 
Dim detail2 As New OrderDetail()
detail2.Item = New Product()
detail2.Item.Name = ".NET Caching Library"
detail2.Item.Cost = 199.95D
detail2.Quantity = 1
detail2.Order = order
order.OrderDetails.Add(detail2)
 
db.Save(order)
 
Dim fieldsOrPropertiesToSave As New List(Of String)()
fieldsOrPropertiesToSave.Add("Order.Notes")
 
order.Notes = "This is test changed"
detail1.Quantity = 3
 
db.SavePartial(order, fieldsOrPropertiesToSave)
 
Dim orderCopy As Order = db.Load(Of Order)(order.OrderId)
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