In my last post I talked about how easy it was to create a database with LiteDb.
But accessing your data is even easier.
To start off, assuming we have no document (i.e., structure) associated with our data – we can create a generic table on the fly using the built in BSonDocument structure.
In this example, I first use my database to get a collection of documents under “FirstTable”. If it’s your first time creating this document, don’t worry, it’ll be created for you, so no need to do any “CREATE” mumbo jumbo.
var FirstTable = database.GetCollection("FirstTable");
Now I’m going to create some data. The simplest, most brain-dead way to do this is to create a Dictionary, make some columns and give them whatever values I want that are of type BsonValue
Dictionary<string, BsonValue> docs