Connect to MongoDB
https://docs.mongodb.com/getting-started/csharp/client/
MongoDB C# Driver is the officially supported C# driver for MongoDB.
Procedure
Download the MongoDB C# Driver.
To download the C# driver, follow the instructions found on MongoDB C#/.NET Driver page.
Add Reference to C# Driver DLLs.
Add to your project references to the following DLLs:
- MongoDB.Bson.dll
- MongoDB.Driver.dll
- MongoDB.Driver.Core.dll
Connect to MongoDB.
Use MongoClient to connect to a running mongod instance.
Add the following using statements in your C# program.
using MongoDB.Bson;
using MongoDB.Driver;
Include the following code in your program to create a client connection to a running mongod instance and use the test database.
protected static IMongoClient _client;
protected static IMongoDatabase _database; _client = new MongoClient();
_database = _client.GetDatabase("test");
To specify a different host and port for the mongod instance, see the MongoClient API page.
ps:
上面的第一步和第二步,可以直接通过NuGet来添加
Connect to MongoDB的更多相关文章
- 用navicat进行身份验证连接出现cannot connect to Mongodb authentication failed
用navicat进行身份验证连接出现cannot connect to Mongodb authentication failed. 解决办法: 1.打开mongoDB连接 win+r --cmd-- ...
- MongoDB学习系列(2)--使用PHP访问MongoDB
第一部分:介绍 在Windows上安装最新MongoDB步骤非常的简单,这里不做介绍.但是如果你安装的时候没有将MongoDB作为服务运行,每次你都要使用cmd切换到指定的目录下,然后在cmd中启动M ...
- nodejs连接mongodb的方法
一. var express = require('express'); var mongodb = require('mongodb'); var app = express(); app.use( ...
- MySQL vs. MongoDB: Choosing a Data Management Solution
原文地址:http://www.javacodegeeks.com/2015/07/mysql-vs-mongodb.html 1. Introduction It would be fair to ...
- Python迁移MySQL数据到MongoDB脚本
MongoDB是一个文档数据库,在存储小文件方面存在天然优势.随着业务求的变化,需要将线上MySQL数据库中的行记录,导入到MongoDB中文档记录. 一.场景:线上MySQL数据库某表迁移到Mong ...
- Codeigniter MongoDB类库
安装方法:1.将mongodb.php 放到config目录2.将Mongo_db.php放到library目录 使用方法: $this->mongo_db->where_gte('age ...
- Java和MongoDB之Hello World
1.新建Project 新建Java Project,并把mongo-java-driver驱动加入到项目bulid path中,如果你使用的是maven增加依赖. <dependency> ...
- php 操作mongodb
在这里首先说一下mongo 客户端安装完成有时会启动失败 这里解决办法就是 删除 D:\mongodb\db 下的 mongod.lock文件即可 再重新启动 首先下载mongodb php扩 ...
- Java + MongoDB Hello World Example--转载
原文地址:http://www.mkyong.com/mongodb/java-mongodb-hello-world-example/ A simple Java + MongoDB hello w ...
随机推荐
- 【转载】linux下的usb抓包方法
1 linux下的usb抓包方法 1.配置内核使能usb monitor: make menuconfig Device Drivers --> ...
- AIX查看某个端口被哪个进程占用
AIX查看某个端口被哪个进程占用 学习了:https://zhidao.baidu.com/question/1928716757722021467.html 1. netstat -Aan|grep ...
- PyQt: LineEdit的智能输入提示
使用的的类是QtGui.QCompleter from PyQt4 import QtGui,QtCore str = QtCore.QStringList(['a','air','airbus']) ...
- 关于 折半查找 while 条件 < , <=
int bin_search(int a[],int len,int key) { int low=0; int high=len-1; while(low<=high) //若为low< ...
- windows+ubuntu双系统,在windows中访问ubuntu文件
今天被告知ubuntu磁盘空间不足,百度得知可以通过autoremove命令清理,然而,,再也进不去ubuntu系统了,具体表现为第一次选择ubuntu之后一直是空白紫屏,如果强制关机再开机后选择ub ...
- 大家都能看懂的 canvas基础教程
原文链接: http://www.shitu91.com/cms/canvasSub/index.html 01.canvas简单的认识 canvas 是html5提供给我们的一个绘图标签 默认大小 ...
- BZOJ 3626 离线+树链剖分+线段树
思路: 抄一波yousiki的- 显然,暴力求解的复杂度是无法承受的. 考虑这样的一种暴力,我们把 z 到根上的点全部打标记,对于 l 到 r 之间的点,向上搜索到第一个有标记的点求出它的深度统计答案 ...
- js闭包的用途详解
js闭包可以用在许多地方.它的最大用处有两个,一个是前面提到的可以读取函数内部的变量,另一个就是让这些变量的值始终保持在内存中 我们来看看闭包的用途.事实上,通过使用闭包,我们可以做很多事情.比如模拟 ...
- hiho 1613 - 墨水滴 - bfs+优先队列 *
题目链接 小Ho有一张白纸,上面有NxN个格子.小Ho可以选择一个格子(X, Y),在上面滴一滴墨水.如果这滴墨水的颜色深度是G,那么这个格子也会被染成深度为G的格子.同时周围的格子也会被这滴墨水浸染 ...
- Golang 中的 面向对象: 方法, 类, 方法继承, 接口, 多态的简单描述与实现
前言: Golang 相似与C语言, 基础语法与C基本一致,除了广受争议的 左花括号 必须与代码同行的问题, 别的基本差不多; 学会了C, 基本上万变不离其宗, 现在的高级语言身上都能看到C的影子; ...