NHibernate bag is always null

Posted by Neville Chinan on Stack Overflow See other posts from Stack Overflow or by Neville Chinan
Published on 2010-05-25T20:45:24Z Indexed on 2010/05/25 20:51 UTC
Read the original article Hit count: 306

Filed under:
|

I have set up my mapping file and classes as suggested by many articles

class A { ... IList BBag {get;set;} ... }

class B { ... A aObject {get;set;} ... }

<class name="A">...<bag name="BBag" table="B" inverse="true" lazy="false"><key column="A_ID" /><one-to-many class="B" /></bag>...

<class name="B">...<many-to-one name="aObject" class="A" column="A_ID" />...

I added a set of A's to the A table and a set of B's to the B table, all the data is stored as expected. However if I try and access aInstance.BBag.Count I get a null reference exception. I think I missing some key knowledge on how an bag gets instantiated. Thanks

© Stack Overflow or respective owner

Related posts about nhibernate

Related posts about mapping