dotnet core链接mongodb代码实例
作者:mlh1421 时间:2023-07-20 14:26:09
这篇文章主要介绍了dotnet core链接mongodb代码实例,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
导入命名空间
using MongoDB.Bson;
using MongoDB.Driver;
测试示例:
var client = new MongoClient("mongodb://127.0.0.1:27017");
var database = client.GetDatabase("foo");
var collection = database.GetCollection<object>("app");
var document = new
{
name="添加到mongodb"
};
var a= collection.AsQueryable<object>();//查询
Console.WriteLine(a.Count());
collection.InsertOne(document);//添加一条数据
来源:https://www.cnblogs.com/mlh1421/p/11913061.html
标签:dotnet,core,链接,mongodb
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Android中创建对话框(确定取消对话框、单选对话框、多选对话框)实例代码
2023-07-04 01:48:25
![](https://img.aspxhome.com/file/2023/4/137494_0s.gif)
教你怎么用idea创建web项目
2021-12-23 14:45:16
![](https://img.aspxhome.com/file/2023/6/110606_0s.png)
C# Websocket连接实现wss协议
2022-09-02 08:20:41
java信号量控制线程打印顺序的示例分享
2023-05-09 12:27:38
如何基于SpringBoot实现人脸识别功能
2022-04-19 13:23:21
Android开发自学笔记(一):Hello,world!
2023-09-12 14:48:50
![](https://img.aspxhome.com/file/2023/1/123341_0s.png)
Hadoop+HBase+ZooKeeper分布式集群环境搭建步骤
2022-02-13 01:16:33
Java中五种不同方法的创建对象
2021-07-25 01:11:37
读取spring配置文件的方法(spring读取资源文件)
2022-10-08 11:24:21
基于selenium-java封装chrome、firefox、phantomjs实现爬虫
2022-04-07 19:04:28
C++实现俄罗斯方块源码
2023-06-27 23:49:14
![](https://img.aspxhome.com/file/2023/6/103096_0s.png)
OpenCV图像旋转Rotate的详细介绍
2023-07-01 08:22:27
![](https://img.aspxhome.com/file/2023/2/95522_0s.jpg)
mac系统下载、安装、使用Java8教程
2023-07-06 04:54:38
![](https://img.aspxhome.com/file/2023/6/138836_0s.jpg)
springboot vue完成发送接口请求显示响应头信息
2023-06-05 02:45:34
![](https://img.aspxhome.com/file/2023/9/108189_0s.gif)
Java中的javaBean、vo、entity、domain和pojo
2023-03-30 21:41:20
![](https://img.aspxhome.com/file/2023/5/61605_0s.png)
Java中一个线程执行死循环有什么后果
2022-05-24 00:28:35
Unity的IPostprocessBuild实用案例深入解析
2023-05-29 05:54:49
使用Thumbnails实现图片指定大小压缩
2021-11-14 11:07:34
![](https://img.aspxhome.com/file/2023/7/138267_0s.jpg)
Android item长按删除功能
2022-11-13 03:45:24
Android之ImageSwitcher的实例详解
2022-06-08 06:03:14
![](https://img.aspxhome.com/file/2023/9/137689_0s.png)