How to render Max(Substring) 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/28
7:31 UTC
Read the original article
Hit count: 207
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: 12345.10 where 12345 is the invoice number, and 10 refers to the current year (2010). So I need to calculate the Max function only over the first 5 digits. How can I do it?
© Stack Overflow or respective owner