LINQPad db4o Driver: Feature Overview

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.

Installation

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.

The Open Dialog

The Schema

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.

Schema Overview

Write Queries

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:

Simple Query

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.

Access Fields or Properties

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.

Update Objects

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:

Update Objects

That’s It

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.

Tagged on: , ,

9 thoughts on “LINQPad db4o Driver: Feature Overview

  1. Jan Semorad

    Error in LinqPad with this Db4o driver:

    ParseException – Parsing failure: unexpected ‘+’; expected , (Line1, Column 21).

    But if we make a query manually in LinqPad – via query editor with Language=C# statement(s) Database= – without any left tree or connection – it works ok – “result.Dump();” works ok.

    We can buy LinqPad – but will LinqPad intelisense do work with driver error above?

    Thank You very much for Your help!

    Best regards Jan Semorad, Prague, CZ, EU.

  2. gamlerhart Post author

    Hi Jan

    Thanks for reporting the issue.
    Are you storing a nested class? I think the issue is that such classes have a ‘+’ in their name (or at least when stored in db4o). And my driver fails to cope with that. I will fix it.

    In general: I expect that there are still tons of bugs. I just made it to the state where the driver can deal with my databases. When people using other features than me then the broken/missing
    parts will show up.

    To the intellisense: I don’t know, i don’t have a commercial LinqPad license =/. Therefore I’m not sure how good it works with my driver.

  3. Jan Semorad

    Thank You very much for Your answer!

    YOU ARE RIGHT ! ! !

    Here are some names of classes in our db4o :

    System.Collections.Generic.Dictionary`2[System.String,ErmSchema.SubHromada]
    ErmSchema.SubHromada
    ErmSchema.KixSubProgram+Argument
    Utils.BusinessObject+Errors_
    System.TimeSpan
    Utils.BusinessObject+Reports_
    System.Collections.Generic.List`1[System.String]
    ErmSchema.KlientFolder+Sets+KlientFolders
    System.Collections.Generic.Dictionary`2[System.Int64,System.String]
    ErmSchema.KlientFolder+Sets+KixMachines
    System.Collections.Generic.Dictionary`2[EZAnalyzer.EzFileType,System.Collections.Generic.Dictionary`2[System.String,EZAnalyzer.EzFile]]
    System.Collections.Generic.Dictionary`2[System.String,EZAnalyzer.EzTema]
    System.Collections.Generic.List`1[EZAnalyzer.EzVystup]
    EZAnalyzer.EzSablonaVystupu
    System.Collections.Generic.List`1[EZAnalyzer.EzTemaVystupu]
    System.Collections.Generic.List`1[System.String[]]
    EZAnalyzer.EzOpPorovnani+Group
    System.Collections.Generic.List`1[EZAnalyzer.EzVystupExpedice]

    It was generated via:
    Dim q = From ezw As Object In g.db4o Select ezw
    Dim l As New System.Collections.Generic.List(Of String)
    For Each o In q
    If l.Contains(o.GetType.ToString) Then

    Else
    l.Add(o.GetType.ToString)
    End If
    Next
    WebBrowserConsole.DocumentText = String.Join(vbCrLf, l.ToArray).ToWhiteHTML

  4. Alex S

    Hello Gamlor,

    Could you provide a recent version of the lpx file? I’m having the same problems as Jan was. I can query fine in a C# Statement query, but if I attempt to connect to my database via your lpx driver it fails with the same error.

    For security purposes I cannot list my class names, sorry.

  5. Anthony

    I’m also getting a parsing error:
    ParseException – Parsing failure: Unexpected end of input reached; expected, (Line 1, Column 21).

  6. gamlerhart Post author

    @Alex S: The link in the post should contain the newest version. Redownload it, and go through the installation procedure again. Then you should have the newest version. If it doesn’t work I almost certainly need an example database to look into the issue.

    @Anthony: Can you send me an example database which shows this issue: Send it to roman.stoffel@gamlor.info

  7. Pingback: Updates for db4o LINQPad Driver | Gamlor