Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
407 changes: 398 additions & 9 deletions .gitignore

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

### What is this?

ToDataTable is a pair of .Net Core extension methods that allow you to create a .Net [DataTable](https://docs.microsoft.com/en-us/dotnet/api/system.data.datatable?view=netframework-4.8) or a SQL Server [Table-Valued Parameter](https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/sql/table-valued-parameters) from a collection of objects, e.g:
ToDataTable is a pair of .NET extension methods that allow you to create a .NET [DataTable](https://docs.microsoft.com/en-us/dotnet/api/system.data.datatable?view=netframework-4.8) or a SQL Server [Table-Valued Parameter](https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/sql/table-valued-parameters) from a collection of objects, e.g:

```csharp
IEnumerable<SomeClass> enumerable = new List<SomeClass();
Expand All @@ -12,14 +12,14 @@ SqlParameter sqlParameter = enumerable.ToSqlParameter("@SqlParameterName","SqlUs

### How do I get it?

Install ToDataTable via nuget Package Manager:
Install ToDataTable via Nuget Package Manager:
```
Install-Package ToDataTable -Version 0.1.2
Install-Package ToDataTable -Version 0.1.3
```

or .Net CLI:
or .NET CLI:
```
dotnet add package ToDataTable --version 0.1.2
dotnet add package ToDataTable --version 0.1.3
```

### Give me an example:
Expand Down Expand Up @@ -70,7 +70,7 @@ The resulting table would look like this:

### Why is this useful?

Sql Table-valued parameters are created in .Net using `DataTable`s. Coding a DataTable from scratch is time consuming and prone to error. These extension methods can create a Datatable or a SqlParameter from a collection of objects in a single line of code.
SQL table-valued parameters are created in .NET using `DataTable`s. Coding a DataTable from scratch is time consuming and prone to error. These extension methods can create a Datatable or a SqlParameter from a collection of objects in a single line of code.

### Is it fast?

Expand Down
25 changes: 12 additions & 13 deletions ToDataTable/ToDataTable.Benchmarks/ToDataTable.Benchmarks.csproj
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<OutputType>Exe</OutputType>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<OutputType>Exe</OutputType>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.11.5" />
<PackageReference Include="FastMember" Version="1.5.0" />
<PackageReference Include="HyperDescriptor" Version="1.0.5" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.1" />
<PackageReference Include="FastMember" Version="1.5.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\ToDataTable.TestDataGenerator\ToDataTable.TestDataGenerator.csproj" />
<ProjectReference Include="..\ToDataTable\ToDataTable.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ToDataTable.TestDataGenerator\ToDataTable.TestDataGenerator.csproj" />
<ProjectReference Include="..\ToDataTable\ToDataTable.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\ToDataTable\ToDataTable.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ToDataTable\ToDataTable.csproj" />
</ItemGroup>

</Project>
34 changes: 18 additions & 16 deletions ToDataTable/ToDataTable.Tests/ToDataTable.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FastMember" Version="1.5.0" />
<PackageReference Include="FluentAssertions" Version="5.9.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.1" />
<PackageReference Include="System.Data.SqlClient" Version="4.5.1" />
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.3.0" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="4.0.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\ToDataTable.TestDataGenerator\ToDataTable.TestDataGenerator.csproj" />
<ProjectReference Include="..\ToDataTable\ToDataTable.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ToDataTable.TestDataGenerator\ToDataTable.TestDataGenerator.csproj" />
<ProjectReference Include="..\ToDataTable\ToDataTable.csproj" />
</ItemGroup>

</Project>
17 changes: 13 additions & 4 deletions ToDataTable/ToDataTable.sln
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ToDataTable.Tests", "ToDataTable.Tests\ToDataTable.Tests.csproj", "{1E9E257C-5A34-40BB-BE64-47404D2D8941}"
# Visual Studio Version 17
VisualStudioVersion = 17.0.32112.339
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ToDataTable.Tests", "ToDataTable.Tests\ToDataTable.Tests.csproj", "{1E9E257C-5A34-40BB-BE64-47404D2D8941}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ToDataTable", "ToDataTable\ToDataTable.csproj", "{1A5E78EC-16B0-40BF-9848-D1B17F33B501}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ToDataTable", "ToDataTable\ToDataTable.csproj", "{1A5E78EC-16B0-40BF-9848-D1B17F33B501}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ToDataTable.Benchmarks", "ToDataTable.Benchmarks\ToDataTable.Benchmarks.csproj", "{3BFF1647-D02F-40D6-A8F3-6F1C7E635CC5}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ToDataTable.Benchmarks", "ToDataTable.Benchmarks\ToDataTable.Benchmarks.csproj", "{3BFF1647-D02F-40D6-A8F3-6F1C7E635CC5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ToDataTable.TestDataGenerator", "ToDataTable.TestDataGenerator\ToDataTable.TestDataGenerator.csproj", "{D48109BD-CCF6-41D5-BF65-9E32C4041928}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ToDataTable.TestDataGenerator", "ToDataTable.TestDataGenerator\ToDataTable.TestDataGenerator.csproj", "{D48109BD-CCF6-41D5-BF65-9E32C4041928}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -31,4 +34,10 @@ Global
{D48109BD-CCF6-41D5-BF65-9E32C4041928}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D48109BD-CCF6-41D5-BF65-9E32C4041928}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {25320C5E-5C2C-4B27-A3CA-32E35759935B}
EndGlobalSection
EndGlobal
48 changes: 24 additions & 24 deletions ToDataTable/ToDataTable/ToDataTable.csproj
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>

<IsPackable>true</IsPackable>
<IsPackable>true</IsPackable>

<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>

<Authors>Chris Hodges</Authors>
<Authors>Chris Hodges</Authors>

<Description>ToDataTable is a pair of .Net Core extension methods that allow you to create a .Net DataTable (or a SQL Server Table-Valued Parameter) from a collection of objects.</Description>
<Description>ToDataTable is a pair of .NET extension methods that allow you to create a .NET DataTable (or a SQL Server Table-Valued Parameter) from a collection of objects.</Description>

<PackageLicenseUrl></PackageLicenseUrl>
<PackageLicenseUrl></PackageLicenseUrl>

<PackageProjectUrl>https://github.com/ChrisHodges/ToDataTable</PackageProjectUrl>
<PackageProjectUrl>https://github.com/ChrisHodges/ToDataTable</PackageProjectUrl>

<RepositoryUrl>https://github.com/ChrisHodges/ToDataTable</RepositoryUrl>
<RepositoryUrl>https://github.com/ChrisHodges/ToDataTable</RepositoryUrl>

<ApplicationIcon />
<ApplicationIcon />

<OutputType>Library</OutputType>
<OutputType>Library</OutputType>

<StartupObject />
<StartupObject />

<AssemblyVersion>0.1.2.0</AssemblyVersion>
<AssemblyVersion>0.1.3.0</AssemblyVersion>

<FileVersion>0.1.2.0</FileVersion>
<FileVersion>0.1.3.0</FileVersion>

<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageLicenseExpression>MIT</PackageLicenseExpression>

<Version>0.1.0</Version>
<Version>0.1.3</Version>

<PackageVersion>0.1.2</PackageVersion>
</PropertyGroup>
<PackageVersion>0.1.3</PackageVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.Data.SqlClient" Version="4.5.1" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Data.SqlClient" Version="4.0.1" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion ToDataTable/ToDataTable/ToDataTableExtensionMethods.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Microsoft.Data.SqlClient;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;

namespace ToDataTable
{
Expand Down