NoSQL: Eloquera and ASP.NET MVC 3 (and Ninject)

I thought today I’d give Eloquera a swing, just to do something fun and new before starting the other obligations of the day. Eloquera is another objected oriented database, like Db4o or MongoDb. The difference is that Eloquera is natively .NET and it’s free whereas db4o is not. But I honestly do not prefer the one above the other. I’m just trying things out.

I wrote a quick web application as a POC.

First, download Eloquera from here. I took the x64 .NET 4.0 version and installed it..
I edited the C:\Program Files\Eloquera\Eloquera Server 3.0\Eloquera.config file so that the Eloquera files are in c:\temp\db by adding DatabasePath=”c:\temp\db”:

[code language=”xml”]
<Server ServerPort="43962"
AllowGroups="Everyone" />
<SmartRuntime Smart="true" />

Oh and don’t forget to take a look in the Samples directory in the program folder.

Then I created an new ASP.NET MVC 3 application and edited the Global.asax.cs. Here is the relevant portion:

Here are the gotcha’s:

  • The OpenSession() method opens the database and if it doesn’t exist, a new one is created with some dummy data.
  • I use the session-per-web request pattern (the lifetime of a session is the same as a web request). You can see that here in the complete Global.asax.cs.
  • I do not have to deal with Transactions with Eloquera.
  • I have to register types explicitly, else the Views won’t recognize them: db.RegisterType(typeof(iSay.Story));

And then I only have to get the current session in my Repositories with (private DB db = MvcApplication.db;) and I’m good to go just like any other app!

[code lang=”csharp”]
using Eloquera.Client;

namespace iSay.Infrastructure
public class StoryRepository : IStoryRepository
private DB db = MvcApplication.db;
public IEnumerable<Story> getStories()
return db.ExecuteQuery("SELECT Story").OfType<Story>();

public void Add(Story s)

public int getNumberOfComments(Story s)
var comments = s.Comments.Count();
return comments;

The controller (I used Ninject again, as you can see I injected the controller with IStoryRepository):

[code lang=”csharp”]
using iSay.Infrastructure;

namespace iSay.Controllers
public class HomeController : Controller
private IStoryRepository _repo;

public HomeController(IStoryRepository repo)
_repo = repo;

public ActionResult Index()
var stories = _repo.getStories();
return View(stories);


Hmm, that’s almost embarrassing, as easy as this is.

You can view the source code here. Maybe I’ll spice it up later but I have to go now.

6 Replies to “NoSQL: Eloquera and ASP.NET MVC 3 (and Ninject)”

    • Hi Dmytro,
      Do you mean the C# dynamic type? No I haven’t actually. My dayjob is taking all of me at the moment, unfortunately.
      Is it very cool?

  • Very cool… this is the future according to me !!!

    BUT one thing remains with Eloquera and this example… how would how write your Update method of your repository !?!? Would it look something like this ??? :

    public void Update(T item)
    var realItem = db.Query(x => x.Id == item.Id);

    realItem.Prop1 = item.Prop1;
    realItem.Prop2 = item.Prop2;
    realItem.Prop99 = item.Prop99;


    This is a question I am asking myself since I have used Db4o, which has a function called Bind() that allows you to take an object that does not originate from the database, and replace the corresponding (as per the internal id) object in the database. This functionality would be great in Eloquera (unless is already exists).

    Maybe Dmytro can answer, also…


  • I’m very happy to discover this web site. I wanted to thank you for ones time just for this fantastic read!! I definitely appreciated every part of it and i also have you book-marked to check out new stuff in your web site.

Geef een reactie

Het e-mailadres wordt niet gepubliceerd. Vereiste velden zijn gemarkeerd met *

%d bloggers liken dit: