Skip to content
This repository was archived by the owner on Nov 3, 2019. It is now read-only.

Extended IDBExecutor interface #4

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
133 changes: 68 additions & 65 deletions DapperWrapper/DapperWrapper.csproj
Original file line number Diff line number Diff line change
@@ -1,72 +1,75 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{0E94BB6B-8213-4B74-B362-A84D42B1AE5D}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>DapperWrapper</RootNamespace>
<AssemblyName>DapperWrapper</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<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|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Dapper">
<HintPath>..\packages\Dapper.1.8\lib\net40\Dapper.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Transactions" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="IDbExecutor.cs" />
<Compile Include="IDbExecutorFactory.cs" />
<Compile Include="ITransactionScope.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SqlExecutor.cs" />
<Compile Include="SqlExecutorFactory.cs" />
<Compile Include="TransactionScopeWrapper.cs" />
</ItemGroup>
<ItemGroup>
<None Include="DapperWrapper.nuspec">
<SubType>Designer</SubType>
</None>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{0E94BB6B-8213-4B74-B362-A84D42B1AE5D}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>DapperWrapper</RootNamespace>
<AssemblyName>DapperWrapper</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<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|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Dapper, Version=1.12.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Dapper.1.12.1\lib\net40\Dapper.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Transactions" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="GridReaderWrapper.cs" />
<Compile Include="IDbExecutor.cs" />
<Compile Include="IDbExecutorFactory.cs" />
<Compile Include="IGridReaderWrapper.cs" />
<Compile Include="ITransactionScope.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SqlExecutor.cs" />
<Compile Include="SqlExecutorFactory.cs" />
<Compile Include="TransactionScopeWrapper.cs" />
</ItemGroup>
<ItemGroup>
<None Include="DapperWrapper.nuspec">
<SubType>Designer</SubType>
</None>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
-->
</Project>
54 changes: 54 additions & 0 deletions DapperWrapper/GridReaderWrapper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using Dapper;

namespace DapperWrapper
{
class GridReaderWrapper : IGridReaderWrapper
{
private SqlMapper.GridReader _gridReader;

public GridReaderWrapper(SqlMapper.GridReader gridReader)
{
_gridReader = gridReader;
}

public IEnumerable<T> Read<T>()
{
return _gridReader.Read<T>();
}

public IEnumerable<TReturn> Read<TFirst, TSecond, TReturn>(
Func<TFirst, TSecond, TReturn> func,
string splitOn = "id")
{
return _gridReader.Read(func, splitOn);
}

public IEnumerable<TReturn> Read<TFirst, TSecond, TThird, TReturn>(
Func<TFirst, TSecond, TThird, TReturn> func,
string splitOn = "id")
{
return _gridReader.Read(func, splitOn);
}

public IEnumerable<TReturn> Read<TFirst, TSecond, TThird, TFourth, TReturn>(
Func<TFirst, TSecond, TThird, TFourth, TReturn> func,
string splitOn = "id")
{
return _gridReader.Read(func, splitOn);
}

public IEnumerable<TReturn> Read<TFirst, TSecond, TThird, TFourth, TFifth, TReturn>(
Func<TFirst, TSecond, TThird, TFourth, TFifth, TReturn> func,
string splitOn = "id")
{
return _gridReader.Read(func, splitOn);
}

public void Dispose()
{
_gridReader.Dispose();
}
}
}
49 changes: 48 additions & 1 deletion DapperWrapper/IDbExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,53 @@ IEnumerable<T> Query<T>(
IDbTransaction transaction = null,
bool buffered = true,
int? commandTimeout = default(int?),
CommandType? commandType = default(CommandType?));
CommandType? commandType = default(CommandType?));

IEnumerable<TReturn> Query<T1, T2, TReturn>(
string sql,
Func<T1, T2, TReturn> map,
object param = null,
IDbTransaction transaction = null,
bool buffered = true,
string splitOn = "Id",
int? commandTimeout = default(int?),
CommandType? commandType = default(CommandType?));

IEnumerable<TReturn> Query<T1, T2, T3, TReturn>(
string sql,
Func<T1, T2, T3, TReturn> map,
object param = null,
IDbTransaction transaction = null,
bool buffered = true,
string splitOn = "Id",
int? commandTimeout = default(int?),
CommandType? commandType = default(CommandType?));

