Write to the second one has to say that I made a small mistake before, in fact, the implementation of the sub-table storage is very simple, first of all I want to achieve what kind of effect it
Is that the user table has a score field, the score field is a child table
Actually realizes this function is also very simple, uses the object-oriented thought to understand very well, the child table is an object field or the collection field of the user table, so I think the development of C # MONGO with the object-oriented thought development more appropriate
Public classUser { PublicObjectId Id {Get;Set; } Public stringName {Get;Set; } Public stringTitle {Get;Set; } PublicChengji Chengji {Get;Set; } PublicList<chengji> chengjis=NewList<chengji>(); }
According to the need to define an object or a collection, when inserting this object, the corresponding field assignment is possible, is not very consistent with the idea of object-oriented?
Chengji Chengji = new Chengji () {yuwen = 56
,shuxue = 23 = new User (); Employee. Name = test1 " ; Employee. Title = title1 " ; Employee. Chengji =chengji; EMPLOYEE.CHENGJIS.ADD (Chengji); // write it in the upper set to collection. Insert (employee);
I wanted to let the user class inherit Bsondocument, did not think that the driver has been designed for us, the operation of the entity object is good
Let Codefrist fly for a while.
C # Development MONGO notes second article