当前位置: 首页>>代码示例>>C#>>正文


C# MongoCollection.InsertBatch方法代码示例

本文整理汇总了C#中MongoCollection.InsertBatch方法的典型用法代码示例。如果您正苦于以下问题:C# MongoCollection.InsertBatch方法的具体用法?C# MongoCollection.InsertBatch怎么用?C# MongoCollection.InsertBatch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MongoCollection的用法示例。


在下文中一共展示了MongoCollection.InsertBatch方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Create

 private static void Create(MongoCollection<Log> logs)
 {
     logs.InsertBatch(CreateSampleLogs(10));
     logs.Insert(new Log("Some logs added", DateTime.Now));
     Console.WriteLine("CREATE");
     logs.FindAll().Print();
 }
开发者ID:MarKamenov,项目名称:TelerikAcademy,代码行数:7,代码来源:MongoCRUD.cs

示例2: CreateAndInsertMultipleDocumentIntoCollection

        /// <summary>
        /// Demo inserting multiple document into collection.
        /// </summary>
        /// <param name="orders">The orders.</param>
        private static void CreateAndInsertMultipleDocumentIntoCollection(MongoCollection<Order> orders)
        {
            Console.WriteLine("\n\n======= Insert Multiple Documents =======");
            Console.WriteLine(string.Format("Document Count Before Insert: [ {0} ]", orders.Count()));

            // Create new orders.
            var order1 = new Order
                         	{
                         			OrderAmount = 100.23,
                         			CustomerName = "Bugs Bunny"
                         	};
            var order2 = new Order
                         	{
                         			OrderAmount = 0.01,
                         			CustomerName = "Daffy Duck"
                         	};

            IEnumerable<Order> orderList = new List<Order> { order1, order2 };

            // Insert an IEnumerable.
            orders.InsertBatch(orderList);

            Console.WriteLine(string.Format("Inserted: {0}", order1));
            Console.WriteLine(string.Format("Inserted: {0}", order2));

            Console.WriteLine(string.Format("Document Count After Insert: [ {0} ]", orders.Count()));
        }
开发者ID:ChrisEdwards,项目名称:IntroducingMongoDB,代码行数:31,代码来源:Program.cs

示例3: GenerateDefaultJobs

 private static void GenerateDefaultJobs(MongoCollection jobsCollection)
 {
     jobsCollection.InsertBatch(new List<Job>
                                    {
                                        new Job {Name = "Commons Coordinator"},
                                        new Job {Name = "Sound & Light"},
                                        new Job {Name = "Greeters"},
                                        new Job {Name = "YRE Family Greeter"}
                                    });
 }
开发者ID:MatthewNichols,项目名称:MongoDb,代码行数:10,代码来源:Volunteers.cs

示例4: Seed

        private static void Seed(MongoCollection<Message> collection, MongoCollection<User> users)
        {
            collection.InsertBatch(new List<Message>
            {
                new Message
                {
                    Text = "chatim chatim",
                    Time = DateTime.Now,
                    UserName = "Pesho"
                },
                new Message
                {
                    Text = "Mnogo chatim",
                    Time = DateTime.Now,
                    UserName = "Gosho"
                },
                new Message
                {
                    Text = "S pesho chatim",
                    Time = DateTime.Now,
                    UserName = "Pesho"
                }
            });

            users.InsertBatch(new List<User>
            {
                new User
                {
                    Username = "Pesho"
                },
                new User
                {
                    Username = "Gosho"
                }
            });
        }
开发者ID:yavor2000,项目名称:All-HomeWorks-SoftwareUniversity-TelerikAcademy,代码行数:36,代码来源:Program.cs

示例5: SeedData

        private void SeedData(MongoDatabase db)
        {
            if (db == null) throw new ArgumentNullException("db");

            // Reset db
            db.GetCollection("IDSequence").Drop();

            _usersCol = db.GetCollection<MembershipAccount>(MembershipAccount.GetCollectionName());
            _usersCol.Drop();

            var salt = Crypto.GenerateSalt();

            var user1 = new MembershipAccount("User1")
                            {
                                PasswordSalt =  salt,
                                Password = Crypto.HashPassword("[email protected]" + salt),
                                IsConfirmed = false
                            };

            var user2 = new MembershipAccount("NonLocalUser")
                            {
                                IsLocalAccount = false,
                                IsConfirmed = true
                            };

            _usersCol.InsertBatch(new[] { user1, user2 });

            var oAuthTokenCol = db.GetCollection<OAuthToken>(OAuthToken.GetCollectionName());
            oAuthTokenCol.Drop();
            oAuthTokenCol.Insert(new OAuthToken("Tok3n", "tok3nSecret"));

            var oAuthMembershipCol = db.GetCollection<OAuthMembership>(OAuthMembership.GetCollectionName());
            oAuthMembershipCol.Drop();
            oAuthMembershipCol.Insert( new OAuthMembership("Test", "[email protected]", 1) );

            Users = _usersCol.AsQueryable();
            OAuthTokens = oAuthTokenCol.AsQueryable();
            OAuthMemberships = oAuthMembershipCol.AsQueryable();
        }
开发者ID:dotfo,项目名称:MongoSimpleMembership,代码行数:39,代码来源:MembershipProviderTestFixture.cs

示例6: ListProcessor

 private static async void ListProcessor(List<Site> sites, int taskID, int totalTasks, MongoCollection<Site> mongoCollection)
 {
     Console.WriteLine("Running Task {0} of {1}", taskID, totalTasks);
     var tasks = sites.Select(site => ProcessSite(site, taskID)).ToList();
     await Task.WhenAll(tasks);
     mongoCollection.InsertBatch(tasks.Select(t => t.Result).ToList());
     foreach (var task in tasks)
     {
         task.Result.Dispose();
         task.Dispose();
     }
 }
开发者ID:JamieH,项目名称:Lexa,代码行数:12,代码来源:Program.cs


注:本文中的MongoCollection.InsertBatch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。