Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 297501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T06:38:43+00:00 2026-05-12T06:38:43+00:00

Further to my other question given the following classes and fluent map, is there

  • 0

Further to my other question given the following classes and fluent map, is there any way to automatically cascade delete a DriversLicense when the related Person is deleted? Note, I do not want the Person class to have any knowledge of the DriversLicense class, but I also don’t want orphaned data if a Person gets deleted.

public class PersonMap : ClassMap<Person>
{
        public PersonMap() { Id( x => x.Id ); }
}

public class PersonMap : ClassMap<Person>
{
        public PersonMap() { Id( x => x.Id ); }
}

public class DriversLicense
{
        public virtual Person Person { get; set; }
        public virtual string State { get; set; }

        public override bool Equals( object obj ){ ... }
        public override int GetHashCode(){ ... }
}

public class DriversLicenseMap : ClassMap<DriversLicense>
{
        public DriversLicenseMap()
        {
                UseCompositeId().WithKeyReference( x => x.Person );
                Map( x => x.State );
        }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T06:38:43+00:00Added an answer on May 12, 2026 at 6:38 am

    Since you can’t cascade deletes from DriversLicense to Person, for business reasons, and you really don’t what the Person to know about the DriversLicense and you have a really good reason for this requirement then I think you could handle it in one of two ways:

    1. Move the responsibilty for deleting the DriversLicense object further into your service or repository levels and doing what Chris suggested. Query for a Person’s DriverLicnese objects and delete them before you delete the Person entity.

    2. You could create an Nhibernate Interceptor or EventHandler that performs deletes for you. This approach leaves your repositories and domain nice and clean and is probably the approach I would take if I couldn’t reference the DriveLicenese collection from my person object. (NHibernate Event Documentation)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given a class class RandomName extends CommonAppBase {} is there any way to automatically
I have a program that can send text to any other program for further
Will there be any further resultset to process if the lookup table in the
Further to my question on disabling validators using javascript - Disable ASP.NET validators with
Further to this question: Algorithm for determining a file’s identity Recap : I'm looking
Background (question further down) I've been Googling this back and forth reading RFCs and
This is a further question based on this answer: How can I implement a
To continue to question further I'm more interested in blogs, websites who once in
I used the code from the following question to insert a YouTube video into
This question is related to another question I asked. In my other question I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.