Mongodb的问题~~
/// <summary>
/// 插入新数据
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="collectionName"></param>
/// <param name="entiry"></param>
public static void InsertOne<T>(string collectionName, T entity) where T : class
{
using (Mongo mongo = new Mongo(connectionString))
{
mongo.Connect();
IMongoDatabase friends = mongo.GetDatabase(database);
IMongoCollection<T> categories = friends.GetCollection<T>(collectionName);
categories.Insert(entity, true);
mongo.Disconnect();
}
}
我拷贝了这么一段代码,但是Mongo mongo = new Mongo这块的时候报错,
IMongoDatabase ,IMongoCollection都报错,下面是以下错误。麻烦大家帮我看看
错误 1 未能找到类型或命名空间名称“Mongo”(是否缺少 using 指令或程序集引用?) D:\Demo\MongodbDemo\ConsoleApplication1\ConsoleApplication1\MongoDBHelper.cs 26 20 ConsoleApplication1
错误 3 未能找到类型或命名空间名称“IMongoDatabase”(是否缺少 using 指令或程序集引用?) D:\Demo\MongodbDemo\ConsoleApplication1\ConsoleApplication1\MongoDBHelper.cs 29 17 ConsoleApplication1
错误 4 未能找到类型或命名空间名称“IMongoCollection”(是否缺少 using 指令或程序集引用?) D:\Demo\MongodbDemo\ConsoleApplication1\ConsoleApplication1\MongoDBHelper.cs 30 17 ConsoleApplication1
------解决方案--------------------去下载一个mongo.dll就好了