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

  • SEARCH
  • Home
  • 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 8093421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T20:30:00+00:00 2026-06-05T20:30:00+00:00

I have class with back reference: public class Employee : Entity { private string

  • 0

I have class with back reference:

public class Employee : Entity
    {
        private string _Name;
        private string _Position;
        private Employee _SupervisorBackRef;
        private IList<Employee> _Subordinates;
        private IList<BusinessPartner> _BusinessPartners;

        public virtual string Name
        {
            get { return _Name; }
            set { _Name = value; }
        }

        public virtual string Position
        {
            get { return _Position; }
            set { _Position = value; }
        }

        public virtual Employee SupervisorBackRef
        {
            get { return _SupervisorBackRef; }
            set { _SupervisorBackRef = value; }
        }

        public virtual IList<Employee> Subordinates
        {
            get { return _Subordinates; }
            set { _Subordinates = value; }
        }

        public virtual IList<BusinessPartner> BusinessPartners
        {
            get { return _BusinessPartners; }
            set { _BusinessPartners = value; }
        }
    }

Because back reference SupervisorBackRef and Subordinates share same foreign key:

create table Employees (
        Id INT not null,
       Name NVARCHAR(255) null,
       Position NVARCHAR(255) null,
       EmployeeFk INT null,
       primary key (Id)
    )

Problem is that although I tryed override it, if I delete any supervisor, it delete all his Subordinates. I tryed this:

class EmployeeOverride : IAutoMappingOverride<Employee>
{
    public void Override(FluentNHibernate.Automapping.AutoMapping<Employee> mapping)
    {
        mapping.HasMany(x => x.Subordinates).Cascade.None();
        mapping.HasOne(x => x.SupervisorBackRef).Cascade.None();
    }
}

But it isn’t work. I tryed it changed to different another combinations, i tryed this override delete, but nothing help.

If I delete any Employee, it delete all his Subordinates.

I don’t know how can i recognize if this override function working.

From many texts on internet i understand that Cascade.None() should work, most people has opposite problem, deleting/updating/… don’t work, so I’m really confused.

  • 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-06-05T20:30:01+00:00Added an answer on June 5, 2026 at 8:30 pm

    Problem was, that I had in another place (in HasManyConvention.Apply) set in instance Cascade.AllDeleteOrphan() and it was higher priority.

    PS: I don’t know if is beter similar post like that answered od deleted. For me it looks like a problem which I had more time in past, but it is variation on “I dont’t know my own code…”

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

Sidebar

Related Questions

I have class with collection as below public class MyClass:IXmlSerializable { int vesrion; private
I have class that looks like this: class A { public: class variables_map vm
I have an object where I maintain a relationship to another object: public class
Let's say I have these two very basic entities: public class ParentEntity { public
I have a simple class like this: class A { public: void f(const int&
I have a code first model: namespace InternetComicsDatabase.Models { public class Issue { [Key]
I am using this Android class to implement a countdown: http://developer.android.com/reference/android/os/CountDownTimer.html I have created
I have a class that holds several vectors of objects: struct ComponentA { public:
i have these models: public class Student { public int Id { get; set;
I have the following class class node { public: node() { } node(const node&);

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.