.net core3.1中使用 **MongoDB.Driver** 实现基础的增删改查操作(含分页)

本文详细介绍了在.NET Core 3.1环境中,利用MongoDB.Driver库进行基本的创建(Create)、读取(Retrieve)、更新(Update)、删除(Delete)操作,同时还涵盖了分页查询的实现方法。
摘要由CSDN通过智能技术生成

.net core3.1中使用 MongoDB.Driver 实现基础的增删改查操作(含分页)。

模型

public class Person
{
   
    public ObjectId Id {
    get; set; }
    //[BsonDateTimeOptions(Kind = DateTimeKind.Local)]
    public DateTime Created {
    get; set; }
    public string Title {
    get; set; }
    public string Description {
    get; set; }
    public string JumpUrl {
    get; set; }
    public int ReadingNum {
    get; set; }
    public PersonType Type {
    get; set; }
}
public enum PersonType
{
   
    类型1 = 1,
    类型2 = 2,
}

增删改查操作

MongoDB操作链接及相关字段:

 private static readonly MongoClient client = new MongoClient("mongodb://admin:222222@127.0.0.1:27017"<
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值