tags:

views:

15

answers:

1

I'm sure I've done this before but I can't recall how. I have 2 classes, say Person and Company. I'm instantiating a new Person and want to set it up so that when I save it to repository it will be associated with Company A. Company A already exists but I don't want to pull the entire thing from the DB just so I can write:

person.Company = CompanyA;

How can I set the Person's Company property so that it will be associated with CompanyA without pulling CompanyA from the DB? I definitely don't want to map the CompanyID property btw!

+2  A: 

Use ISession.Load(id). Ayende has a good post about Get vs. Load.

person.Company = session.Load(companyAId);
Jamie Ide
Thank you for your quick response. Apparently I can't accept your answer for another 6 minutes, but I will when I can :).
statichippo