next step is to do some quick and dirty console logging to figure out
what you are working with.
I would also read the (n)hibernate docs on MultiQuery. That will be
the best source of information.

var oList = oMultiQuery.List();
ConsoleWriteLine(oList.GetType());
foreach(var o in oList)
{
   ConsoleWriteLine(o.GetType());
}

On Apr 3, 8:26 am, similitude2009 <[email protected]> wrote:
> This line fails because for some reason, i cant get MultiQuery return
> anything other than array of object[].
> Transformers does not work either with MultiQuery.
>
> var persons_one = oList[0] as IEnumerable<PersonDTO>;
>
> On 2 avr, 16:58, Jason Meckley <[email protected]> wrote:
>
> > mutliequery returns multiple result sets which can be anything, hence
> > IList instead of IList. In this instance the number of items in oList
> > is known because you executed 2 queries. they just happen to return
> > the same result type. cast each item in the list and combine.
>
> > var oList = oMultiQuery.List();
> > var persons_one = oList[0] as IEnumerable<PersonDTO>;
> > var persons_two = oList[1] as IEnumerable<PersonDTO>;
> > var all_persons = persons_one.Concat(persons_two);
>
> > or, if your using .net 2.0
>
> > var oList = oMultiQuery.List();
> > var persons_one = oList[0] as IEnumerable<PersonDTO>;
> > var persons_two = oList[1] as IEnumerable<PersonDTO>;
>
> > var all_persons = new List<PersonDTO/>();
> > all_persons.AddRange(persons_one);
> > all_persons.AddRange(persons_two);
>
> > On Apr 2, 8:51 am, similitude2009 <[email protected]> wrote:
>
> > > I use a class PersonDTO to get a lighter Person class.
>
> > > class Person
> > > {
> > > string FirstName{get,set};
> > > string LastName{get,set};
> > > string Age{get,set};
>
> > > }
>
> > > class PersonDTO
> > > {
> > > string FirstName{get,set};
> > > string LastName{get,set};
>
> > > }
>
> > > if i do a simple (notice the 'new' in the query)
>
> > > ISession oSession = GetSession();
> > > IQuery oQuery = oSession.CreateQuery("from Person p select new
> > > PersonDTO(p.FirstName,p.LastName) where p.Age = 10");
> > > IList<PersonDTO> oList  = oQuery.List<PersonDTO>();
> > > oSession.Close();
> > > ISession oSession = GetSession();
>
> > > I get an IList<PersonDTO> as result, which is fine, but when i do it
> > > with multi query, i get IList<ArrayList> of Object[], which is very
> > > hard to reuse.
> > > I m trying to get the syntax of Transformers with multiqueries.
>
> > > IMultiQuery oMultiQuery = oSession.CreateMultiQuery();
>
> > > IQuery oQuery1 = oSession.CreateQuery("from Person p select new
> > > PersonDTO(p.FirstName,p.LastName) where p.Age = 10");
> > > IQuery oQuery2 = oSession.CreateQuery("from Person p select new
> > > PersonDTO(p.FirstName,p.LastName) where p.Age = 20");
>
> > > oMultiQuery.Add(oQuery1);
> > > oMultiQuery.Add(oQuery2);
>
> > > IList oList  = oMultiQuery.List();
>
> > > oSession.Close();
>
> > > I get an IList of ArrayList in as the result of the multiquery in
> > > oList, each ArrayList of this oList is Object[]
>
> > >  I tried to add some of these commands but none does anything
> > > oQuery1.AddResultTransformer(Transformers.AliasToBean(typeof
> > > (PersonDTO)));
> > > oQuery1.AddResultTransformer(Transformers.AliasToEntityMap);
> > > oMultiQuery.AddResultTransformer(Transformers.AliasToBean(typeof
> > > (List<PersonDTO>)));
> > > oMultiQuery.AddResultTransformer(Transformers.AliasToBean(typeof
> > > (PersonDTO)));
>
> > > I would like to get an IList<PersonDTO> or IList<IList<PersonDTO>>.- 
> > > Masquer le texte des messages précédents -
>
> > - Afficher le texte des messages précédents -
--~--~---------~--~----~------------~-------~--~----~
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