Hello all, consider these POCOs:
class Foo {
int Id {get;set;}
string Name {get;set;}
}
class Bar {
int Id {get;set;}
string PropA {get;set;}
Foo PropB {get;set;}
}
Now what i want to achieve is using an ISQLQuery
with a root entity of Bar
to also hydrate the PropB property.
ISQLQuery barsAround = nhSes.CreateSQLQuery("select b.Id, b.PropA, {????} from Bar b inner join Foo f on f.Id = b.FK_FooId");
barsAround.SetResultTransformer(Transformers.AliasToBean<Bar>());
IList<Bar> results = barsAround.List<Bar>();
where in the {????} is the fragment that fetches the b.Id and b.Name and hydrates the property PropB of entity Bar.
I cannot use ISQLQuery.AddEntity()
because that results in managed entities and i cannot use managed entities. The bars fetched are versions of a bar so the same Id for each row kills the NHibernate engine.