NHibernate icriteria SQLFunction Left

74 Views Asked by At

How do i implement the following statement in NHibernate iCriteria

        Select * From LECNNy where Left(Address,4)='test'

It has to be something like

         Projections.SqlFunction("left"("Address"), 

But how do i pass the number of chars and the var ?

1

There are 1 best solutions below

0
KeldJ On

Some further research gave the following answer :

store.Add(
      Restrictions.Eq(
                       Projections.SqlFunction(
                                               "left", 
                                               NHibernate.NHibernateUtil.String,
                                               Projections.Property("Address"),
                                               Projections.Constant(4)
                                             ),
                       'test'
                      )
       );