Question: How would I go about summing the values of one column for all rows containing a name that is part of a target group, as well as a specific year which is in another column?

Example: I would like to sum the values of a, b, c for 2015 to make a new Category, "e", and to do the same for 2016.

```
Year Category Value
2015 a        2
2015 b        3
2015 c        2
2015 d        1
2016 a        7
2016 b        2
2016 c        1
2016 d        1

```

To give something like this:

```
Year Category Value
2015 d        1
2015 e        7
2016 d        1
2016 e        10

```

Thanks!

Answer: 
I found the solution.

To hint NHibernate to use the proper UserType use: `MappedAs` extension method, like so:

```
using(var session = _factory.OpenSession()) {
   var q = session.Query<SomeEntity>()
           .Where(s => s.IpAddressField.InetEquals(
                 IPAddress.Parse("4.3.2.1").MappedAs(NHibernateUtil.Custom(typeof(IPAddressUserType))
            );

```

}
The year is 2019 and I'm still stuck on version **3.3.2.GA of NHibernate** and the `MappedAs` extension method exists only on version **4.x** onwards.

My scenario was the need to pass a large string as a parameter to a supported method in an `HqlGeneratorForMethod`.

I created the following class to store any large string to use as a parameter of any method throughout the application:

```cs
public class StringClob
{
    public StringClob()
    {
    }

    public StringClob(string value)
    {
        Value = value;
    }

    public virtual string Value { get; protected set; }
}

```

In order to link the `NHibernateUtil.StringClob` type with the `string` value I had the idea to create a mapping for my class without informing table mapping just the property (**I use FluentNHibernate to map class**):

```cs
public class StringClobMap : ClassMap<StringClob>
{
    public StringClobMap()
    {
        Id(x => x.Value, "VALUE").CustomType("StringClob").CustomSqlType("VARCHAR(MAX)").Length(int.MaxValue / 2);
    }
}

```

And now hypothetically following the example of @krdx the usage would look like this:

```cs
using(var session = _factory.OpenSession()) 
{
    var q = session.Query<SomeEntity>()
                   .Where(s => s.IpAddressField.InetEquals(new StringClob("<large_string_here>")));

    // ...
}

```

Therefore by passing the `StringClob` class as a parameter, NHibernate gets the custom type defined in the mapping.

I hope I helped those who still use **NHibernate 3.3.2.GA**.