C # Development MONGO notes second article

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.