CommonUtils/Database/MongoDb.cs

(完整代码) 983B

using MongoDB.Bson;
using MongoDB.Driver;

namespace CommonUtils
{
    //https://mongodb.github.io/mongo-csharp-driver/2.10/getting_started/quick_tour/
    public static class MongoDb
    {
        public static void Test()
        {
            // To directly connect to a single MongoDB server
            // (this will not auto-discover the primary even if it's a member of a replica set)
            //var client = new MongoClient();

            // or use a connection string
            var client = new MongoClient("mongodb://localhost:27017");

            // or, to connect to a replica set, with auto-discovery of the primary, supply a seed list of members
            //var client = new MongoClient("mongodb://localhost:27017,localhost:27018,localhost:27019");

            //Get a Database
            var database = client.GetDatabase("foo");

            //Get a Collection
            var collection = database.GetCollection<BsonDocument>("bar");
        }
    }
}

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。