Traditional relational databases are generally composed of three levels of databases (database), tables (table), records (record), and MongoDB are made up of three levels (db), Collections (collection), document objects (documents). MongoDB for tables in relational databases, but there is no column, row, and relationship concept in the collection, which embodies the characteristics of pattern freedom.
one, about the MongoDB drive
MongoDB supports multiple language drivers, here we only introduce C # drivers. There are many types of C # drivers, each with roughly the same form, but the details are different, so the code is not universal. The more commonly used is the official drive and the Samus drive. The Samus driver supports LINQ manipulation of data in addition to general forms of operation. Everyone prefers this way.
Official Driver Download Address: Click to download
Samus Driver Download Address: Click to download
This article will start from Samus drive to explain the database access, international practice, Access "Hello world!".
Second, through Samus Drive to realize HelloWorld access
Before doing the following, please make sure the MongoDB service is turned on, do not know how to open the service, please see article. Download the driver, create a new console item, and add a reference to the MongoDB.dll, if you download the driver source code, compile it again to refer to the generated DLL.
The basic code is as follows:Copy Code code as follows:
Run the program to successfully print Helloword. At the same time, we opened the Data folder, found more than two files "Mydatabase.ns" and "mydatabase.0."
Code Download: Http://xiazai.jb51.net/201307/yuanma/MongoDB_001.rar
This concise explanation of the basic access operation, the next article will be combined with the MVC framework through the MONGODB to achieve the model layer of a single set of basic additions and deletions to check the operation.
Author: Lee (Lipan)
Source: [Lipan] (http://www.cnblogs.com/lipan/)