Mongdb. NET tool Library Mongorepository easy to use

Source: Internet
Author: User

Mongdb. NET tool Library Mongorepository easy to use

Recently studied the MongoDB database, and used an open source in the. NET environment of a class library, MONGO warehouse. Some simple operations for data are very useful, especially for later reference.

The specific use process is as follows:

first, the new project, in get the library on Nuget.

Second, set the database address in the configuration file

third, new data entity, and inherit Entity, defining the required fields

Four, pay attention to the use of several common field properties

[Bsonelement ("ReName")] the name of the field used to rename the database.

[Bsonignore] This property is used to ignore the field and not be generated in the database.

[Bsonignoreifnull] This property is typically used on collection objects and ignores fields when the collection is empty, not generated in the database.

[CollectionName ("CollectionName")] The secondary attribute is used to name the table name, and the table name of the database is not the entity name.

[Bsonknowtypes (typeof (Class))] This property is used to define a known type

Five, Data interactive operation

1. Instance entity Object

2. Add data based on entity

or:

3. Update data based on ID

4,Delete the data, according to the specified conditions to delete,

5, access to data, access to data can be obtained according to conditions, or to obtain all the data, and return a variety of forms.

So far, basic data additions and deletions have been completed, GitHub address: https://github.com/RobThree/MongoRepository

The shortcomings also look at the same.

Mongdb. NET tool Library Mongorepository easy to use

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.