Chapter 4 TestGetsTopTwenty - Format Exception

System.FormatException : Element ‘Count’ does not match any field or property of class M220N.Models.Projections.ReportProjection.

Any one getting this same exception?

Hi @Wei_27563,

Are you still facing the issue?

Kanika

Yeah, still not resolved yet.

Oh, this is actually not for Chapter 3 but for the first ticket of Chapter 4, If possible, please update the topic for me, change “Chapter 3” to “Chapter 4”

The eventual solution for this issue is actually adding BsonElement to the Count property of ReportProjection class, a change I suspected since the very beginning.

public class ReportProjection
{
    [BsonElement("_id")]
    public string Id { get; set; }
    [BsonElement("Count")]
    public int Count { get; set; }
}

@kanikasingla , if possible, please add a video with detailed explanation of the serialization of C# classes, what could be the difference with and without these attributes, thanks.

P.S. I suspect ‘Count’ could also be a special property name which caused all those trouble.

Hi @Wei_27563,

Give me some time, I am looking into this.

Kanika

Thank you so much - this had me stumped. Come on MongoDB, get the framework code for mflix sorted!

You are welcome, Mark, I am glad my post helped other students here.

1 Like