コード例 #1
0
        public void CreateChunks()
        {
            dbKeyOffset.Create(Settings.Current.Building.Id.Value);
            dbChunk.ClearChunks(Settings.Current.Building.Id.Value);
            dbSource.CreateChunkTable();
            foreach (var chunk in GetPersonKeys(Settings.Current.Builder.BatchSize))
            {
                var chunkId = dbChunk.AddChunk(Settings.Current.Building.Id.Value);

                using (var bulkCopy = new SqlBulkCopy(Settings.Current.Building.SourceConnectionString))
                {
                    bulkCopy.Write(
                        new ChunkDataReader(
                            chunk.Select(
                                c => new ChunkRecord {
                        Id = chunkId, PersonId = Convert.ToInt64(c.Key), PersonSource = c.Value
                    })
                            .ToList()),
                        "_chunks");
                    bulkCopy.Close();
                }
            }
            dbSource.CreateIndexesChunkTable();
        }