Knight Data Access Layer
Save<T>(List<T>) Method
Example 




KellermanSoftware.NetDataAccessLayer Namespace > IDataHelper Interface > Save Method : Save<T>(List<T>) Method
Generic class type
A list of entities to save
Save a list of items to the database. If the primary key is zero or null, it is an insert otherwise an update. If IsDeleted is set, the record is deleted.
Syntax
Overloads Sub Save(Of T As {Class, New})( _
   ByVal list As List(Of T) _
) 
Dim instance As IDataHelper
Dim list As List(Of T)
 
instance.Save(Of T)(list)
void Save<T>( 
   List<T> list
)
where T: class, new()
void Save<T>( 
   List<T*>* list
) 
where T: ref class, gcnew()
void Savegeneric<typename T>
( 
   List<T^>^ list
) 
where T: ref class, gcnew()

Parameters

list
A list of entities to save

Type Parameters

T
Generic class type
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==";
 
//Log to the console
db.EnableLogging();
 
//Open the database connection
db.OpenConnection();
 
List<Person> persons = new List<Person>();
 
//Create a new Person to save to the database
Person john = new Person();
john.FirstName = "John";
john.LastName = "Smith";
persons.Add(john);
 
//Create a new Person to save to the database
Person jane = new Person();
jane.FirstName = "Jane";
jane.LastName = "Smith";
persons.Add(jane);
 
//Save it to the database 
db.Save(persons);
 
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=="
 
'Log to the console
db.EnableLogging()
 
'Open the database connection
db.OpenConnection()
 
Dim persons As New List(Of Person)()
 
'Create a new Person to save to the database
Dim john As New Person()
john.FirstName = "John"
john.LastName = "Smith"
persons.Add(john)
 
'Create a new Person to save to the database
Dim jane As New Person()
jane.FirstName = "Jane"
jane.LastName = "Smith"
persons.Add(jane)
 
'Save it to the database 
db.Save(persons)
 
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