上一篇博客主要介绍了MongoDB和它的的使用场景,这篇文章主要介绍一下如何用C#如何借助官方的Mongodb.Driver操作MongoDB

1.NuGet引入Mongodb.Dirver

Mongodb使用基础-Mongodb.Driver操作MongoDB

安装后项目中会新增如下dll

Mongodb使用基础-Mongodb.Driver操作MongoDB

MongoDB.Driver.dll:顾名思义,驱动程序

MongoDB.Bson.dll:序列化、Json相关

 

2.初始化集合,子类需重写集合名

        #region 构造函数
        /// <summary>
        /// 集合
        /// </summary>
        public string _collName { get; set; }
        public MongoBaseRepository(string collName)
        {
            this._collName = collName;
        }
        #endregion
View Code

相关文章:

  • 2021-12-04
  • 2021-04-17
  • 2021-04-10
  • 2022-02-08
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-28
猜你喜欢
  • 2021-08-16
  • 2021-06-22
  • 2021-10-02
  • 2022-03-07
相关资源
相似解决方案