本文整理汇总了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();
}
示例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");
}
}