Ninja Database Pro
Add Load Update Delete Records
Basic Tasks > Add Load Update Delete Records

 

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(); //Valid only for non Silverlight projects

//database.Storage = new MyDocumentsDatabase(); //Valid for Silverlight 4 Out of Browser

 

//The database is automatically created if it does not exist

db.OpenDatabase();

//Create a person to insert

Person person = new Person();

person.Name = "John Smith";

//Insert a person

//The type is automatically registered and an auto increment primary key is created on the first save

db.Save(person);

//Load a person

Person personCopy = db.Load<Person>(person.PersonId);

//Update a person

person.Name = "John Jones";

db.Save(person);

//Delete a person

db.Delete(person);

 

db.CloseDatabase();