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 6690599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:39:21+00:00 2026-05-26T05:39:21+00:00

I have an object model like that: Folder – simple structure with name etc.

  • 0

I have an object model like that:

  • Folder – simple structure with name etc.
  • File – complex object containing reference to Folder in which it is contained.

Folder doesn’t know its Files and I don’t want it to know. The relation is many-to-one and should be known on File’s side only.

Anyway, I would like to rely on my database’s ON DELETE CASCADE feature, so that when I remove Folder, I want all Files within that Folder to be deleted automatically. I can’t use NHibernate’s cascading as there is no relation from Folder to File.

I know that there is on-delete="cascade" option for <key> element in case of one-to-many relationship, but I can’t find its equivalent for my model – when the relation is defined on many side.

Am I doing something wrong or do I really need to go through and delete all the Files within deleted Folder manually?

  • 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-26T05:39:21+00:00Added an answer on May 26, 2026 at 5:39 am

    You could try to map the one-to-many side with access="noop". That way you don’t need a property in your classes but still have the mapping.

    In Fluent NHibernate that would be someting like this:

    HasMany(Reveal.Member<Folder, IEnumerable<File>>("_files"))
       .KeyColumn("column_name")
       .Access.NoOp()
       .Inverse()
       .ForeignKeyCascadeOnDelete();
    

    Note: For that you need an _files field of type IEnumerable<File> in the Folder class (limitation of Fluent NHibernate, can only map really existing fields or properties). But this field can always be null, it will never be used.

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

Sidebar

Related Questions

I have a column model like that: ... {name:'password',index:'password', width:100}, {name:'type.name',index:'type.name', width:100}, ... My
I have an object model that looks like this (pseudo code): class Product {
I have an object model that looks like this: public class MyObjectModel { public
Say I have a model object 'Person' defined, which has a field called 'Name'.
The GoDiagram object model has a GoDocument. GoViews have a reference to a GoDocument.
I'm relatively new to the Component Object Model specification - I have a simple
I know that the asp.net repeater doesnt have a Client side object model, and
I have an object model like this: class Car { public string Manufacturer; public
I have an object that looks like this when outputted via a print_r Array
I have an object model called MyObject that I'm serializing to a json string

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.