Considering Team โ attitude of the athlete and the request of all athletes. What I don't understand about fetch="Join" ? If this mapping causes the command to load through the connection? When repeating athletes, these are still lazy loads of Team.
public class AthleteMap : ClassMapping<Athlete> { public AthleteMap() { ManyToOne(a => a.Team, o => { o.Fetch(FetchKind.Join); o.Lazy(LazyRelation.NoLazy); } ); } }
What this HBM produces:
<class name="Athlete" table="Athletes"> <id name="Id" type="Int32" /> <property name="FirstName" /> <property name="LastName" /> <many-to-one name="Team" fetch="join" lazy="false" /> <property name="Created" /> </class>
iteration:
var session = factory.OpenSession(); foreach (var athlete in session.Query<Athlete>()) Console.WriteLine("{0} {1}", athlete.FirstName, athlete.Team.Name);
source share