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 ...
随机推荐
- 2015 Multi-University Training Contest 8 hdu 5384 Danganronpa
Danganronpa Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Tot ...
- ASP.NET-JSON.NET技巧
第一个技巧,字符串转JSON 单条的json数据可以使用JObject.Parse将对象转化成JObject对象,你可以接着使用JsonConvert.SerializeObject方法把这个对象序列 ...
- C#-常用对象-思维导图
C#-常用对象-思维导图 链接:http://pan.baidu.com/s/1jHNgS78 密码:3i74 如有错误,请告知我!
- Android自己定义组件系列【4】——自己定义ViewGroup实现双側滑动
在上一篇文章<Android自己定义组件系列[3]--自己定义ViewGroup实现側滑>中实现了仿Facebook和人人网的側滑效果,这一篇我们将接着上一篇来实现双面滑动的效果. 1.布 ...
- C 语言运算符优先级(记忆口诀)
优先级 运算符 名称或含义 使用形式 结合方向 说明 1 [] 数组下标 数组名[常量表达式] 左到右 () 圆括号 (表达式)/函数名(形參表) . 成员选择(对象) 对象.成员名 -& ...
- JAVA设计模式之【模板方法模式】
模板方法模式 提高代码的复用性 把常用的基本方法放入父类中 强调一种流程步骤 角色 抽象类 抽象方法 具体方法 钩子方法 空方法 通过bool控制 具体类 看例子 1.银行模板类 package Te ...
- Java 定制工具库 —— Print(import static)
创建自己的工具库以减少或消除重复的程序代码.例如,我们在Print类中,对常常用到的System.out.println()封装调用以减少输入负担.这样,我们在使用该类时,可以用一个更具可读性的 im ...
- 5分钟学会 CSS Grid 布局
欢迎加入前端交流群交流知识&&获取视频资料:749539640 这是一篇快速介绍网站未来布局的文章. Grid 布局是网站设计的基础,CSS Grid 是创建网格布局最强大和最简单的工 ...
- CentOS7安装EPEL的两种方式
转自:http://www.mamicode.com/info-detail-1671603.html epel是社区强烈打造的免费开源发行软件包版本库. EPEL,即Extra Packages f ...
- Redis-4-链表结构
Redis-4-链表结构 标签(空格分隔):redis lpush key value 作用: 把值插入到链接头部 rpop key 作用: 返回并删除链表尾元素 lrange key start s ...