上一篇博客主要介绍了MongoDB和它的的使用场景,这篇文章主要介绍一下如何用C#如何借助官方的Mongodb.Driver操作MongoDB
1.NuGet引入Mongodb.Dirver
安装后项目中会新增如下dll
MongoDB.Driver.dll:顾名思义,驱动程序
MongoDB.Bson.dll:序列化、Json相关
2.初始化集合,子类需重写集合名
#region 构造函数 /// <summary> /// 集合 /// </summary> public string _collName { get; set; } public MongoBaseRepository(string collName) { this._collName = collName; } #endregion