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