Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ac3b4fc

Browse files
committed
Merge branch 'AsyncCrud' of https://github.com/AdamAtDotNet/dapper-dot-net into AdamAtDotNet-AsyncCrud
2 parents 04ba42f + 5b1134a commit ac3b4fc

File tree

10 files changed

+1498
-4
lines changed

10 files changed

+1498
-4
lines changed

Dapper - VS2012.sln

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 2013
4-
VisualStudioVersion = 12.0.30723.0
4+
VisualStudioVersion = 12.0.30324.0
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DapperTests NET40", "Tests\DapperTests NET40.csproj", "{A2A80512-11F4-4028-A995-505463632C84}"
77
EndProject
@@ -44,6 +44,7 @@ EndProject
4444
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dapper.Contrib NET45", "Dapper.Contrib NET45\Dapper.Contrib NET45.csproj", "{302EC82F-A81B-48C5-B653-B5C75D2BD103}"
4545
EndProject
4646
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dapper.Rainbow NET45", "Dapper.Rainbow NET45\Dapper.Rainbow NET45.csproj", "{DB42428F-3C2B-4C9E-9B7A-5E43B53D6613}"
47+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dapper.Contrib.Tests NET45", "Dapper.Contrib.Tests NET45\Dapper.Contrib.Tests NET45.csproj", "{7A85178F-4ADC-4E4C-BF08-17FC99488A9A}"
4748
EndProject
4849
Global
4950
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -195,6 +196,16 @@ Global
195196
{DB42428F-3C2B-4C9E-9B7A-5E43B53D6613}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
196197
{DB42428F-3C2B-4C9E-9B7A-5E43B53D6613}.Release|Mixed Platforms.Build.0 = Release|Any CPU
197198
{DB42428F-3C2B-4C9E-9B7A-5E43B53D6613}.Release|x86.ActiveCfg = Release|Any CPU
199+
{7A85178F-4ADC-4E4C-BF08-17FC99488A9A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
200+
{7A85178F-4ADC-4E4C-BF08-17FC99488A9A}.Debug|Any CPU.Build.0 = Debug|Any CPU
201+
{7A85178F-4ADC-4E4C-BF08-17FC99488A9A}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
202+
{7A85178F-4ADC-4E4C-BF08-17FC99488A9A}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
203+
{7A85178F-4ADC-4E4C-BF08-17FC99488A9A}.Debug|x86.ActiveCfg = Debug|Any CPU
204+
{7A85178F-4ADC-4E4C-BF08-17FC99488A9A}.Release|Any CPU.ActiveCfg = Release|Any CPU
205+
{7A85178F-4ADC-4E4C-BF08-17FC99488A9A}.Release|Any CPU.Build.0 = Release|Any CPU
206+
{7A85178F-4ADC-4E4C-BF08-17FC99488A9A}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
207+
{7A85178F-4ADC-4E4C-BF08-17FC99488A9A}.Release|Mixed Platforms.Build.0 = Release|Any CPU
208+
{7A85178F-4ADC-4E4C-BF08-17FC99488A9A}.Release|x86.ActiveCfg = Release|Any CPU
198209
EndGlobalSection
199210
GlobalSection(SolutionProperties) = preSolution
200211
HideSolutionNode = FALSE

Dapper.Contrib NET45/Dapper.Contrib NET45.csproj

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@
4444
<Compile Include="..\Dapper.Contrib\Properties\AssemblyInfo.cs">
4545
<Link>AssemblyInfo.cs</Link>
4646
</Compile>
47-
<Compile Include="..\Dapper.Contrib\SqlMapperExtensions.cs">
48-
<Link>SqlMapperExtensions.cs</Link>
49-
</Compile>
47+
<Compile Include="SqlMapperExtensions.cs" />
5048
</ItemGroup>
5149
<ItemGroup>
5250
<Folder Include="Properties\" />

Dapper.Contrib NET45/SqlMapperExtensions.cs

Lines changed: 854 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
5+
</startup>
6+
</configuration>
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
5+
namespace Dapper.Contrib.Tests_NET45
6+
{
7+
/// <summary>
8+
/// Assert extensions borrowed from Sam's code in DapperTests
9+
/// </summary>
10+
static class Assert
11+
{
12+
public static void IsEqualTo<T>(this T obj, T other)
13+
{
14+
if (!obj.Equals(other))
15+
{
16+
throw new ApplicationException(string.Format("{0} should be equals to {1}", obj, other));
17+
}
18+
}
19+
20+
public static void IsSequenceEqualTo<T>(this IEnumerable<T> obj, IEnumerable<T> other)
21+
{
22+
if (!obj.SequenceEqual(other))
23+
{
24+
throw new ApplicationException(string.Format("{0} should be equals to {1}", obj, other));
25+
}
26+
}
27+
28+
public static void IsFalse(this bool b)
29+
{
30+
if (b)
31+
{
32+
throw new ApplicationException("Expected false");
33+
}
34+
}
35+
36+
public static void IsTrue(this bool b)
37+
{
38+
if (!b)
39+
{
40+
throw new ApplicationException("Expected true");
41+
}
42+
}
43+
44+
public static void IsNull(this object obj)
45+
{
46+
if (obj != null)
47+
{
48+
throw new ApplicationException("Expected null");
49+
}
50+
}
51+
52+
}
53+
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{7A85178F-4ADC-4E4C-BF08-17FC99488A9A}</ProjectGuid>
8+
<OutputType>Exe</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>Dapper.Contrib.Tests_NET45</RootNamespace>
11+
<AssemblyName>Dapper.Contrib.Tests NET45</AssemblyName>
12+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
</PropertyGroup>
15+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16+
<PlatformTarget>AnyCPU</PlatformTarget>
17+
<DebugSymbols>true</DebugSymbols>
18+
<DebugType>full</DebugType>
19+
<Optimize>false</Optimize>
20+
<OutputPath>bin\Debug\</OutputPath>
21+
<DefineConstants>DEBUG;TRACE</DefineConstants>
22+
<ErrorReport>prompt</ErrorReport>
23+
<WarningLevel>4</WarningLevel>
24+
</PropertyGroup>
25+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26+
<PlatformTarget>AnyCPU</PlatformTarget>
27+
<DebugType>pdbonly</DebugType>
28+
<Optimize>true</Optimize>
29+
<OutputPath>bin\Release\</OutputPath>
30+
<DefineConstants>TRACE</DefineConstants>
31+
<ErrorReport>prompt</ErrorReport>
32+
<WarningLevel>4</WarningLevel>
33+
</PropertyGroup>
34+
<ItemGroup>
35+
<Reference Include="System" />
36+
<Reference Include="System.Core" />
37+
<Reference Include="System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL" />
38+
<Reference Include="System.Xml.Linq" />
39+
<Reference Include="System.Data.DataSetExtensions" />
40+
<Reference Include="Microsoft.CSharp" />
41+
<Reference Include="System.Data" />
42+
<Reference Include="System.Xml" />
43+
</ItemGroup>
44+
<ItemGroup>
45+
<Compile Include="Assert.cs" />
46+
<Compile Include="Program.cs" />
47+
<Compile Include="Properties\AssemblyInfo.cs" />
48+
<Compile Include="Tests.cs" />
49+
<Compile Include="TestsAsync.cs" />
50+
</ItemGroup>
51+
<ItemGroup>
52+
<None Include="App.config" />
53+
</ItemGroup>
54+
<ItemGroup>
55+
<ProjectReference Include="..\Dapper NET45\Dapper NET45.csproj">
56+
<Project>{0fff5bc7-0a4b-4d87-835e-4fad70937507}</Project>
57+
<Name>Dapper NET45</Name>
58+
</ProjectReference>
59+
<ProjectReference Include="..\Dapper.Contrib NET45\Dapper.Contrib NET45.csproj">
60+
<Project>{302ec82f-a81b-48c5-b653-b5c75d2bd103}</Project>
61+
<Name>Dapper.Contrib NET45</Name>
62+
</ProjectReference>
63+
<ProjectReference Include="..\Dapper.SqlBuilder\Dapper.SqlBuilder.csproj">
64+
<Project>{bf782ef1-2b0f-42fa-9dd0-928454a94c6d}</Project>
65+
<Name>Dapper.SqlBuilder</Name>
66+
</ProjectReference>
67+
</ItemGroup>
68+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
69+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
70+
Other similar extension points exist, see Microsoft.Common.targets.
71+
<Target Name="BeforeBuild">
72+
</Target>
73+
<Target Name="AfterBuild">
74+
</Target>
75+
-->
76+
</Project>
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Data.SqlServerCe;
4+
using System.Diagnostics;
5+
using System.IO;
6+
using System.Linq;
7+
using System.Reflection;
8+
using System.Text;
9+
using System.Threading.Tasks;
10+
11+
namespace Dapper.Contrib.Tests_NET45
12+
{
13+
class Program
14+
{
15+
static void Main(string[] args)
16+
{
17+
Setup();
18+
RunTests();
19+
Setup();
20+
RunAsyncTests();
21+
Console.ReadKey();
22+
}
23+
24+
private static void Setup()
25+
{
26+
var projLoc = Assembly.GetAssembly(typeof(Program)).Location;
27+
var projFolder = Path.GetDirectoryName(projLoc);
28+
29+
if (File.Exists(projFolder + "\\Test.sdf"))
30+
File.Delete(projFolder + "\\Test.sdf");
31+
var connectionString = "Data Source = " + projFolder + "\\Test.sdf;";
32+
var engine = new SqlCeEngine(connectionString);
33+
engine.CreateDatabase();
34+
using (var connection = new SqlCeConnection(connectionString))
35+
{
36+
connection.Open();
37+
connection.Execute(@" create table Users (Id int IDENTITY(1,1) not null, Name nvarchar(100) not null, Age int not null) ");
38+
connection.Execute(@" create table Automobiles (Id int IDENTITY(1,1) not null, Name nvarchar(100) not null) ");
39+
connection.Execute(@" create table Results (Id int IDENTITY(1,1) not null, Name nvarchar(100) not null, [Order] int not null) ");
40+
}
41+
Console.WriteLine("Created database");
42+
}
43+
44+
private static void RunTests()
45+
{
46+
var tester = new Tests();
47+
foreach (var method in typeof(Tests).GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly))
48+
{
49+
if (method.ReturnType != typeof(Task))
50+
{
51+
Console.Write("Running " + method.Name);
52+
method.Invoke(tester, null);
53+
Console.WriteLine(" - OK!");
54+
}
55+
}
56+
}
57+
58+
private static void RunAsyncTests()
59+
{
60+
var tester = new TestsAsync();
61+
62+
Console.Write("Running TableNameAsync");
63+
Task.WaitAll(tester.TableNameAsync());
64+
Console.WriteLine(" - OK!");
65+
66+
Console.Write("Running TestSimpleGetAsync");
67+
Task.WaitAll(tester.TestSimpleGetAsync());
68+
Console.WriteLine(" - OK!");
69+
70+
Console.Write("Running InsertGetUpdateAsync");
71+
Task.WaitAll(tester.InsertGetUpdateAsync());
72+
Console.WriteLine(" - OK!");
73+
74+
Console.Write("Running InsertCheckKeyAsync");
75+
Task.WaitAll(tester.InsertCheckKeyAsync());
76+
Console.WriteLine(" - OK!");
77+
78+
Console.Write("Running BuilderSelectClauseAsync");
79+
Task.WaitAll(tester.BuilderSelectClauseAsync());
80+
Console.WriteLine(" - OK!");
81+
82+
Console.Write("Running BuilderTemplateWOCompositionAsync");
83+
Task.WaitAll(tester.BuilderTemplateWOCompositionAsync());
84+
Console.WriteLine(" - OK!");
85+
86+
Console.Write("Running InsertFieldWithReservedNameAsync");
87+
Task.WaitAll(tester.InsertFieldWithReservedNameAsync());
88+
Console.WriteLine(" - OK!");
89+
90+
Console.Write("Running DeleteAllAsync");
91+
Task.WaitAll(tester.DeleteAllAsync());
92+
Console.WriteLine(" - OK!");
93+
}
94+
}
95+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("Dapper.Contrib.Tests NET45")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("Dapper.Contrib.Tests NET45")]
13+
[assembly: AssemblyCopyright("Copyright © 2014")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("2d6cdd3d-b94b-4cd4-842a-60c6e4c93c5c")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]

0 commit comments

Comments
 (0)