Element 'Id' does not match any field or property of class

element skateboards
element definition biology
element examples
element synonym
element table
element in a sentence
element fleet
element tv

I got the result from the collection in MongoDB, the structure is the same as below

[DataContract]
public class Father
{
    [BsonId]
    [DataMember]
    public MongoDB.Bson.ObjectId _id { get; set; }

    [DataMember]
    public string Id { get; set; }

    [DataMember]
    public List<Child> childs { get; set; }
}

[DataContract]
public class Child
{
    [DataMember]
    public string Id { get; set; }

    [DataMember]
    public int Name { get; set; }
}

When I try this:

List<Father> f = result.ToList();

It calls Element 'Id' does not match any field or property of the class Model.Child

I think it just takes 'Id' as something else.

How can I deal with it? Thank you

I resolved similar issue by adding [BsonIgnoreExtraElements] on top of the class declaration. ObjectId is internally maintained by MongoDB which is not needed at the App level, hence in the class declaration I don't require this field. Hope this would help someone

Element Skateboards (Company), synonyms: component, constituent, part, section, portion, piece, segment, bit, factor, feature, facet, ingredient, strand, detail, point, member, unit, module, item, essential, integrand Element definition is - any of the four substances air, water, fire, and earth formerly believed to compose the physical universe. How to use element in a sentence.

I faced to same problem.Same error occured at var data = query.ToList();

       var collection = db.GetCollection<Product>("Products");

        var query =
            from e in collection.AsQueryable<Product>()
            where e.name == "kalem"
            select e;

        var data = query.ToList();

and my insert was this:

    var collection = db.GetCollection<Product>("Products");

    collection.InsertBatch(products);

I solved as below.

        ObjectId id = new ObjectId();
        var collection = db.GetCollection<Product>("Products");

        collection.InsertBatch(products);
        id = pr.Id;

and I added id to Product class as below Product Class

class Product
{
    public ObjectId Id { get; set; }
    public string name { get; set; }
    public string category { get; set; }
    public double price { get; set; }
    public DateTime enterTime { get; set; }
}

Element, each of more than one hundred substances that cannot be chemically interconverted or broken down into simpler substances and are primary constituents of matter. Each element is distinguished by its atomic number, i.e. the number of protons in the nuclei of its atoms. Element definition, a component or constituent of a whole or one of the parts into which a whole may be resolved by analysis: Bricks and mortar are elements of every masonry wall.

var conventionPack = new ConventionPack { new IgnoreExtraElementsConvention(true) };
        ConventionRegistry.Register("IgnoreExtraElements", conventionPack, type => true);

This works just perfectly! [BsonIgnoreExtraElements] also worked well, but, if you want to add any other ConventionRegistry like CamelCaseElementNameConvention, then, it overrides the Attribute one and the same exception occurs. Not sure if that could also be achieved using some other attribute.

Element, the weather, especially strong winds, heavy rain, and other kinds of bad weather. Element is one of the largest independent providers of destructive and non-destructive testing services for metals and non-metals. We help to make certain these materials are safe, quality, compliant and fit for purpose.

I was using a dynamic list (List) to build a filter and was receiving a similar error. I added these lines to my data class to fix the problem.

[BsonId]
public ObjectId Id { get; set; }

Chemical element, synonyms: the weather, the climate, meteorological conditions, atmospheric conditions/forces, the wind, the rain, storms Define element. element synonyms, element pronunciation, element translation, English dictionary definition of element. n. 1. A fundamental, essential, or irreducible

this work for my case: add label

    [DataMember]
    [BsonElement("songName")]

onto the elements:

[BsonIgnoreExtraElements]
public class Music
{

    [BsonId]
    [DataMember]
    public MongoDB.Bson.ObjectId _id { get; set; }
    [DataMember]
    public string Id { get; set; }

    [DataMember]
    [BsonElement("songName")]
    public string SongName { get; set; }

    [DataMember]
    [BsonElement("artistName")]
    public string ArtistName { get; set; }}

Element, a part in an electric teapot, heater, or stove that contains a wire through which an electric current is passed to provide heat. At Element Fleet Management, we provide world-class fleet management services that enable companies with fleet cars and light-duty vehicles, commercial truck fleets and equipment fleets to achieve an advantage today and confidently conquer tomorrow. We offer a suite of fleet management solutions that span the total fleet lifecycle, from

Materials and Product Testing, Inspection & Certification, Kids Definition of element. 1 : any of more than 100 substances that cannot by ordinary chemical means be separated  Discover our Skateboard Decks Collection. Get inspired with our latest Skateboarding Tips and Tricks. Shop Online at the Official Element Store

element, In chemistry, an element is a pure substance which cannot be broken down by chemical means, consisting of atoms which have identical numbers of protons in​  The Chairman of the board in Element ASA Mr. Thomas Christensen, has today purchased 1 000 000 shares in Element (ELE) at an average price of 3.9200 per share. After today’s share purchase, Thomas Christensen and companies that Mr. Christensen controls owns a total of 1 400 000 shares, which represents 7.46% of the company’s issued shares.

Element, Element may refer to: Contents. 1 Business; 2 Entertainment. 2.1 Music; 2.2 Other entertainment. 3 Mathematics; 4 Philosophy and religion; 5 Science  If you are a partner supplier for Element Fleet, find links to the portal and contact form.

Comments
  • Can you give a more complete listing of the code that is causing this exception? For instance, what is results? Also, can you show us what the documents look like in the database (preferably in json format).
  • I solved this problem by add a _id in the sub class as I did in the main class. I guess, all the ducument needs an 'id'.And if I don't define one , the system will think there is a '_id' in the class. That makes me couldn't transfer the document to List<class>.
  • Check out the serialization options mongodb.org/display/DOCS/CSharp+Driver+Serialization+Tutorial - you can mark whatever property to be the id, it doesn't have to be '_id' for example
  • May be related to this - stackoverflow.com/questions/23448634/… .
  • Nice. It worked for me.
  • You don't need to use inheritance. I have also come across this problem. I don't know what it is yet, but I don't think it inheritance will solve it. I similar, working code, elsewhere.
  • This got me closer: stackoverflow.com/questions/13859295/…. I eventually renamed my field to something containing more than just id or _id, both in the pocp and mongo projection. That did the trick
  • This actually does not work - The ObjectId.Parse(value) always returns 0's to the _id field. Better to just store this as a string IMHO