.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"<