locked
In Fluent NHibernate HasManyToMany association, How to set a primitive field in Child object that is different for each parent object? RRS feed

  • Question

  • User652258676 posted

    I have two entities that have hasManyToMany association between them. i.e. each of the entity has a collection of the other.

    For example, I have entities A and B, So A will have a collection of B in it. Now when I read A, it will also read the ICollection(). So in this collection, I want to set the value of a primitive field, different for each A object. But when I do so, my changes to B are passed to other A objects using the same B object.

    I just want to overwrite the data in the child collection. But when i do it, the child object gets overwritten for every parent the uses it.

    Any suggestions on that?

    I hope I'm pretty clear what i need to do, but I'm open for a discussion on this.

    Monday, April 20, 2015 2:02 AM

Answers

  • User1711366110 posted

    For example, I have entities A and B, So A will have a collection of B in it. Now when I read A, it will also read the ICollection(). So in this collection, I want to set the value of a primitive field, different for each A object. But when I do so, my changes to B are passed to other A objects using the same B object

       As per this case, refer the following forum link which had similar situation as Fluent nHibernate in Many to Many Mappings which may guide you to resolve this case :

    http://stackoverflow.com/questions/6771400/fluent-nhibernate-issue-in-many-to-many-mappings

    --
    with regards,
    Edwin

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, April 21, 2015 1:52 AM