This time I’m giving a small feature overview for my LINQPad driver for db4o. I promise that is the last post about this for a while =). Why now? Because I’ve implemented the core set of features and now it is has reached a usable state.
Well, just take a look at my previous post. I just repeat the most important steps here: Download the plugin-file and save it somewhere. Open LINQPad and add a new connection. Click on ‘View more drivers’ and there on ‘Browse’. Now choose the downloaded lpx-file and confirm it.
Opening a Database
After installing there’s a new ‘db4o Driver’ entry in the ‘Add connection’ dialog. After choosing it you need to specify the path to your db4o database file. Optionally you can add the assemblies which contain the classes of the domain model. If you do so, you can access the original classes in LINQPad. You can also enable the write access to the database, when you want to do updates from within LINQPad. Of course that’s a little dangerous, since you can potentially destroy your database with it, due to bugs in the Driver or a bogues update statement.
On the left you can see the schema of the stored objects. Note that it is a little simplified. Especially instances of generic types are simplified. For example an instance of Preference<Food> is shown as Preference_1_Food. Also the schema explorer doesn’t show any inheritance structure.
Now we can write queries. Ensure that the database is selected in the query window. You can query by just using the entity name. We just can write a simple query like this:
Now we can start using the fields etc. in the database. When you didn’t specify any assemblies for the connection, then you can refer any field by its name or by a capitalized property. When there’s a field called ‘name’ you can access it with ‘name’ or with ‘Name’. Auto properties are accessed by their name. However when you’ve specified the assemblies for the classes in the beginning, then you have the API etc. from your classes available.
Now you can see why generic instances have such a silly name. That makes queries for them much easier.
Access Meta Data
You just can access the ‘MetaData’ property in LINQPad to see the meta-data:
Or drill down further:
Insert New Instances
In order to create a new instance you can call .New() on the entities. If you have specified you’re assemblies you can pass in the arguments for the constructor. Or just use directly the constructor of your classes. After that you just can store the created instance. Of course you need to allow write access to the connection to use this feature.
You can update objects by just using the Store-method. Or you can use the .UpdateAll extension method which iterates over a query result and applies the changes:
Well that’s about the features currently implemented. Any wishes, questions or issues? Let me know. Any feedback is welcome. I’ll tweet if there are minor updates.
Btw. the code is still hosted here. Maybe I get around making real project out of it.
- Elegant Event Handling in Java