Use HQL or Criteria
select max(id) from ClassName

On Fri, May 8, 2009 at 1:00 AM, Alessandro C. <
[email protected]> wrote:

>
> I need a function that returns the max ID of a generic entity (table).
>
> In my base class I tried to write the following:
>
>            var query = new ActiveRecordContext().Session.Linq<T>();
>            int num = query.Select(keyName).Max();
>
> where keyName is the string containing the name of the primary ID.
>
> but I have the following error:
> The type argument cannot be inferred by the usage...etc.etc.
>
> If I write the statement in the real class (not the base class), see
> the following, everything is ok.
>            var query = new ActiveRecordContext
> ().Session.Linq<Colorant>();
>            int num = query.Select(c => c.ColorantID).Max();
>
> How can I write the correct statement in the base class?
>
> Thanks.
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"NHibernate Contrib - Development Group" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com.ar/group/nhcdevs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to