If you use stateless sessions you can work totally disconnected:
ChildEntity.ParentEntity = new ParentEntity(){ Id = 100 };
This is mostly the same as using ISession.Load(), because it won't go to
the database (if your entity is configured as lazy, that is).
RP
On Monday, September 17, 2012 4:24:47 PM UTC+1, Mike B wrote:
>
> Hello,
>
> What I need is to be able to map both foreign key and a reference to a
> parent object. For example:
>
>
> class Parent
>> int ParentID
>> List<Child> Children
>>
>
>>
>
>> class Child
>> int ChildID
>> int ParentID // foreign key
>> Parent ParentEntity
>>
>> class ParentMap
>> HasMany(x => x.Children)
>> .KeyColumn("ParentID ") // PROBLEM!
>> .Inverse()
>> .Cascade.All();
>>
>> class ChildMap
>> Map(x => x.ParentID); // PROBLEM!
>> References(x => ParentEntity);
>
>
> The reason behind this is that operations are done in a detached
> environment, and the detached environment doesn't "know" about NHibernate,
> so solutions like ChildEntity.ParentEntity = Sessions.Load(parentEntityID)
> are not acceptable. We explicitly need to work with the foreign key as a
> property. Any help very appreciated
>
>
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/nhusers/-/2-PXFSUUryQJ.
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.