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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:28:03+00:00 2026-06-08T06:28:03+00:00

I have a Winforms Control from a 3rd party developer and want to store

  • 0

I have a Winforms Control from a 3rd party developer and want to store its data directly in a MongoDB. It is a gantt chart which has a list of Resources and a list of Appointments. The Appointments have also a list of Resources to which is responsible for the mapping of Appointments to Resources.

To simplify the storage I created a class called “PlanningDocument”:

public class PlanningDocument
{
[BsonId]
public ObjectId Id { get; set; }
public string Name { get; set; }
public ResourceCollection Resources { get; set; }
public ItemCollection Schedule { get; set; }
}

The Document gets stored correctly in the database (I’m using MongoVUE to check the content of the database). But the Items in the “Schedule” collection do not contain references to the Resources as it is during runtime of the program.

What do I have to do to store referenced relations between objects?

EDIT: I’ll try to explain what I want to do with a more concrete example:

    public class Identity
    {
        public string Id;

        public Identity()
        {
            Id = Guid.NewGuid().ToString();
        }
    }

    public class Thing : Identity
    {
        public string Name = "";
    }

    public class Drawer : Identity
    {
        public List<Thing> SomeThings;
        public List<Thing> AdditionalThings;

        public Drawer()
        {
            SomeThings = new List<Thing>();
            AdditionalThings = new List<Thing>();
        }
    }

I have these classes “Thing” and “Drawer”. The Drawer can contain Things in “SomeThings” and “AdditionalThings”.

var d = new Drawer();
d.AdditionalThings.Add(new Thing() { Name = "Thing 1"});
d.AdditionalThings.Add(new Thing() { Name = "Thing 2" });
d.AdditionalThings.Add(new Thing() { Name = "Thing 3" });

d.SomeThings.Add(new Thing() { Name ="Thing A"});
d.SomeThings.Add(d.AdditionalThings[0]);

When I store the same Thing in both Lists (like done with “Thing 1” here), MongoDB stores a copy of Thing 1 – not a reference.

My Question is: does a generic way exist to make MongoDB and the C# driver store a reference here instead of a copy?

Thanks in advance
Achim

  • 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-08T06:28:07+00:00Added an answer on June 8, 2026 at 6:28 am

    No, there is no way to store a reference automatically in the C# driver. This is by design as storing references automatically would imply that we would automatically resolve those references at run time, which we do not do.

    Since your “thing” objects have an identity, then it won’t be difficult to keep them in sync when you update one of them, either by doing it client-side or by writing the appropriate update statement using the positional $ operator and the update-multi flag.

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

Sidebar

Related Questions

I have a WinForms control inherited from TreeView and I want it to automatically
We have a 3rd party control loaded in our C# WinForms app. When we
In WinForms, you have Control.BeginInvoke() , which means you can marshall a call from
Say I have a label control in Winforms and I want to do some
I have a WinForms control on which I want to display two things: An
I have a winforms project that I want to develop a custom control for.
I have a class that handles events from a WinForms control. Based on what
I'm using the Chart control from .net 4.0 in my C# WinForms app. I
I have a custom WinForms control (inherits from control, i.e. without user interface jsut
I have a custom winforms control (inherits from Component) that has some strings displayed

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.