Also this one should be the easy part but just in case...
Do you initialize your Children collection in the constructor of the parent
class?

Something like:

public class ParentEntity
{
   public ParentEntity()
   {
      ChildList = new List<ChildEntity>();
   }

   public virtual IList<ChildEntity> ChildList{get;set;}

   // ...... the rest of the class stuff ....
}

--
Mohamed Meligy
Senior Developer (Microsoft Technologies - Technical Delivery)
Injazat Data Systems
P.O. Box: 8230 Abu Dhabi, UAE.

Direct:  +971   2 4045385
Mobile: +971 50 2623624, +971 55 2017 621

E-mail: [email protected]
Weblog: http://gurustop.net


On Wed, Jun 2, 2010 at 12:19 AM, Mohamed Meligy <[email protected]>wrote:

> How about setting inverse to true on this collection mapping ?
> This will make any effect on the collection not reflect to the DB.
>
> so, something like:
>    myParent.Children.Add(myChild); //makes no use
> So, when you want to assign parent you'll do something like:
>    myChild.Parent = myParent; // This will be reflected when saving the
> child entity
>
> See
> http://knol.google.com/k/fabio-maulo/nhibernate-chapter-6-collection-mapping/1nr4enxv3dpeq/9#6%282E%298%282E%29%28C2%29%28A0%29Bidirectional_Associations
>
> --
> Mohamed Meligy
> Senior Developer (Microsoft Technologies - Technical Delivery)
> Injazat Data Systems
> P.O. Box: 8230 Abu Dhabi, UAE.
>
> Direct:  +971   2 4045385
> Mobile: +971 50 2623624, +971 55 2017 621
>
> E-mail: [email protected]
> Weblog: http://gurustop.net
>
>
>
> On Tue, Jun 1, 2010 at 5:53 PM, sternr <[email protected]> wrote:
>
>> It's a simple: public virtual IList<ChildEntity> ChildList{get;set;}
>>
>> On Jun 1, 4:39 pm, Fabio Maulo <[email protected]> wrote:
>> > ley us see the implementation of the collection getter
>> >
>> >
>> >
>> >
>> >
>> > On Tue, Jun 1, 2010 at 10:37 AM, sternr <[email protected]> wrote:
>> > > Hi,
>> > > (I hope I'm posting in the right news-group, if not please refer me in
>> > > the right direction, thanks!)
>> >
>> > > I'm developing an ASP.Net web application using NHibernate, in a
>> > > session-per-request paradigm.
>> > > I've got a page, where the user can update a certain entitiy.
>> > > My Code-Behind creates a new entity with the form's data and calls the
>> > > Session.SaveOrUpdateCopy method to do the actual update.
>> >
>> > > This works perfectly well, except for a certain entity I have, which
>> > > has a collection of a different entity mapped with cascade all. (a
>> > > simple one-to-many with cascade all).
>> >
>> > > The problem is, since the update page allows updating only the flat
>> > > entity properties, the collection stays null, and the update process
>> > > deletes all the related childs (because of the cascading).
>> > > The thing is, I need the cascading option as specified (for other
>> > > scenarios, like delete a child entity etc.).
>> >
>> > > Is there a way to tell NHibernate not to update this "undirty"
>> > > properties?
>> > > Thanks!
>> >
>> > > --sternr
>> >
>> > > --
>> > > 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]<nhusers%[email protected]>
>> <nhusers%[email protected]<nhusers%[email protected]>>
>> > > .
>> > > For more options, visit this group at
>> > >http://groups.google.com/group/nhusers?hl=en.
>> >
>> > --
>> > Fabio Maulo
>>
>> --
>> 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]<nhusers%[email protected]>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/nhusers?hl=en.
>>
>>
>

-- 
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