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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:36:53+00:00 2026-06-16T01:36:53+00:00

Hopefully this is a simple one, but not sure if it will be as

  • 0

Hopefully this is a simple one, but not sure if it will be as information online seems to indicate that you are unable to query without using a strongly typed model.

To give some background to the scenario, I have a client side javascript application, which creates and stores models locally (local storage). However there is a web service (ASP MVC) which can be sent models via authorised users and it will validate it and persist it.

Now the problem is that as the client side application is updated the models tend to change, think of it like database migration scripts, but with models. However they all have versions and migration scripts so the system will allow a saved (client side) older model to be loaded and then updated to the latest version and re-saved.

So the client side deals with differing version models well, and im sure your all wondering where the mongodb/c# question is, so here it comes.

On the server side the validation criteria is always against the latest version of the model at that given time. So if the latest client side model version is 2.3 then the server side will be the same, and will validate it correctly.

So at this point lets say I save my client side model @ version 3.1, the server validates version 3.1 and persists it to MongoDB. Then I go away for a year, and when I come back the client side version is 5.1, and I have formatted my computer so I no longer have the local data, so I go to download it, however the 5.1 model is quite different to version 3.1. The server is not equipped to migrate the data, HOWEVER we know that it was valid when it was entered into the database, so there is no reason why the JSON in the database cant be sent to the client and then it will be auto migrated when its loaded into memory (and then re-saved on the client). Now due to the servers model representing the latest version (5.1) I imagine it would either exception or just fill in what it can and default the rest of the variables in the model. (The client can update the server model so the server model can be updated via the client, incase you were worrying about the data always being out of date.)

So as all queries are against 2 fields which I know will never change (AccountId, PersistedId), I dont see any reason why I couldn’t query MongoDB objects without a strongly typed object to get back the raw BSON Document, then call ToJson() on that BSON document and send back to the client. So is there any way to read data without having to use a strong type? So I can validate the writes and use a strongly typed model there, but on pulling the data out I just want to query the raw BSON?

Hopefully this makes sense even if it is long winded, just wanted to give context to avoid the “why can’t you use a strongly typed model?” etc.

  • 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-16T01:36:54+00:00Added an answer on June 16, 2026 at 1:36 am

    So, you can query using raw BsonDocuments. These are untyped, but can be created using typed models. Maybe this is a compromise?

    var queryDocument = Query<Person>.Eq(p => p.Name, "Jack");
    // { "name" : "Jack" }
    

    Otherwise, if you are intent on having your versions work this way, there is no magical bullet to handle schema migration. It is a problem across all database stacks. We have some documentation written for dealing with it in the serialization tutorial.

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

Sidebar

Related Questions

This will hopefully be a simple one: I have a div I want to
This is hopefully a very simple question, but one a lot of Googling has
This should hopefully be a simple one. When using a date time picker in
New to MVC, so hopefully this will be pretty simple. I have an HTML
Quite a simple one I think, but hopefully someone can help out. I have
Hopefully this is just a quick one and I'm missing something simple... I've got
Hopefully a simple one. I have the following form validation rules: $this->form_validation->set_rules('timeStart', 'Day Start
I'm sure there is something simple that I am missing, but I must confess
Hopefully this is a simple one. I have a table of sent messages and
I'm developing a very simple but (hopefully) solid framework that just fits my needs.

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.