In a regular query you should use SetResultTransformer, i didn't work with multiquery, but i'm sure if it is possible, you should use SetResultTransformer anyway.
Gustavo. On Sun, Jan 18, 2009 at 8:12 PM, Joe <[email protected]> wrote: > > I am trying to get a subset of data and a total records count with > multiquery and a custom DTO. My problem is that when the results are > returned they come back as object[] and not my DTO. I can get it to > work using a mapped object, but not the DTO that is imported. > > Here is some code: > var hql = "select new PostSummary(p.Id, p.Title) from PostEntity p > order by p.DateCreated asc"; > using (var session = sessionManager.OpenSession()) > { > var query = session.CreateMultiQuery(); > > query.Add(session.CreateQuery(hql) > .SetMaxResults(pageSize) > .SetFirstResult(pageIndex)) > .Add(session.CreateQuery("select count(*) from > PostEntity")); > > var results = query.List(); > > var items = (IList) results[0]; > var count = (IList) results[1]; > } > > public class PostSummary > { > public int PostId { get; set; } > public string Title { get; set; } > > public PostSummary(int id, string title) > { > PostId = id; > Title = title; > } > } > > <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" > assembly="YABE.Domain" namespace="YABE.Domain.Model"> > <import class="PostSummary" /> > </hibernate-mapping> > > I am trying to get a list of PostSummary in the first resultset, but I > keep getting a list of object[]. > > What am I doing wrong? > > Thanks, > Joe > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