IEnumerable<TReturn> Query<T1, T2, T3, T4, TReturn>(
string sql,
Func<T1, T2, T3, T4, TReturn> map,
object param = null,
IDbTransaction transaction = null,
bool buffered = true,
string splitOn = "Id",
int? commandTimeout = default(int?),
CommandType? commandType = default(CommandType?));

IEnumerable<TReturn> Query<T1, T2, T3, T4, T5, TReturn>(
string sql,
Func<T1, T2, T3, T4, T5, TReturn> map,
object param = null,
IDbTransaction transaction = null,
bool buffered = true,
string splitOn = "Id",
int? commandTimeout = default(int?),
CommandType? commandType = default(CommandType?));

IGridReaderWrapper QueryMultiple(
string sql,
dynamic param = null,
IDbTransaction transaction = null,
int? commandTimeout = null,
CommandType? commandType = null);
}
}
14 changes: 14 additions & 0 deletions DapperWrapper/IGridReaderWrapper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;

namespace DapperWrapper
{
public interface IGridReaderWrapper : IDisposable
{
IEnumerable<T> Read<T>();
IEnumerable<TReturn> Read<TFirst, TSecond, TReturn>(Func<TFirst, TSecond, TReturn> func, string splitOn = "id");
IEnumerable<TReturn> Read<TFirst, TSecond, TThird, TReturn>(Func<TFirst, TSecond, TThird, TReturn> func, string splitOn = "id");
IEnumerable<TReturn> Read<TFirst, TSecond, TThird, TFourth, TReturn>(Func<TFirst, TSecond, TThird, TFourth, TReturn> func, string splitOn = "id");
IEnumerable<TReturn> Read<TFirst, TSecond, TThird, TFourth, TFifth, TReturn>(Func<TFirst, TSecond, TThird, TFourth, TFifth, TReturn> func, string splitOn = "id");
}
}
104 changes: 103 additions & 1 deletion DapperWrapper/SqlExecutor.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using Dapper;
Expand Down Expand Up @@ -61,6 +62,107 @@ public IEnumerable<T> Query<T>(
buffered,
commandTimeout,
commandType);
}

public IEnumerable<TReturn> Query<T1, T2, TReturn>(
string sql,
Func<T1, T2, TReturn> map,
object param = null,
IDbTransaction transaction = null,
bool buffered = true,
string splitOn = "Id",
int? commandTimeout = default(int?),
CommandType? commandType = default(CommandType?))
{
return _sqlConnection.Query(
sql,
map,
param,
transaction,
buffered,
splitOn,
commandTimeout,
commandType);
}

public IEnumerable<TReturn> Query<T1, T2, T3, TReturn>(
string sql,
Func<T1, T2, T3, TReturn> map,
object param = null,
IDbTransaction transaction = null,
bool buffered = true,
string splitOn = "Id",
int? commandTimeout = default(int?),
CommandType? commandType = default(CommandType?))
{
return _sqlConnection.Query(
sql,
map,
param,
transaction,
buffered,
splitOn,
commandTimeout,
commandType);
}

public IEnumerable<TReturn> Query<T1, T2, T3, T4, TReturn>(
string sql,
Func<T1, T2, T3, T4, TReturn> map,
object param = null,
IDbTransaction transaction = null,
bool buffered = true,
string splitOn = "Id",
int? commandTimeout = default(int?),
CommandType? commandType = default(CommandType?))
{
return _sqlConnection.Query(
sql,
map,
param,
transaction,
buffered,
splitOn,
commandTimeout,
commandType);
}

public IEnumerable<TReturn> Query<T1, T2, T3, T4, T5, TReturn>(
string sql,
Func<T1, T2, T3, T4, T5, TReturn> map,
object param = null,
IDbTransaction transaction = null,
bool buffered = true,
string splitOn = "Id",
int? commandTimeout = default(int?),
CommandType? commandType = default(CommandType?))
{
return _sqlConnection.Query(
sql,
map,
param,
transaction,
buffered,
splitOn,
commandTimeout,
commandType);
}

public IGridReaderWrapper QueryMultiple(
string sql,
object param = null,
IDbTransaction transaction = null,
int? commandTimeout = null,
CommandType? commandType = null)
{
var gridReader = _sqlConnection.QueryMultiple(
sql,
param,
transaction,
commandTimeout,
commandType);

return new GridReaderWrapper(gridReader);
}

public void Dispose()
Expand Down
6 changes: 3 additions & 3 deletions DapperWrapper/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Dapper" version="1.8" />
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Dapper" version="1.12.1" targetFramework="net40" />
</packages>