NHibernate.FlowQuery v0.8 Released

Today I finally got the time to release a new version of NHibernate.FlowQuery ( FlowQuery ). Version 0.8 of FlowQuery can be downloaded here. The new version contains one new feature ( OrderBy<TProjection>, which lets you order your result set by one ( or more ) of the projections ), a few bug fixes ( Is.Not.* in sub-queries now actually negates the expression which it, somehow, didn’t in the previous version ) and a minor change in the API ( an IRevealer now exposes its’ IRevealConvention ).

The new feature can be used like this:

var users = session.FlowQuery<User>()
    .OrderBy<UserDto>(x => x.Name)
    .Select(x => new UserDto()
    {
        Name = x.Firstname + " " + x.Lastname
    });

This is actually the same as doing:

var users = session.FlowQuery<User>()
    .OrderBy(x => x.Firstname + " " + x.Lastname)
    .Select(x => new UserDto()
    {
        Name = x.Firstname + " " + x.Lastname
    });

But it’s a bit more convenient, don’t you think?

The new feature also provides overloads to support strings:

var users = session.FlowQuery<User>()
    .OrderBy<UserDto>("Name")
    .Select(x => new UserDto()
    {
        Name = x.Firstname + " " + x.Lastname
    });

Every overload also has a matching OrderByDescending method and the new feature can also be combined with the old OrderBy-syntax with ease:

var users = session.FlowQuery<User>()
    .OrderBy(x => x.Age)
    .OrderBy<UserDto>(x => x.Name)
    .Select(x => new UserDto()
    {
        Age = x.Age,
        Name = x.Firstname + " " + x.Lastname
    });

The only possible downside is that it can only be used with projections made using ISelectSetup ( .For(x => x.Prop).Use(x => x.Prop) ) or a lambda expression ( member initializer ). It does not work using IProjections.

Enjoy! (:

/Niklas Källander

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: