How to render Max(Substgring) with Lambda Extensions
        Posted  
        
            by caifa
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by caifa
        
        
        
        Published on 2010-05-27T22:37:44Z
        Indexed on 
            2010/05/27
            22:41 UTC
        
        
        Read the original article
        Hit count: 363
        
Hi everybody. I'm using NHibernate with Lambda Extensions. I'd like to know how to nest a Max function with a Substring.
The following statement retrieves Max("invoice_id")
var ret = session
          .CreateCriteria<Invoice>()
          .SetProjection(Projections.Max("invoice_id"))
          .UniqueResult();
but in my case the field invoice_id is made in this way: 123452010 where 12345 is the invoice number, and 2010 is the current year. So I need to calculate the Max function only over the first 5 digits. How can I do it?
© Stack Overflow or respective owner