{"id":1530,"date":"2011-03-20T23:03:34","date_gmt":"2011-03-20T22:03:34","guid":{"rendered":"http:\/\/www.gamlor.info\/wordpress\/?p=1530"},"modified":"2021-07-03T13:35:54","modified_gmt":"2021-07-03T12:35:54","slug":"db4o-driver-for-linqpad","status":"publish","type":"post","link":"https:\/\/www.gamlor.info\/wordpress\/2011\/03\/db4o-driver-for-linqpad\/","title":{"rendered":"db4o Driver for LINQPad"},"content":{"rendered":"<div id=\"attachment_1536\" style=\"width: 310px\" class=\"wp-caption alignright\"><a href=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/03\/conquer-with-linqpad.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1536\" class=\"size-medium wp-image-1536\" title=\"conquer-with-linqpad\" alt=\"LINQPad and db4o\" src=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/03\/conquer-with-linqpad-300x259.png\" width=\"300\" height=\"259\" srcset=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/03\/conquer-with-linqpad-300x259.png 300w, https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/03\/conquer-with-linqpad.png 538w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-1536\" class=\"wp-caption-text\">LINQPad and db4o<\/p><\/div>\n<p>Way back in my posts about db4o I complained about the missing tool support. I also demonstrated how to use <a title=\"db4o: Tools For Adhoc Querying And Modification\" href=\"?p=949\">LINQPad for ad hoc<\/a> queries. However wouldn\u2019t it be cooler if you can access db4o databases more directly with <a href=\"http:\/\/www.linqpad.net\/\">LINQPad<\/a>? Like a relational databases? Well that\u2019s possible by creating a driver for LINQPad. That\u2019s what I\u2019ve developed, a small prototype driver for db4o!<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>The driver allows you to open db4o databases like any other database in LINQPad. You can query it without providing the original classes. Just open it and start writing LINQ queries against it.<\/p>\n<h2>How to Use It<\/h2>\n<p>The plugin only works with .NET 4.0 and the LINQPad version for 4.0. <a href=\"https:\/\/www.gamlor.info\/files\/db4oPad.lpx\">Download the plugin-file<\/a> and save it somewhere. Open LINQPad and add a new connection. Click on \u2018View more drivers\u2019 and there on \u2018Browse\u2019. Now choose the downloaded <a href=\"https:\/\/www.gamlor.info\/files\/db4oPad.lpx\">lpx-file<\/a> and confirm it. Afterwards choose the \u2018db4o Driver\u2019 on the list and proceed. Now a dialog shows up which lets you choose a database file. Choose the database file which you want to open.<\/p>\n<p>After that there is an entry of it on the left, with a list of stored classes and fields. In the query-window you can start to write queries. Use the class-names as the data-source. For example to query instances of the Car class just write queries like this \u2018from c in Car select c\u2019.<\/p>\n<div id=\"attachment_1534\" style=\"width: 588px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/03\/using-it.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1534\" class=\"size-full wp-image-1534\" title=\"using-it\" alt=\"Using the Driver\" src=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/03\/using-it.png\" width=\"578\" height=\"528\" srcset=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/03\/using-it.png 578w, https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/03\/using-it-300x274.png 300w\" sizes=\"(max-width: 578px) 100vw, 578px\" \/><\/a><p id=\"caption-attachment-1534\" class=\"wp-caption-text\">Using the Driver<\/p><\/div>\n<h2>Limitations and Bugs<\/h2>\n<p>Of course the implementation is in a very early stage. It probably crashes with complex data models. Let me know of cases which don\u2019t work. Anyhow here\u2019s a list of issues and limitations.<\/p>\n<ul>\n<li>Name collisions can happen and cause issues\/crashes: With generics, same class-names in different namespaces, field-names etc.<\/li>\n<li>Right now you cannot use your original assemblies to access the database. And if you load your own assemblies into LINQPad it probably crashes.<\/li>\n<li>At the moment all fields are accessible by the field-name and a property name. When you\u2019re class has a field called \u2018name\u2019 you can access it also with the name \u2018Name\u2019. That is a bit confusing.<\/li>\n<li>Complex types may cause crashes, especially with array-fields.<\/li>\n<li>No support for client-server mode and configuring your database.<\/li>\n<li>Advanced db4o features like your own type-handler will cause a crash.<\/li>\n<li>It uses its own db4o version (8.1.184.15492). You cannot provide the db4o version you want to use.<\/li>\n<li>It is slow.<\/li>\n<\/ul>\n<h2>Planned Features<\/h2>\n<p>So here\u2019s an overview of the features I\u2019m planning to implement:<\/p>\n<ul>\n<li>Option to load assemblies with the original classes.<\/li>\n<li>More stability against name collisions. Although I\u2019m not aiming for solving 100% of all cases.<\/li>\n<li>Insert and update support.<\/li>\n<li>Access to some meta-data. For example if a field is indexed or not.<\/li>\n<\/ul>\n<p>And let me also tell the features I\u2019m not going to implement. (Of course you can implement that yourself and contribute it.)<\/p>\n<ul>\n<li>Client-Server mode: I\u2019m not really interested in that.<\/li>\n<li>.NET 3.5 or Mono support. I\u2019m focusing only on 4.0.<\/li>\n<\/ul>\n<h2>How is it Implemented?<\/h2>\n<p>Well I\u2019m going to elaborate the implementation-details in future posts. Roughly it works like this: First open the db4o database and read the meta-data. Then resolve well-known types. For each unknown type generate dynamically a type. Finally generate a database-context for LINQPad which contains the entry-points for all queries.<\/p>\n<p>Currently the source is available on my <a href=\"https:\/\/github.com\/gamlerhart\/db4opad\">scratch repository<\/a> on Github. Probably I\u2019ll create a proper project and also mirror it on GitHub.<\/p>\n<h2>Final Word<\/h2>\n<p>Try it yourself ;). <a href=\"https:\/\/www.gamlor.info\/files\/db4oPad.lpx\">Here\u2019s the download<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Way back in my posts about db4o I complained about the missing tool support. I also demonstrated how to use LINQPad for ad hoc queries. However wouldn\u2019t it be cooler&hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_links_to":"","_links_to_target":""},"categories":[126,150],"tags":[21,100,214],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.gamlor.info\/wordpress\/wp-json\/wp\/v2\/posts\/1530"}],"collection":[{"href":"https:\/\/www.gamlor.info\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gamlor.info\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gamlor.info\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gamlor.info\/wordpress\/wp-json\/wp\/v2\/comments?post=1530"}],"version-history":[{"count":10,"href":"https:\/\/www.gamlor.info\/wordpress\/wp-json\/wp\/v2\/posts\/1530\/revisions"}],"predecessor-version":[{"id":3896,"href":"https:\/\/www.gamlor.info\/wordpress\/wp-json\/wp\/v2\/posts\/1530\/revisions\/3896"}],"wp:attachment":[{"href":"https:\/\/www.gamlor.info\/wordpress\/wp-json\/wp\/v2\/media?parent=1530"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gamlor.info\/wordpress\/wp-json\/wp\/v2\/categories?post=1530"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gamlor.info\/wordpress\/wp-json\/wp\/v2\/tags?post=1530"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}