public void Dispose() { _api.Dispose(); }
void CRUD() { /// ## CRUD /// (Create / Read / Update / Delete) /// /// For basic usage, LimeBean requires zero configuration and no additional code! /// Database schema is maintained on-the-fly: /// no need to create tables and columns (see [Fluid Mode](#fluid-mode)). /// /// Take a look at the following sample scenario: /// #if CODE // Use a temporary in-memory SQLite database var api = new BeanApi("Data Source=:memory:", SQLiteFactory.Instance); // Enter the "Fluid Mode" api.EnterFluidMode(); #endif /// **Create** #if CODE // Create a bean. "Bean" means "data record", "dispense" means "instantiate new". var bean = api.Dispense("book"); // Each bean has a kind. "Kind" is a synonym for "table name" var kind = bean.GetKind(); Console.WriteLine(kind); // Fill it with some data bean["title"] = "Three Comrades"; bean["rating"] = 10; // Store it // Table "book" with 2 columns, one string and one integer, will be generated automatically var id = api.Store(bean); // Each saved bean has an ID, or primary key Console.WriteLine(id); #endif /// **Read** #if CODE // Load by ID bean = api.Load("book", id); #endif /// **Update** #if CODE // Make some edits bean["title"] = "Learn LimeBean"; bean["release_date"] = new DateTime(2015, 7, 30); bean["rating"] = "good"; // Save updated bean // One new column ("release_date") will be added // The type of column "rating" will be expanded from integer to string api.Store(bean); #endif /// **Delete** #if CODE api.Trash(bean); // Don't forget to close the connection api.Dispose(); #endif }