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>>.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---