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”)
.SetProjection(Projections.ProjectionList()
.Add(Projections.RowCount())
.Add(Property.ForName(“responsibleuser.FullName”))
.Add(Property.ForName(“responsibleuser.FullName”).Group())
);

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.

Advertisements

ODF toolkit

June 24, 2009

As of 2009 06 16, I am a member of “Open Document Format Toolkit Union”. In short, this organization is managing http://odftoolkit.org/ website, and it’s main purpose is to “provides a home for libraries that ease the development of applications that support ODF”

What will happen next: my project AODL2 will be merged back to original AODL mercurial repository. At odftoolkit.org site, a new project will be launched with its own infrastructure. So hopefully things will get better.

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:

http://www.eventbrite.com/event/370536284

Yesterday i’ve worked on SourceGrid. The goal was to create a new sample to show how SourceGrid.DataGrid performs with a data set of 1000000 (one million) rows.

I had to create an asyncrhonyous data loader. I’ve measured that 200k rows are added to System.Data.DataTable in around 4 seconds on my computer.  You can check sample number 53 and see what is the result.

Initially, there a was performance problem with selection drawing code. The problem was that if you select many rows, for example, 900k, then the selection code called the function which calculated the drawing region for it.  I used dotTrace to track down the problem. My observation was that while there were 18 calls to method “Draw”, there where almost 400k calls to get DataRowView from DataTable.

The solution was to clip the selection region with the visible area region. After that, once the DataGrid is finished populating with data, selection and drawing works like a charm.

There are still problems which asynchronous loading, however. If you try to sort a column while the grid has not finished populating, you will get an exception.

I hope this will be a nice feature for somebody ;)