I tried that with:

                query.Add(session.CreateQuery(hql)
                              .SetMaxResults(pageSize)
                              .SetFirstResult(pageIndex)
                              .SetResultTransformer(new
AliasToBeanResultTransformer(typeof(PostSummary))))
                    .Add(session.CreateQuery("select count(*) from
PostEntity"));

and

                query.Add(session.CreateQuery(hql)
                              .SetMaxResults(pageSize)
                              .SetFirstResult(pageIndex)
                              .SetResultTransformer
(Transformers.AliasToBean(typeof(PostSummary))))
                    .Add(session.CreateQuery("select count(*) from
PostEntity"));

and I still get the same results.

When I am looking at item[0] in the locals window, the following is
displayed:

-               [0]     {object[2]}     object {object[]}
                [0]     1073    object {int}
                [1]     "Test"  object {string}

Thanks,
Joe

On Jan 18, 12:25 pm, "Gustavo Ringel" <[email protected]>
wrote:
> 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- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
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