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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T12:54:00+00:00 2026-06-03T12:54:00+00:00

I dont normally deal with data like this but I thought id give it

  • 0

I dont normally deal with data like this but I thought id give it a try. As it turned out I failed :/ and am not sure how to proceed.

I have a database object track:

public virtual string Type { get; set; }

public virtual IList<DateTypeTrack> TrackDates { get; set; }

With a mapping file:

Table("Tracks");
Map(x => x.Type).Not.Nullable();
HasMany(x => x.TrackDates).KeyColumn("TrackID").Cascade.All();

The DateTypeTrack Object looks like this:

public virtual DateType DateType { get; set; }
public virtual Track Track { get; set; }
public virtual int Days { get; set; }

With a mapping file like this:

Table("DateTypeTracks");
References(x => x.DateType, "DateTypeID").Not.Nullable();
References(x => x.Track, "TrackID").Not.Nullable();
Map(x => x.Days).Not.Nullable();

If its necessary, Ill post the DateType code aswell, but I dont think its needed.

And am trying to write a delete method in my service layer that is pretty simple:

public void PushDelete(int id)
    {
        Track track = _tracks.Get(id);

        try
        {
            _tracks.BeginTransaction();
            _tracks.Delete(track);
            _tracks.CommitTransaction();
        }
        catch (Exception)
        {
            _tracks.RollbackTransaction();
            throw;
        }
    }

I keep getting an error:

could not delete collection: [TSE.Domain.DatabaseObjects.Track.TrackDates#12][SQL: UPDATE DateTypeTracks SET TrackID = null WHERE TrackID = @p0]

I dont know why its trying to do the update at the end, but I suppose that is what is causing the issue. What sort of recourse do I have?

Thanks.

  • 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-03T12:54:03+00:00Added an answer on June 3, 2026 at 12:54 pm

    since the DateTypeTrack already cares for the association between the two entities you should mark the HasMany as Inverse to tell NH that the hasmany does not maintain it (the Update)

    HasMany(x => x.TrackDates).KeyColumn("TrackID").Cascade.All().Inverse();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I dont think this is possible in c# but ill post it anyway. Given
Normally it is possible to apply data validation in excel through vba but i
The dev version of Netbeans has Git support. This is great. I'm not sure
I have an issue usign QTableWidgetItem. I normally use the QTableWidget like this this->setItem(i,
This might be a very stupid question, but I still dont completely understand and
I dont know if this is possible. In SSIS Derived column transformation, can you
I dont really know how to explain exactly what function i need but ill
I dont know how to debug structures like: fun1 <- function(obj){ a<-c(obj,4) c(a,5) }
I dont understand why I am not able to update a field on the
I have read some other articles like here and here but unfortunately there are

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.