mongodb c# 基本操作

点击量:40

MongoDB.Driver.IMongoClient

ICluster Cluster{get;}  //获取集群
MongoClientSettings Settings{get;} 
void DropDatabase();                        //删除数据库
IMongoDatabase GetDatabase();               //获取一个数据库
IAsyncCursor<BsonDocument> ListDatabases();   //返回所有的数据库

IMongoClient WriteReadConcern();
IMongoClient WriteReadPreference();
IMongoClient WithWriteConcern();

MongoDb.Driver.MongoClient

MongoDb.Driver.IMongoDatabase

IMongoDatabase db = client.GetDatabase("shop");

void CreateCollection();
void CreateView();
void DropCollection();
IMongoCollection<TDocument> GetCollection();
IAsyncCursor<BsonDocument> ListCollections();
void RenameCollection();
TResult RunCommand();

IMongoDatabase WriteReadConcern(ReadConcern);
IMongoDatabase WithReadPreference(ReadPreference);
IMongoDatabase WithWriteConcern(WriteConcern);

internal sealed class MongoDB.Driver.MongoDatabaseImpl

MongoDB.Driver.IMongoCollection

CollectionNamespace CollectionNamespace{get;}
IMongoDatabase Database{get;}
IBsonSerializer<TDocument> DocumentSerializer{get;}
IMongoIndexManager<TDocument> Indexes{get;}
MongoCollectionSettings Settings{get;}

IAsyncCursor<TResult> Aggregate<TResult>(); // 执行聚合的管道
BulkWriteResult<TDocument> BulkWrite();     // 执行多条插入
long Count();                               // 返回collection的数量

DeleteResult DeleteMany();                  // 删除多个document      
DeleteResult DeleteOne();                   // 删除单条

IAsyncCursor<TField> Distinct();
IAsyncCursor<TProjection> FindSync();
TProjection FindOneAndDelete<TProjection>();
TProjection FindOneAndReplace<TProjection>();
TProjection FindOneAndUpdate<TProjection>();

void InsertOne();
void InsertMany();
IAsyncCursor MapReduce();
IFilteredMongoCollection<TDerivedCouemnt> OfType<TDerivedDocument>();
ReplaceOneResult ReplaceOne();
UpdateResult UpdateMany();
UpdateResult UpdateOne();

IMongoCollection<TDocument> WithReadConcern(ReadConcern);       // 返回一个读相关设置不同的instance
IMongoCollection<TDocument> WithReadPreference(ReadPreference); // 返回一个写偏爱设置不同的instance
IMongoCollection<TDocument> WithWriteConcern(WriteConcern);     // 返回一个写相关设置不同的instance

MongoDB.Driver.IMongoCollectionExtensions

发表评论

电子邮件地址不会被公开。

12 + 4 =