I have a problem's. I need to select from database entries for people with identifiers that are in the externalIds list. After that, I need to select for each person only 1 entry with the latest StartTime. I tried, for example, with SetProjection (GroupProperty and Max property), but as a result, it returns me only the StartTime list when I need the PersonnelPresence list. My method looks like this:
public IList<PersonnelPresence> GetLastPersonnelPresencesForPeopleExternalIds(IList<string> externalIds) { ICriteria criteria = Session.CreateCriteria(typeof(PersonnelPresence), "pp").CreateCriteria("pp.Person", "p") .Add(Restrictions.In("p.ExternalId", externalIds.ToList())) .SetProjection(Projections.ProjectionList() .Add(Projections.GroupProperty("p.Id")) .Add(Projections.Max("pp.StartTime"))); return criteria.List<Object>() as List<PersonnelPresence>; }
Does anyone know how to solve my problem? Thanks in advance.
user2229474
source share