Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added type support for bulk inserts. #5

Merged
merged 1 commit into from Mar 2, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 19 additions & 10 deletions nDump.Console/nDump.Console.csproj
Expand Up @@ -29,24 +29,33 @@
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<CodeAnalysisLogFile>bin\Debug\nDump.Console.exe.CodeAnalysisLog.xml</CodeAnalysisLogFile>
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
<CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<CodeAnalysisLogFile>bin\Release\nDump.Console.exe.CodeAnalysisLog.xml</CodeAnalysisLogFile>
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
<CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
Expand Down
29 changes: 19 additions & 10 deletions nDump.GUI/nDump.GUI.csproj
Expand Up @@ -14,24 +14,33 @@
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<CodeAnalysisLogFile>bin\Debug\nDump.GUI.exe.CodeAnalysisLog.xml</CodeAnalysisLogFile>
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
<CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<CodeAnalysisLogFile>bin\Release\nDump.GUI.exe.CodeAnalysisLog.xml</CodeAnalysisLogFile>
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
<CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
Expand Down
72 changes: 10 additions & 62 deletions nDump.sln
Expand Up @@ -18,89 +18,37 @@ EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|Mixed Platforms = Debug|Mixed Platforms
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|Mixed Platforms = Release|Mixed Platforms
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{FE26FDE2-574F-480E-96E6-4C2A5051D14A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FE26FDE2-574F-480E-96E6-4C2A5051D14A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FE26FDE2-574F-480E-96E6-4C2A5051D14A}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{FE26FDE2-574F-480E-96E6-4C2A5051D14A}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{FE26FDE2-574F-480E-96E6-4C2A5051D14A}.Debug|x86.ActiveCfg = Debug|x86
{FE26FDE2-574F-480E-96E6-4C2A5051D14A}.Debug|x86.Build.0 = Debug|x86
{FE26FDE2-574F-480E-96E6-4C2A5051D14A}.Release|Any CPU.ActiveCfg = Release|x86
{FE26FDE2-574F-480E-96E6-4C2A5051D14A}.Release|Any CPU.Build.0 = Release|x86
{FE26FDE2-574F-480E-96E6-4C2A5051D14A}.Release|Mixed Platforms.ActiveCfg = Release|x86
{FE26FDE2-574F-480E-96E6-4C2A5051D14A}.Release|Mixed Platforms.Build.0 = Release|x86
{FE26FDE2-574F-480E-96E6-4C2A5051D14A}.Release|x86.ActiveCfg = Release|x86
{FE26FDE2-574F-480E-96E6-4C2A5051D14A}.Release|x86.Build.0 = Release|x86
{FE26FDE2-574F-480E-96E6-4C2A5051D14A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FE26FDE2-574F-480E-96E6-4C2A5051D14A}.Release|Any CPU.Build.0 = Release|Any CPU
{E3B83D68-C90C-4874-8E5F-DEC8D038BC7C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E3B83D68-C90C-4874-8E5F-DEC8D038BC7C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E3B83D68-C90C-4874-8E5F-DEC8D038BC7C}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{E3B83D68-C90C-4874-8E5F-DEC8D038BC7C}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{E3B83D68-C90C-4874-8E5F-DEC8D038BC7C}.Debug|x86.ActiveCfg = Debug|Any CPU
{E3B83D68-C90C-4874-8E5F-DEC8D038BC7C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E3B83D68-C90C-4874-8E5F-DEC8D038BC7C}.Release|Any CPU.Build.0 = Release|Any CPU
{E3B83D68-C90C-4874-8E5F-DEC8D038BC7C}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{E3B83D68-C90C-4874-8E5F-DEC8D038BC7C}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{E3B83D68-C90C-4874-8E5F-DEC8D038BC7C}.Release|x86.ActiveCfg = Release|Any CPU
{DBF22390-41BC-4E33-BC9E-F381621EBF01}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DBF22390-41BC-4E33-BC9E-F381621EBF01}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DBF22390-41BC-4E33-BC9E-F381621EBF01}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{DBF22390-41BC-4E33-BC9E-F381621EBF01}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{DBF22390-41BC-4E33-BC9E-F381621EBF01}.Debug|x86.ActiveCfg = Debug|Any CPU
{DBF22390-41BC-4E33-BC9E-F381621EBF01}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DBF22390-41BC-4E33-BC9E-F381621EBF01}.Release|Any CPU.Build.0 = Release|Any CPU
{DBF22390-41BC-4E33-BC9E-F381621EBF01}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{DBF22390-41BC-4E33-BC9E-F381621EBF01}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{DBF22390-41BC-4E33-BC9E-F381621EBF01}.Release|x86.ActiveCfg = Release|Any CPU
{63A90231-56B0-4BA7-9484-B4909890165D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{63A90231-56B0-4BA7-9484-B4909890165D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{63A90231-56B0-4BA7-9484-B4909890165D}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{63A90231-56B0-4BA7-9484-B4909890165D}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{63A90231-56B0-4BA7-9484-B4909890165D}.Debug|x86.ActiveCfg = Debug|Any CPU
{63A90231-56B0-4BA7-9484-B4909890165D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{63A90231-56B0-4BA7-9484-B4909890165D}.Release|Any CPU.Build.0 = Release|Any CPU
{63A90231-56B0-4BA7-9484-B4909890165D}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{63A90231-56B0-4BA7-9484-B4909890165D}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{63A90231-56B0-4BA7-9484-B4909890165D}.Release|x86.ActiveCfg = Release|Any CPU
{E6F5B9C6-A111-4787-98A1-A8EE8E603D77}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E6F5B9C6-A111-4787-98A1-A8EE8E603D77}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E6F5B9C6-A111-4787-98A1-A8EE8E603D77}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{E6F5B9C6-A111-4787-98A1-A8EE8E603D77}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{E6F5B9C6-A111-4787-98A1-A8EE8E603D77}.Debug|x86.ActiveCfg = Debug|Any CPU
{E6F5B9C6-A111-4787-98A1-A8EE8E603D77}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E6F5B9C6-A111-4787-98A1-A8EE8E603D77}.Release|Any CPU.Build.0 = Release|Any CPU
{E6F5B9C6-A111-4787-98A1-A8EE8E603D77}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{E6F5B9C6-A111-4787-98A1-A8EE8E603D77}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{E6F5B9C6-A111-4787-98A1-A8EE8E603D77}.Release|x86.ActiveCfg = Release|Any CPU
{339F5DB2-53E0-4958-BC0A-79843A5413FB}.Debug|Any CPU.ActiveCfg = Debug|x86
{339F5DB2-53E0-4958-BC0A-79843A5413FB}.Debug|Any CPU.Build.0 = Debug|x86
{339F5DB2-53E0-4958-BC0A-79843A5413FB}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{339F5DB2-53E0-4958-BC0A-79843A5413FB}.Debug|Mixed Platforms.Build.0 = Debug|x86
{339F5DB2-53E0-4958-BC0A-79843A5413FB}.Debug|x86.ActiveCfg = Debug|x86
{339F5DB2-53E0-4958-BC0A-79843A5413FB}.Debug|x86.Build.0 = Debug|x86
{339F5DB2-53E0-4958-BC0A-79843A5413FB}.Release|Any CPU.ActiveCfg = Release|x86
{339F5DB2-53E0-4958-BC0A-79843A5413FB}.Release|Any CPU.Build.0 = Release|x86
{339F5DB2-53E0-4958-BC0A-79843A5413FB}.Release|Mixed Platforms.ActiveCfg = Release|x86
{339F5DB2-53E0-4958-BC0A-79843A5413FB}.Release|Mixed Platforms.Build.0 = Release|x86
{339F5DB2-53E0-4958-BC0A-79843A5413FB}.Release|x86.ActiveCfg = Release|x86
{339F5DB2-53E0-4958-BC0A-79843A5413FB}.Release|x86.Build.0 = Release|x86
{69908E89-D0F7-4CCF-8C80-9EF4678FFE8D}.Debug|Any CPU.ActiveCfg = Debug|x86
{69908E89-D0F7-4CCF-8C80-9EF4678FFE8D}.Debug|Any CPU.Build.0 = Debug|x86
{69908E89-D0F7-4CCF-8C80-9EF4678FFE8D}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{69908E89-D0F7-4CCF-8C80-9EF4678FFE8D}.Debug|Mixed Platforms.Build.0 = Debug|x86
{69908E89-D0F7-4CCF-8C80-9EF4678FFE8D}.Debug|x86.ActiveCfg = Debug|x86
{69908E89-D0F7-4CCF-8C80-9EF4678FFE8D}.Debug|x86.Build.0 = Debug|x86
{69908E89-D0F7-4CCF-8C80-9EF4678FFE8D}.Release|Any CPU.ActiveCfg = Release|x86
{69908E89-D0F7-4CCF-8C80-9EF4678FFE8D}.Release|Any CPU.Build.0 = Release|x86
{69908E89-D0F7-4CCF-8C80-9EF4678FFE8D}.Release|Mixed Platforms.ActiveCfg = Release|x86
{69908E89-D0F7-4CCF-8C80-9EF4678FFE8D}.Release|Mixed Platforms.Build.0 = Release|x86
{69908E89-D0F7-4CCF-8C80-9EF4678FFE8D}.Release|x86.ActiveCfg = Release|x86
{69908E89-D0F7-4CCF-8C80-9EF4678FFE8D}.Release|x86.Build.0 = Release|x86
{339F5DB2-53E0-4958-BC0A-79843A5413FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{339F5DB2-53E0-4958-BC0A-79843A5413FB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{339F5DB2-53E0-4958-BC0A-79843A5413FB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{339F5DB2-53E0-4958-BC0A-79843A5413FB}.Release|Any CPU.Build.0 = Release|Any CPU
{69908E89-D0F7-4CCF-8C80-9EF4678FFE8D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{69908E89-D0F7-4CCF-8C80-9EF4678FFE8D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{69908E89-D0F7-4CCF-8C80-9EF4678FFE8D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{69908E89-D0F7-4CCF-8C80-9EF4678FFE8D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
19 changes: 17 additions & 2 deletions nDump/Import/CsvDataImporter.cs
Expand Up @@ -74,13 +74,28 @@ public void InsertDataIntoDestinationTables(List<SqlTableSelect> tablesToProcess
var csvFile = Path.Combine(_csvDirectory, table.TableName + ".csv");
var csvReader = new CsvReader(File.OpenText(csvFile), true, _delimiter, '\"', '\"', '#',
ValueTrimmingOptions.UnquotedOnly);
var dataTable = new DataTable();
dataTable.Load(csvReader);

var dataTable = LoadData(csvReader, table.TableName);
_queryExecutor.ExecuteBulkInsert(table.TableName, dataTable, table.HasIdentity);
_logger.Log("\t\tInserted " + dataTable.Rows.Count + " rows.");

}
}

private DataTable LoadData(CsvReader csvReader, string tableName)
{
var dataTable = GetDataTableWithColumnDataTypesSet(csvReader, tableName);
dataTable.Load(csvReader);

return dataTable;
}

private DataTable GetDataTableWithColumnDataTypesSet(CsvReader csvReader, string tableName)
{
var columnList = csvReader.GetFieldHeaders().Select(columnName => "[" + columnName + "]");
var query = string.Format("SET FMTONLY ON; SELECT {0} FROM {1}; SET FMTONLY OFF;", string.Join(",", columnList), tableName);
var dataTable = _queryExecutor.ExecuteSelectStatement(query);
return dataTable;
}
}
}
19 changes: 0 additions & 19 deletions nDump/nDump.csproj
Expand Up @@ -15,25 +15,6 @@
</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<PlatformTarget>AnyCPU</PlatformTarget>
<OutputPath>bin\Debug\</OutputPath>
Expand Down