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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:46:17+00:00 2026-06-13T13:46:17+00:00

Lets say we have these classes: class Teacher { public int Id { get;

  • 0

Lets say we have these classes:

class Teacher {
    public int Id { get; set; }
    public string FullName { get; set; }
    public List<Course> Courses { get; set; }
}

class Course {
    public int Id { get; set; }
    public string CourseName { get; set; }
}

Now lets say I have selected one Teacher instance from the list of teachers and I’ve been redirected to a page where I can edit what courses this teacher can teach. So there’s a list of all the courses she can teach at the momemt (taken from the database) with a “remove” option and a dropdownlist of all available courses that a user can select; when a user selects a course from the dropdownlist, it gets added to a “she can teach” list. At the end is a “save” button.

But, when a users removes a course from the list or adds a course, I don’t want to save it to the database until pressed “save” button. My question is: where to hold Teacher object and its child Course objects while being edited and before saved to database?

So far I’ve been using Session to hold the edited object; adding a new course just adds a child object to its collection, and removing a courses removes a child object from Session. Is that the best way to go on or is there something better (or at least, cleaner)?

  • 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-13T13:46:18+00:00Added an answer on June 13, 2026 at 1:46 pm

    Session should be fine, as long as you’re ok with keeping all this in memory, and potentially losing it if the session is lost prematurely.

    But if you’re looking for persistence, I’d probably suggest a “pending” database table, where you can keep the pending transactions (adds and deletes) until they’re ready to be saved. When you’re on this screen, you combine the real data with the pending data, and when you save, you apply the pending changes to the real data and kill the pending changes.

    If they cancel, all you have to do is delete the pending records.

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

Sidebar

Related Questions

So lets say I have these classes: public class Person { public string Name
Let's say we have these two classes: public class Base { public static int
Lets say we have these packages and classes: package p1; public class A1 {
Lets say I have these classes: class Foo { public $_data; public function addObject($obj)
Lets say I have two classes one base class: public class BaseModel { }
Let's say I have these classes: public class BaseMapClass<T1, T2> { protected T1 Thing1;
let's say I have these classes : internal class A { public B Field
Lets say I have a two classes: class A : public QObject {}; class
Let's say I have these classes: class A<T> { void set(T t) {} }
Say I have these classes: public class Loan { @Id private Long id; @ManyToOne

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.