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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:54:36+00:00 2026-06-02T02:54:36+00:00

I am using fluent nHibernate for my mappings as follow: public class ContentTagMap: ClassMap<Employee>

  • 0

I am using fluent nHibernate for my mappings as follow:

public class ContentTagMap: ClassMap<Employee>
{
    public EmployeeMap()
    {
        Id(t => t.Id);
        Map(t => t.Name);
        HasManyToMany(t => t.Company);
    }
}

public class CompanyMap: ClassMap<Company>
{
    public HelpMap()
    {
        Id(h => h.Id);
        Map(h => h.CompanyName).Length(6000);
        Map(h => h.address).Length(6000);
        HasManyToMany(h => h.Employee);
    }
}

These mappings produce Employee Table ,Company Table and EmployeeToCompany Table

Employee Table

Id    Name
1     John
2     MAX

Company Table

Id    CompanyName   address
1      HTC           ABC
2      HTC2          India

EmployeeToCompany Table

Employee_Id     Company_Id
1               1
2               1

How can I delete the employee with Id 1?

  • 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-02T02:54:39+00:00Added an answer on June 2, 2026 at 2:54 am

    Unless I’m misunderstanding your question you should be asking:

    How can i delete the content of the table using NHibernate?

    Fluent NHibernate is only a tool to aid in the mapping of your entities. NHibernate is what you use to create, read, update and delete data. In any event:

    9.5. Deleting persistent objects

    ISession.Delete() will remove an object’s state from the database. Of
    course, your application might still hold a reference to it. So it’s
    best to think of Delete() as making a persistent instance transient.

    From the NHibernate Documentation

    You probably want to also define a Cascading style on your many to many relationship (HasManyToMany) in your mapping.

    If you use Cascade.SaveUpdate in your many to many whenever you delete an entity on one side of the relationship it will delete that entity and any relationships. If you remove the association (ex. if you removed an Employee from a Company) it will only delete the relationship (EmployeeToCompany). This is what I’ve typically found to work in the case of many to many relationships.

    Look at this article for more details on mapping and using a many to many relationship in Fluent NHibernate.

    how to keep many to many relationships in sync with nhibernate?

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

Sidebar

Related Questions

I'm using Fluent NHibernate for my mappings and the SchemaExport class to the database
I am using my fluent nhibernate mappings to generate my MS SQL Server database.
Is there an easy way to automatically truncate strings using fluent nHibernate mappings. I
I define my data model using Fluent nHibernate POCO classes + mappings. I'm also
I am using Fluent NHibernate AutoMappings to map my entities, including a few component
We are using Fluent NHibernate for data object model in the company i work.
This is how I create Session Factory using Fluent Nhibernate public static ISessionFactory CreateSessionFactory()
I've been using NHibernate (with Fluent-NHibernate mappings) in a project for the first time
Using the fluent-nhibernate mappings, I am trying to meet a requirement to create the
I am trying to map several tables using Fluent Nhibernate. My tests are giving

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.