Something like this may do the trick
NHSession.QueryOver<Customer>()
.Where(
Restrictions.Eq(
Projections.SqlFunction("length", NHibernateUtil.String,
Projections.Property<Customer>(x => x.RegistryCode)),
8
)
)