I’ve read in Ayendes blog about Esent, which is an embeddable database storage engine (ISAM) which is part of Windows.

There is also a managed API being created at CodePlex. What I did is implemented a backend for SourceGrid using Esent PersistentDictionary. This is similar to windows DataGrid, which takes data from DataSet (or DataTable, or DataView) structure.

However, with DataSet there are two problems.

  • Whole data must be kept in memory. I did home-testing and found that keeping 1 million rows in DataTable increases my app memory consumption from roughlt 50MB to 250MB.
  • Data is not persistent.

Essent backend solved both of these two problems (although sorting is not available with PersistentDictionary out of the box). This image shows the result:

Of course the data is simplistic, first column is just ID, second is one of the 5 random strings. Whole esent DB file takes 674 MB on disk. There is at the moment a small problem with hidden rows implementation, but that can be fixed easily. If hidden rows feature is temporarily disabled, then the data can be viewed immediately, scrolling works just fine.

I plan to make other backends too. Probably the next one will be NHibernate backend, with embedded FireBird as an example. Hope that it will support sorting, and will handle data (at least on local computer) easily. I will try to test SourceGrid against 10 mln rows.

Finally, i managed to find how to do grouping with NHibernate. Basically, what you need to know is that grouping and aggreagte functions are all made with IProjection.  A quick example would be:

return session.CreateCriteria(typeof(HumanTask))
.CreateCriteria(“Human”, “responsibleuser”)

What this does is: group tasks assigned to human, and returned the count and name for each group.  A nice way to understand how to use some features of NH is to read it’s code. I found this by looking at NHibernate.Test.Criteria.CriteriaQueryTest class. There is a nice method which creates a lot of criterias. that method is CloningProjectionsTest, have a look at it.

In a week i will be speaking at .Net user group meeting in Vilnius and in Kaunas.

I will be presenting a topic about NHibernate. Not sure what exactly it will be like. Probably something from either beggining with NHibernate, and profiling performance with NHProf.

Meeting in vilnius: http://www.eventbrite.com/event/370532272

Meeting in Kaunas: