csharp mongo客户端版本2 beta的示例问题

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了csharp mongo客户端版本2 beta的示例问题相关的知识,希望对你有一定的参考价值。

 class Program
    {
        static void Main(string[] args)
        {
            Run().Wait();
        }

        private static async Task Run()
        {
            var client = new MongoClient("mongodb://localhost:27016");
            try
            {

                var database = client.GetDatabase("testv2");

                var customers = database.GetCollection<Customer>("customer");
                
                var nextId = 563627090084241408;
                var nextId2 = 563627090084241409;

                customers.InsertOneAsync(new Customer { Name = "Dave", Id = nextId }).Wait();
                customers.InsertOneAsync(new Customer { Name = "Steve", Id = nextId2 }).Wait();

                var list = await customers.Find(x => x.Name == "Jill")
                    .ToListAsync();

                foreach (var person in list)
                {
                    Console.WriteLine(person.Name);
                }
            }
            catch (Exception)
            {

                throw;
            }
        }
    }

    public class Customer
    {
        public long Id { get; set; }
        public string Name { get; set; }
    }
  

以上是关于csharp mongo客户端版本2 beta的示例问题的主要内容,如果未能解决你的问题,请参考以下文章

mongo-cxx-driver-legacy-1.1.2 SCRAM-SHA-1身份验证错误

npm install 不在 GitHub 上安装最新版本

csharp C#_mongo_datetime_attributing.cs

csharp Beta 19

csharp Beta 19

csharp 使用带有Unity 5.6 beta的新VideoPlayer组件播放视频。