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


C# IDocumentStore.BulkInsert方法代码示例

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


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

示例1: bulk_inserts

        public void bulk_inserts(IDocumentStore store, Target[] documents)
        {
            store.BulkInsert(documents, BulkInsertMode.IgnoreDuplicates);

            // or

            store.BulkInsert(documents, BulkInsertMode.OverwriteExisting);
        }
开发者ID:JasperFx,项目名称:marten,代码行数:8,代码来源:OnePointOneNotes.cs

示例2: CreateInitialData

        public static void CreateInitialData(IDocumentStore store, string databaseName)
        {
            store.DatabaseCommands.GlobalAdmin.EnsureDatabaseExists(databaseName);
            using (var bulkInsert = store.BulkInsert())
            {
                foreach (var category in DataFactory.Categories.GenerateMany(Constants.NumOfCategories))
                    bulkInsert.Store(category);

                foreach (var company in DataFactory.Companies.GenerateMany(Constants.NumOfCompanies))
                    bulkInsert.Store(company);

                foreach (var employee in DataFactory.Employees.GenerateMany(Constants.NumOfEmployees))
                    bulkInsert.Store(employee);

                foreach (var order in DataFactory.Orders.GenerateMany(Constants.NumOfOrders))
                    bulkInsert.Store(order);

                foreach (var product in DataFactory.Products.GenerateMany(Constants.NumOfProducts))
                    bulkInsert.Store(product);

                foreach (var region in DataFactory.Regions.GenerateMany(Constants.NumOfRegions))
                    bulkInsert.Store(region);

                foreach (var shipper in DataFactory.Shippers.GenerateMany(Constants.NumOfShippers))
                    bulkInsert.Store(shipper);

                foreach (var supplier in DataFactory.Suppliers.GenerateMany(Constants.NumOfSuppliers))
                    bulkInsert.Store(supplier);
            }

            new OrdersByCompany().Execute(store);
            new OrdersTotals().Execute(store);
            new ProductSales().Execute(store);
            new OrderLines_ByProduct().Execute(store);
        }
开发者ID:myarichuk,项目名称:Chaos.Raven,代码行数:35,代码来源:Utils.cs

示例3: Create

        public static void Create(IDocumentStore store)
        {
            Logger.Write("Creating models...");
            using (var session = store.OpenSession())
            {
                var dataSourceId = "DataSources/1";

                var query = session
                    .Query<Record>("Records/ByData")
                    .Where(x => x.DataSourceId == dataSourceId);
                var results = session.Advanced.Stream(query);
                using (var bulkInsert = store.BulkInsert())
                {
                    while (results.MoveNext())
                    {
                        try
                        {
                            var current = results.Current;
                            var record = current.Document;
                            var transform = Transform(record);
                            if (transform != null)
                                bulkInsert.Store(transform);
                        }
                        catch (EndOfStreamException)
                        {
                            Logger.WriteLine("EndOfStream");
                        }
                    }
                }
            }

            Logger.WriteLine("Done!");
        }
开发者ID:JuanjoFuchs,项目名称:Log-Indexer,代码行数:33,代码来源:Models.cs

示例4: CreateNotifications

        public void CreateNotifications(IDocumentStore store)
        {
            var notificationFactory = AutoPoco.AutoPocoContainer.Configure(x =>
            {
                x.Conventions(c => c.UseDefaultConventions());
                x.Include<Notification>()
                    .Setup(n => n.Body).Use<RandomStringSource>(30,500)
                    .Setup(n => n.From).Use<EmailRecipientSource>(store)
                    .Setup(n => n.Id).Use<RandomStringSource>()
                    .Setup(n=>n.NotificationRecipients).Use<NotificationRecipientsSource>(store)
                    .Setup(n=>n.Read).Use<BoolSource>()
                    .Setup(n=>n.SendDate).Use<DateSource>(DateTime.Now.AddMonths(-6),DateTime.Now.AddMonths(2))
                    .Setup(n=>n.Sent).Use<BoolSource>()
                    .Setup(n=>n.Title).Use<RandomStringSource>(30,100)
                    ;

            });

            var pocoSession = notificationFactory.CreateSession();
            var notifications = pocoSession.List<Notification>(5).Get();
            

            using (var bulkInsert = store.BulkInsert())
            {
                foreach (var notification in notifications)
                {
                    bulkInsert.Store(notification);
                }
            }

        }
