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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:03:33+00:00 2026-06-18T02:03:33+00:00

I have some issue with mongo c# driver. I have such class: class MongoEntity<T>

  • 0

I have some issue with mongo c# driver. I have such class:

class MongoEntity<T>
{
    public ObjectId Id {get; set;}
    public DateTime CreatedAt { get; set; }
    public DateTime UpdatedAt { get; set; }
    public int Version { get; set; }
    public T Entity { get; set; }
}

And during serialization my entities to database I have such document:

"_id" : "510654cf33d22e1774d5a2a9",
"CreatedAt" : {
    "DateTime" : ISODate("2013-01-28T10:37:02.932Z"),
    "Ticks" : NumberLong("634949662229321756")
 },
 "UpdatedAt" : {
    "DateTime" : ISODate("2013-01-28T10:37:02.932Z"),
    "Ticks" : NumberLong("634949662229321756")
 },
 "Version" : 1,
 "Entity" : {
    "EntityKey" : "tom@gmail.com",
    "Password" : "ICy5YqxZB1uWSwcVLSNLcA==",        
    "Email" : "tom@gmail.com",
    "Name" : "Tom Anderson"
 }

What I really want is to have all properties of entity object in my document in the same level as properties of MongoEntity object like this:

"_id" : "510654cf33d22e1774d5a2a9",
"CreatedAt" : {
    "DateTime" : ISODate("2013-01-28T10:37:02.932Z"),
    "Ticks" : NumberLong("634949662229321756")
 },
 "UpdatedAt" : {
    "DateTime" : ISODate("2013-01-28T10:37:02.932Z"),
    "Ticks" : NumberLong("634949662229321756")
 },
 "Version" : 1,
 "EntityKey" : "tom@gmail.com",
 "Password" : "ICy5YqxZB1uWSwcVLSNLcA==",        
 "Email" : "tom@gmail.com",
 "Name" : "Tom Anderson"

without Entity embedded object. How can I implement this in easiest way ?

P.S. What I am really looking for is some configuration of driver or writing custom serializer, maybe some workaround with dynamic, I do not want to change current class structure Enteties <-> MongoEntity

Thx for help.

  • 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-18T02:03:35+00:00Added an answer on June 18, 2026 at 2:03 am

    There is no way to configure the built-in serializers to produce the document format you want (where the Entity fields are lifted one level up).

    You would have to write a custom serializer, but it would be difficult because you either have to write a new serializer for each <T>, or you would have to write a sophisticated serializer that works for any <T>.

    WiredPrairie’s suggestion (Person : MongoEntityBase) is the recommended solution.

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

Sidebar

Related Questions

I have some issue regarding display name of property in result of get request
I have some issue with displaying date correctly, using the MVC4 DateTime object. In
Hi I have some issue regarding constructor and destructor. I have list class, which
I have some urgent issue which I could not find answer for across the
I have a weird issue. I have some icons that are being built based
I have an issue with some HTML displayed in Drupal, but I am not
I know that there are some threads have a similar issue with this thread.
Good morning. I've been having this issue for some days and have been lokking
I have an issue while storing some special character values into db. For e.g.
i have an issue i could use some help with, i have python list

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.