public int GetImagesCount(string ticket, TransitImageQueryOptions options) { using (DBlog.Data.Hibernate.Session.OpenConnection(GetNewConnection())) { ISession session = DBlog.Data.Hibernate.Session.Current; CountQuery query = new CountQuery(session, typeof(DBlog.Data.Image), "Image"); if (options != null) options.Apply(query); return query.Execute<int>(); } }
public List<TransitImage> GetImages(string ticket, TransitImageQueryOptions options) { using (DBlog.Data.Hibernate.Session.OpenConnection(GetNewConnection())) { ISession session = DBlog.Data.Hibernate.Session.Current; ICriteria cr = session.CreateCriteria(typeof(Image)); if (options != null) { options.Apply(cr); } IList<Image> list = cr.List<Image>(); List<TransitImage> result = new List<TransitImage>(list.Count); foreach (Image obj in list) { result.Add(new TransitImage(session, obj, ticket)); } return result; } }