It looks like the same thing as the link Fabio sent, but I don't want
to use an alpha version in my production website.  I'll put a little
test case though, just to make sure we're talking about the same
thing:

  <class name="Category">
    <id name="ID" column="CategoryID" type="Int32" unsaved-value="0"
access="field.pascalcase-underscore">
      <generator class="native" />
    </id>
    <many-to-one name="Template" column="TemplateID" class="Template" /
>
</class>

 <class name="Template" discriminator-value="2">
    <id name="ID" column="TemplateID" type="Int32" unsaved-value="0"
access="field.pascalcase-underscore">
      <generator class="native" />
    </id>
    <discriminator column="TemplateTypeID"/>
   <set name="TemplateItems" access="field.camelcase-underscore"
cascade="all-delete-orphan" inverse="true" lazy="false">
      <key column="TemplateID"/>
      <one-to-many class="TemplateItem"/>
    </set>
</class>

And the code:
TemplateItem ti = new TemplateItem();
Template t = new Template;
t.AddItem(ti);
repo.Create(t);
Category c = new Category();
c.Template = t;
repo.Create(c);

Category c2 = repo.GetById<Category>(c.ID);
// This will cause the repo to load the Template and Template Item,
instead of just accessing the templateID...
Assert.AreEqual(c.Template.ID,c2.Template.ID);


Thanks for all the quick help!
Jamie

On Feb 17, 11:09 am, Ayende Rahien <[email protected]> wrote:
> Please create a test case for that.
> It looks like you have mapped the many-to-one as lazy=false
>
> On Tue, Feb 17, 2009 at 11:07 AM, Jamie Houston <[email protected]> wrote:
>
> > I have Entity A with a many-to-one to Entity B.  Entity B then has a
> > set of Entity C, with lazy=false, because every time Entity B is used,
> > all of the Entity Cs are used.
>
> > I'm trying to determine the ID of Entity B, while I'm using Entity A,
> > but it's loading all of the Entity C items when I access B.
>
> > So, if I call EntityA.EntityB.ID <http://entitya.entityb.id/>, it loads
> > all of EntityB.EntityCs.  I
> > tried to create another property on A that was just EntityBID (that
> > accessed the same column as EntityB.ID, but NHibernate got all weird.
>
> > Hopefully I'm explaining this ok... I searched and couldn't find a
> > solution.  I basically want to get the ID of B, without loading all of
> > the lazy=false items on B when I do so.
>
> > Thanks,
> > jamie
--~--~---------~--~----~------------~-------~--~----~
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