Instead of "NHibernateUtil.String" I should use this type of "NHibernateUtil.Int16" because the parameter "length" should always be a number, not a string.
Something like that:
NHSession.QueryOver<Customer>() .Where( Restrictions.Eq( Projections.SqlFunction("length", NHibernateUtil.Int16, Projections.Property<Customer>(x => x.RegistryCode)), 8 ) )
source share