Syntax: Multi Something

time to read 1 min | 195 words

As I have already explained, I am doing a lot of work with NHibernate's MultiCriteria and MutliQuery. There are very powerful, but they are also mean that I am working at a level that has a lot of power, but a bit of a complex syntax. I want to improve that, but I am not sure what the best way to do it. Anything here is blog-code, meaning that I didn't even verified that it has valid syntax. It is just some ideas about how this can go, I am looking for feedback.

The idea here is to have a better way to use NHQG expressions, and to remove the need to manually correlate between the index of the added query and the index in the result set. It should also give you better syntax for queries that return a unique result.

new CriteriaQueryBatch()
 .Add(Where.Post.User.Name == "Ayende", OrderBy.Post.PublishedDate.Desc)
   .Paging(0, 10)
   .OnRead(delegate(ICollection<Post> posts) { PropertyBag["posts"] = posts; })
 .Add(Where.Post.User.Name == "Ayende")
   .Count()
   .OnRead(delegate(int count) { PropertyBag["countOfPosts"] = count; })
 .Execute();
 

Waiting for you thoughts...