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


C# SqlBulkCopy.Write方法代码示例

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


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

示例1: CreateChunks

        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();
        }
开发者ID:bradanton,项目名称:ETL-CDMBuilder,代码行数:22,代码来源:ChunkController.cs

示例2: SaveEntityLookup

        private void SaveEntityLookup(bool saveToDb)
        {
            if (saveToDb)
             {
            using (var c = SqlConnectionHelper.OpenConnection(Settings.Current.Building.DestinationConnectionString))
            using (var bulkCopy = new SqlBulkCopy(c, SqlBulkCopyOptions.TableLock, null))
            {
               if (locationConcepts != null)
                  bulkCopy.Write(new LocationDataReader(locationConcepts.Lookup.Values.ToList()), "LOCATION");

               if (organizationConcepts != null)
                  bulkCopy.Write(new OrganizationDataReader(organizationConcepts.Lookup.Values.ToList()), "ORGANIZATION");

               if (careSiteConcepts != null)
                  bulkCopy.Write(new CareSiteDataReader(careSiteConcepts.Lookup.Values.ToList()), "CARE_SITE");

               if (providerConcepts != null)
                  bulkCopy.Write(new ProviderDataReader(providerConcepts.Lookup.Values.ToList()), "PROVIDER");

               bulkCopy.Close();
            }
             }
             else
             {
            var folder = Settings.Current.ResultFolder;
            if (locationConcepts != null)
               SaveToFile(folder, new LocationDataReader(locationConcepts.Lookup.Values.ToList()), "LOCATION");

            if (organizationConcepts != null)
               SaveToFile(folder, new OrganizationDataReader(organizationConcepts.Lookup.Values.ToList()),
                  "ORGANIZATION");

            if (careSiteConcepts != null)
               SaveToFile(folder, new CareSiteDataReader(careSiteConcepts.Lookup.Values.ToList()), "CARE_SITE");

            if (providerConcepts != null)
               SaveToFile(folder, new ProviderDataReader(providerConcepts.Lookup.Values.ToList()), "PROVIDER");
             }
        }
开发者ID:bradanton,项目名称:ETL-CDMBuilder,代码行数:39,代码来源:Vocabulary.cs


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