Hi,

I need some hints on creating a better hql...

The query should return a list of current assessments of all clients
(the newest assessment of the client)

each client can have a couple of assessments, the assessment has a
ValidFrom and ValidTo date


This one is working, but i think there must be a better way:

from Clients.Assessment a
where cast(a.Client.Id as String) +'-' + cast(a.ValidTo as String) in
(Select cast(a.Client.Id as String)  + '-' + cast(max(a.ValidTo) as
String)
from Clients.Assessment as a group by a.Client.Id)


here a excerpt of the class including the mapping

namespace Clients
{
    public class Assessment
    {
        [NHMA.ManyToOne(0, Column = "Client", NotNull = true)]
        public virtual Client Client { get; set; }

        [NHMA.Property(0)]
        [NHMA.Column(1, Name = "ValidFrom", SqlType = "smalldatetime",
NotNull = true, Index = "idxValid")]
        public virtual DateTime ValidFrom { get; set; }

        [NHMA.Property(0)]
        [NHMA.Column(1, Name = "ValidTo", SqlType = "smalldatetime",
NotNull = true, Index = "idxValid")]
        public virtual DateTime ValidTo { get; set; }

        [NHMA.Property(0, Length = 500, NotNull = false)]
        public virtual string Comments { get; set; }

                //...
     }
}

pleas help me
tia cybere

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" 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/group/nhusers?hl=en.

Reply via email to