Hello,

I have a relationship like so:

StudyPlan -> StudyPlanInstitutionFees

I run a method that does something like this:

var studyPlan = this.studyPlanRepository.SelectById(studyPlanId);
studyPlan.StudyPlanInstitutionFees.Clear();

// ADD SOME NEW FEES HERE

this.studyPlanRepository.Update(studyPlan);


Now the issue is I am deleting existing fees, and I have a unique key
constraint on InstititutionId in the database, and it is trying to
insert first. Am I missing something so that it will delete the old
items first?

Mapping for collection:

  <bag name="StudyPlanInstitutionFees" inverse="true" lazy="true"
cascade="all-delete-orphan">
      <key column="StudyPlanId" />
      <one-to-many
class="Phoenix.Link2Uni.ApplicationManager.Domain.StudyPlanInstitutionFee,
                   Phoenix.Link2Uni.ApplicationManager.Domain" />
    </bag>

<class name="StudyPlanInstitutionFee" table="StudyPlanInstitutionFees"
lazy="false">
    <!-- Id -->
    <id name="Id" column="Id" type="int">
      <generator class="native" />
    </id>

    <!-- Properties -->
    <property name="InstitutionName" column="InstitutionName"
type="string" not-null="true" />
    <property name="InstitutionId" column="InstitutionId" type="int"
not-null="true" unique="true" />
    <property name="Fee" column="Fee" type="Decimal" not-null="true" />
    <property name="OrphanFlag" column="OrphanFlag" type="Boolean"
not-null="true" update="false" insert="false" />

    <!-- Many to one mappings -->
    <many-to-one name="StudyPlan" column="StudyPlanId" cascade="none"
not-null="true" fetch="join" />
  </class>



Cheers

-- 
Stefan Sedich
Software Developer
http://weblogs.asp.net/stefansedich

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