开发者ID:andyevans2000,项目名称:Illuminate,代码行数:31,代码来源:NotificationGenerator.cs

示例5: CreateBulk

 private static void CreateBulk(IDocumentStore store)
 {
     using (var bulkInsert = store.BulkInsert())
     {
         for (var i = 0; i < 2000; i++)
         {
             bulkInsert.Store(new Test {Id = "" + i});
         }
     }
 }
开发者ID:j2jensen,项目名称:ravendb,代码行数:10,代码来源:BulkInsert.cs

示例6: AddDocuments

 private IEnumerable<User> AddDocuments(IDocumentStore store, int docCount = 5000)
 {
     using (var bulkInsert = store.BulkInsert(options:new BulkInsertOptions {BatchSize = 16}))
     {
         for (int i = 0; i < docCount; i++)
         {
             var user = new User
             {
                 Name = "John Doe " + Guid.NewGuid()
             };
             bulkInsert.Store(user);
             yield return user;
         }
     }
 }
开发者ID:IdanHaim,项目名称:ravendb,代码行数:15,代码来源:RavenDB-4379.cs

示例7: DoAction

        protected override bool DoAction(IDocumentStore store)
        {
            var lotsOfOrders = DataFactory.Orders.GenerateMany(Constants.SmallBatchSize).ToList();
            using (var bulkInsert = store.BulkInsert())
                lotsOfOrders.ForEach(order => bulkInsert.Store(order));

            WaitForIndexing(store);

            using (var session = store.OpenSession())
            using (var stream = session.Advanced.Stream(session.Query<Order>("Orders/Totals")))
            {
                do
                {
                    if (!lotsOfOrders.Any(x => x.Id == stream.Current.Key))
                        return false;
                } while (stream.MoveNext());
            }

            return true;
        }
开发者ID:myarichuk,项目名称:Chaos.Raven,代码行数:20,代码来源:VerifyBulkInsertDocs.cs

示例8: TestFixtureSetUp

        public void TestFixtureSetUp()
        {
            _store = NewDocumentStore();

            var players = DataGenerator.CreatePlayerList();

            using (var bulkInsert = _store.BulkInsert())
            {
                foreach (var player in players)
                {
                    bulkInsert.Store(player);
                }
            }

            // nasty: we have to initialize the dynamic index
            using (var session = _store.OpenSession())
            {
                session.Query<Player>().Any();
            }

            WaitForIndexing(_store);
        }
开发者ID:Zuehlke,项目名称:ravendb-workshop,代码行数:22,代码来源:E02-QueryAutoIndexWithPaging.cs

