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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:03:34+00:00 2026-05-27T05:03:34+00:00

Been trying to fetch documents from a collection, and the documents contains nested documents.

  • 0

Been trying to fetch documents from a collection, and the documents contains nested documents.

Getting an error message saying “Expected a nested document representing the serialized form of a Project.Models.MapTags value, but found a value of String instead”

Here is the code

This is the Method getting the collection and does the query.

public List<Maps> GetAllMapsByUserId(ObjectId userId)        
                  {            
                      using (_server.RequestStart(_db))            
                      {                
                          var query = Query.EQ("UserId", userId);
                          MongoCursor<Maps> maps = _db.GetCollection<Maps>"Maps").FindAs<Maps>(query);
                          var list = maps.ToList();

                          return list;            
                      }
                  }

This is the class which contains the object

namespace Project.Models 
{    

public class Maps    {        

    [BsonId]        
    public ObjectId Id { get; set; }
    public ObjectId UserId { get; set; }
    public string MapName { get; set; }
    public string Description { get; set; }
    public BsonBoolean PublicMap { get; set; }
    public DateTime Created { get; set; }

    [BsonIgnoreIfNull]
    public List<MapTags> Tags { get; set; }

    [BsonIgnoreIfNull]
    public List<MapVotes> Votes { get; set; }

    }

public class MapVotes
{
    public ObjectId VoterId { get; set; }
    public int VoteValue { get; set; }
}

public class MapTags
{
    public string Tag { get; set; }
}

}

Hope that someone has an idea/tip or similar, been searching and testing for a long time and haven’t found a solution.

Update :

Here is an example of data in the database

  { 
    "_id" : ObjectId("4eda2415851e702684bf6392"), 
    "MapName" : "Test", 
    "Description" : "Test", 
    "Created" : ISODate("2011-12-03T13:28:53.698Z"), 
    "PublicMap" : false,
    "UserId" : ObjectId("4e8033a0851e701c7c1e12e1"), 
    "Tags" : [ "Test", "Kalle", "Jonas", "Fredrik" ] 
  }
  • 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-05-27T05:03:35+00:00Added an answer on May 27, 2026 at 5:03 am

    It looks like the serializer expects a document, but finds a string.

    The problem is that you have serialized an array of strings:

    {
       "MapName" : "SomeMapName"
       "Tags" : ["tag1", "tag2"] // list of strings
       // ...
    }
    

    but you should have

    {
       "MapName" : "SomeMapName"
       "Tags" : [ { /* map tag document */ }, { /* map tag document */ }, ...]
       // ...
    }
    

    The deserializer expects to find a document, but finds only a string. Now it’s possible that the MapTag class can be essentially serialized using a string and can be reconstructed from a string, but you have to provide a custom serializer for that. It’s pretty straightforward.

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

Sidebar

Related Questions

I'm getting terribly slow results from the following code. I've been trying to troubleshoot
Ive been trying to display formatted content blocks from a xml file with no
We've been trying to alter a lot of columns from nullable to not nullable,
I have been trying to fetch facebook like count of any web url. for
I've been trying to figure out the best way to return an order from
I've been trying to present my data from my database using PHP. My while
So I've been trying to fetch a web page that uses authentication to a
ive been trying to make a form with drop downs which are populated from
I have been trying to display image from database using php but i am
I have been trying to add data from my ajax query that returns json

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.