❔ Insert a document to a MongoDB

Hey there... I am trying to build a simple API connected to a MongoDB. I have customers and I want to add those to the DB This is my customer class:
public class Customer : BaseCustomer
{
public Customer(string name, string surname, string address) : base(name, surname, address)
{
}
}
public class Customer : BaseCustomer
{
public Customer(string name, string surname, string address) : base(name, surname, address)
{
}
}
It inherits from BaseCustomer:
public class BaseCustomer
{
public string Key { get; }
public string Name { get; }
public string Surname { get; }
public string Address { get; }

protected BaseCustomer(string name, string surname, string address)
{
Name = name;
Surname = surname;
Address = address;
Key = "test";
}
}
public class BaseCustomer
{
public string Key { get; }
public string Name { get; }
public string Surname { get; }
public string Address { get; }

protected BaseCustomer(string name, string surname, string address)
{
Name = name;
Surname = surname;
Address = address;
Key = "test";
}
}
I just simply insert it like this:
public void CreateEntry(TObject o)
{
_mongoCollection.InsertOne(o);
}
public void CreateEntry(TObject o)
{
_mongoCollection.InsertOne(o);
}
Why is everything displayed except the key? (Img1) If I change the Key property in BaseCustomer to
public string Key { get; set; }
public string Key { get; set; }
only the key appears (Img2) Why??? Thanks in advance
No description
No description
1 Reply
Accord
Accord9mo ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.