示例9: IndexFile

        private static void IndexFile(IDocumentStore store, DataSource dataSource)
        {
            var lastLineNumber = 0;

            Logger.WriteLine($"Looking for files in '{dataSource.Path}'...");

            var file = Directory
                .GetFiles(dataSource.Path)
                .FirstOrDefault(x => Path.GetFileName(x) == dataSource.File);
            if (file == null)
                return;

            using (var stream = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
            using (var reader = new StreamReader(stream))
                try
                {
                    using (var bulkInsert = store.BulkInsert())
                    {
                        Logger.Write($"Processing '{file}'");
                        var index = 0;
                        string line;
                        while ((line = reader.ReadLine()) != null)
                        {
                            index++;
                            if (index > lastLineNumber)
                            {
                                bulkInsert.Store(new Record {Data = line, DataSourceId = dataSource.Id});
                                Logger.Write(".");
                            }
                        }
                    }

                    Logger.Write("Done!");
                }
                catch (EndOfStreamException)
                {
                    Logger.WriteLine("Reached end of file");
                }
        }
开发者ID:JuanjoFuchs,项目名称:Log-Indexer,代码行数:39,代码来源:Logs.cs

示例10: TestFixtureSetUp

        public void TestFixtureSetUp()
        {
            _store = NewDocumentStore();

            IndexCreation.CreateIndexes(typeof(Player_Index_R03).Assembly, _store);

            var playerDictionary = DataGenerator.CreatePlayerList().ToDictionary(p => p.Id);
            var teamDictionary = DataGenerator.CreateTeamList().ToDictionary(p => p.Id);
            var employmentList = DataGenerator.CreateEmploymentList();

            foreach (var employment in employmentList)
            {
                var team = teamDictionary[employment.TeamId];
                employment.TeamName = team.Name;
                playerDictionary[employment.PlayerId].Employments.Add(employment);
            }

            using (var bulkInsert = _store.BulkInsert(null, new BulkInsertOptions { OverwriteExisting = true }))
            {
                foreach (var player in playerDictionary.Values)
                {
                    bulkInsert.Store(player);
                }

                foreach (var team in teamDictionary.Values)
                {
                    bulkInsert.Store(team);
                }
            }

            WaitForIndexing(_store);
        }
开发者ID:Zuehlke,项目名称:ravendb-workshop,代码行数:32,代码来源:E07-EmploymentEmbeddedInPlayer.cs

示例11: TestFixtureSetUp

        public void TestFixtureSetUp()
        {
            _store = NewDocumentStore();

            IndexCreation.CreateIndexes(typeof(Player).Assembly, _store);

            var players = DataGenerator.CreatePlayerList();

            using (var bulkInsert = _store.BulkInsert())
            {
                foreach (var player in players)
                {
                    bulkInsert.Store(player);
                }
            }

            WaitForIndexing(_store);
        }
开发者ID:Zuehlke,项目名称:ravendb-workshop,代码行数:18,代码来源:E04-QueryStaticIndexWithTypeCoercion.cs

示例12: TestFixtureSetUp

        public void TestFixtureSetUp()
        {
            _store = NewDocumentStore();

            IndexCreation.CreateIndexes(typeof(Player_Index_R03).Assembly, _store);

            var playerList = DataGenerator.CreatePlayerList();
            var teamList = DataGenerator.CreateTeamList();
            var employmentList = DataGenerator.CreateEmploymentList();

            using (var bulkInsert = _store.BulkInsert(null, new BulkInsertOptions { OverwriteExisting = true }))
            {
                foreach (var player in playerList)
                {
                    bulkInsert.Store(player);
                }

                foreach (var team in teamList)
                {
                    bulkInsert.Store(team);
                }

                foreach (var employment in employmentList)
                {
                    bulkInsert.Store(employment);
                }
            }

            WaitForIndexing(_store);
        }
开发者ID:Zuehlke,项目名称:ravendb-workshop,代码行数:30,代码来源:E06-EmploymentInSeparateCollection.cs

示例13: GenerateItems

        private static TestResult GenerateItems(IDocumentStore documentStore, int bulkSize, int generateCount, List<string> generatedIds)
        {
            var time = new Stopwatch();
            var writeResult = new TestResult();
            var totalRecords = 0;
            var generatingTotalTime = 0L;

            foreach (var chunkSize in ChunkUtils.GetChunks(generateCount, bulkSize))
            {
                //var items = Enumerable.Range(0, chunkSize).Select(PersonGenerator.Create).ToList();

                time.Restart();
                using (var bulkInsert = documentStore.BulkInsert())
                {
                    for (var i = 0; i < chunkSize; i++)
                    {
                        var item = PersonGenerator.Create();
                        bulkInsert.Store(item);
                        generatedIds.Add(item.Id);
                    }
                }
                time.Stop();
                generatingTotalTime += time.ElapsedMilliseconds;

                totalRecords += chunkSize;
                Console.WriteLine("Written {0} total: {1} records in: {2} ms", chunkSize, totalRecords,
                                  time.ElapsedMilliseconds);
            }
            writeResult.Count = generateCount;
            writeResult.TotalMs = generatingTotalTime;
            Console.WriteLine("Writing total time: {0} ms, avg item: {1} ms", generatingTotalTime, writeResult.ItemAvgMs);

            Console.WriteLine("Waiting for rebuilding indexes...");
            Thread.Sleep(TestSettings.WaitForRebuildIndexesMs);
            return writeResult;
        }
开发者ID:pvasek,项目名称:RavenVsMongo,代码行数:36,代码来源:RavenTest.cs


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