Commit 2de05697 authored by James Holwell's avatar James Holwell

Merge remote-tracking branch 'upstream/master' into issue-138

parents d149e0c2 ce23d47d
 
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013 # Visual Studio 2013
VisualStudioVersion = 12.0.30501.0 VisualStudioVersion = 12.0.30723.0
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DapperTests NET40", "Tests\DapperTests NET40.csproj", "{A2A80512-11F4-4028-A995-505463632C84}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DapperTests NET40", "Tests\DapperTests NET40.csproj", "{A2A80512-11F4-4028-A995-505463632C84}"
EndProject EndProject
...@@ -28,6 +28,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dapper NET45", "Dapper NET4 ...@@ -28,6 +28,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dapper NET45", "Dapper NET4
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{E757192C-9411-458D-8815-8DAB34E12D03}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{E757192C-9411-458D-8815-8DAB34E12D03}"
ProjectSection(SolutionItems) = preProject ProjectSection(SolutionItems) = preProject
Dapper.Contrib.nuspec = Dapper.Contrib.nuspec
Dapper.EntityFramework.nuspec = Dapper.EntityFramework.nuspec Dapper.EntityFramework.nuspec = Dapper.EntityFramework.nuspec
Dapper.nuspec = Dapper.nuspec Dapper.nuspec = Dapper.nuspec
License.txt = License.txt License.txt = License.txt
...@@ -39,6 +40,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dapper.EntityFramework NET4 ...@@ -39,6 +40,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dapper.EntityFramework NET4
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dapper.EntityFramework NET40", "Dapper.EntityFramework NET40\Dapper.EntityFramework NET40.csproj", "{2544DFBA-7F64-4003-9C36-D8337F770A36}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dapper.EntityFramework NET40", "Dapper.EntityFramework NET40\Dapper.EntityFramework NET40.csproj", "{2544DFBA-7F64-4003-9C36-D8337F770A36}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dapper.Contrib NET45", "Dapper.Contrib NET45\Dapper.Contrib NET45.csproj", "{302EC82F-A81B-48C5-B653-B5C75D2BD103}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
...@@ -169,6 +172,16 @@ Global ...@@ -169,6 +172,16 @@ Global
{2544DFBA-7F64-4003-9C36-D8337F770A36}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {2544DFBA-7F64-4003-9C36-D8337F770A36}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{2544DFBA-7F64-4003-9C36-D8337F770A36}.Release|Mixed Platforms.Build.0 = Release|Any CPU {2544DFBA-7F64-4003-9C36-D8337F770A36}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{2544DFBA-7F64-4003-9C36-D8337F770A36}.Release|x86.ActiveCfg = Release|Any CPU {2544DFBA-7F64-4003-9C36-D8337F770A36}.Release|x86.ActiveCfg = Release|Any CPU
{302EC82F-A81B-48C5-B653-B5C75D2BD103}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{302EC82F-A81B-48C5-B653-B5C75D2BD103}.Debug|Any CPU.Build.0 = Debug|Any CPU
{302EC82F-A81B-48C5-B653-B5C75D2BD103}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{302EC82F-A81B-48C5-B653-B5C75D2BD103}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{302EC82F-A81B-48C5-B653-B5C75D2BD103}.Debug|x86.ActiveCfg = Debug|Any CPU
{302EC82F-A81B-48C5-B653-B5C75D2BD103}.Release|Any CPU.ActiveCfg = Release|Any CPU
{302EC82F-A81B-48C5-B653-B5C75D2BD103}.Release|Any CPU.Build.0 = Release|Any CPU
{302EC82F-A81B-48C5-B653-B5C75D2BD103}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{302EC82F-A81B-48C5-B653-B5C75D2BD103}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{302EC82F-A81B-48C5-B653-B5C75D2BD103}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
......
...@@ -32,5 +32,5 @@ ...@@ -32,5 +32,5 @@
// //
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
[assembly: AssemblyVersion("1.27.0.0")] [assembly: AssemblyVersion("1.28.0.0")]
[assembly: AssemblyFileVersion("1.27.0.0")] [assembly: AssemblyFileVersion("1.28.0.0")]
This diff is collapsed.
...@@ -50,7 +50,7 @@ private static async Task<IEnumerable<T>> QueryAsync<T>(this IDbConnection cnn, ...@@ -50,7 +50,7 @@ private static async Task<IEnumerable<T>> QueryAsync<T>(this IDbConnection cnn,
{ {
object param = command.Parameters; object param = command.Parameters;
var identity = new Identity(command.CommandText, command.CommandType, cnn, effectiveType, param == null ? null : param.GetType(), null); var identity = new Identity(command.CommandText, command.CommandType, cnn, effectiveType, param == null ? null : param.GetType(), null);
var info = GetCacheInfo(identity, param); var info = GetCacheInfo(identity, param, command.AddToCache);
bool wasClosed = cnn.State == ConnectionState.Closed; bool wasClosed = cnn.State == ConnectionState.Closed;
using (var cmd = (DbCommand)command.SetupCommand(cnn, info.ParamReader)) using (var cmd = (DbCommand)command.SetupCommand(cnn, info.ParamReader))
{ {
...@@ -59,7 +59,7 @@ private static async Task<IEnumerable<T>> QueryAsync<T>(this IDbConnection cnn, ...@@ -59,7 +59,7 @@ private static async Task<IEnumerable<T>> QueryAsync<T>(this IDbConnection cnn,
if (wasClosed) await ((DbConnection)cnn).OpenAsync().ConfigureAwait(false); if (wasClosed) await ((DbConnection)cnn).OpenAsync().ConfigureAwait(false);
using (var reader = await cmd.ExecuteReaderAsync(command.CancellationToken).ConfigureAwait(false)) using (var reader = await cmd.ExecuteReaderAsync(command.CancellationToken).ConfigureAwait(false))
{ {
return ExecuteReader<T>(reader, effectiveType, identity, info).ToList(); return ExecuteReader<T>(reader, effectiveType, identity, info, command.AddToCache).ToList();
} }
} }
finally finally
...@@ -130,7 +130,7 @@ private static async Task<int> ExecuteMultiImplAsync(IDbConnection cnn, CommandD ...@@ -130,7 +130,7 @@ private static async Task<int> ExecuteMultiImplAsync(IDbConnection cnn, CommandD
cmd = (DbCommand)command.SetupCommand(cnn, null); cmd = (DbCommand)command.SetupCommand(cnn, null);
masterSql = cmd.CommandText; masterSql = cmd.CommandText;
var identity = new Identity(command.CommandText, cmd.CommandType, cnn, null, obj.GetType(), null); var identity = new Identity(command.CommandText, cmd.CommandType, cnn, null, obj.GetType(), null);
info = GetCacheInfo(identity, obj); info = GetCacheInfo(identity, obj, command.AddToCache);
} else if(pending.Count >= MAX_PENDING) } else if(pending.Count >= MAX_PENDING)
{ {
var recycled = pending.Dequeue(); var recycled = pending.Dequeue();
...@@ -177,7 +177,7 @@ private static async Task<int> ExecuteMultiImplAsync(IDbConnection cnn, CommandD ...@@ -177,7 +177,7 @@ private static async Task<int> ExecuteMultiImplAsync(IDbConnection cnn, CommandD
masterSql = cmd.CommandText; masterSql = cmd.CommandText;
isFirst = false; isFirst = false;
var identity = new Identity(command.CommandText, cmd.CommandType, cnn, null, obj.GetType(), null); var identity = new Identity(command.CommandText, cmd.CommandType, cnn, null, obj.GetType(), null);
info = GetCacheInfo(identity, obj); info = GetCacheInfo(identity, obj, command.AddToCache);
} }
else else
{ {
...@@ -199,7 +199,7 @@ private static async Task<int> ExecuteMultiImplAsync(IDbConnection cnn, CommandD ...@@ -199,7 +199,7 @@ private static async Task<int> ExecuteMultiImplAsync(IDbConnection cnn, CommandD
private static async Task<int> ExecuteImplAsync(IDbConnection cnn, CommandDefinition command, object param) private static async Task<int> ExecuteImplAsync(IDbConnection cnn, CommandDefinition command, object param)
{ {
var identity = new Identity(command.CommandText, command.CommandType, cnn, null, param == null ? null : param.GetType(), null); var identity = new Identity(command.CommandText, command.CommandType, cnn, null, param == null ? null : param.GetType(), null);
var info = GetCacheInfo(identity, param); var info = GetCacheInfo(identity, param, command.AddToCache);
bool wasClosed = cnn.State == ConnectionState.Closed; bool wasClosed = cnn.State == ConnectionState.Closed;
using (var cmd = (DbCommand)command.SetupCommand(cnn, info.ParamReader)) using (var cmd = (DbCommand)command.SetupCommand(cnn, info.ParamReader))
{ {
...@@ -390,7 +390,7 @@ private static async Task<int> ExecuteImplAsync(IDbConnection cnn, CommandDefini ...@@ -390,7 +390,7 @@ private static async Task<int> ExecuteImplAsync(IDbConnection cnn, CommandDefini
{ {
object param = command.Parameters; object param = command.Parameters;
var identity = new Identity(command.CommandText, command.CommandType, cnn, typeof(TFirst), param == null ? null : param.GetType(), new[] { typeof(TFirst), typeof(TSecond), typeof(TThird), typeof(TFourth), typeof(TFifth), typeof(TSixth), typeof(TSeventh) }); var identity = new Identity(command.CommandText, command.CommandType, cnn, typeof(TFirst), param == null ? null : param.GetType(), new[] { typeof(TFirst), typeof(TSecond), typeof(TThird), typeof(TFourth), typeof(TFifth), typeof(TSixth), typeof(TSeventh) });
var info = GetCacheInfo(identity, param); var info = GetCacheInfo(identity, param, command.AddToCache);
bool wasClosed = cnn.State == ConnectionState.Closed; bool wasClosed = cnn.State == ConnectionState.Closed;
try try
{ {
...@@ -407,14 +407,14 @@ private static async Task<int> ExecuteImplAsync(IDbConnection cnn, CommandDefini ...@@ -407,14 +407,14 @@ private static async Task<int> ExecuteImplAsync(IDbConnection cnn, CommandDefini
} }
} }
private static IEnumerable<T> ExecuteReader<T>(IDataReader reader, Type effectiveType, Identity identity, CacheInfo info) private static IEnumerable<T> ExecuteReader<T>(IDataReader reader, Type effectiveType, Identity identity, CacheInfo info, bool addToCache)
{ {
var tuple = info.Deserializer; var tuple = info.Deserializer;
int hash = GetColumnHash(reader); int hash = GetColumnHash(reader);
if (tuple.Func == null || tuple.Hash != hash) if (tuple.Func == null || tuple.Hash != hash)
{ {
tuple = info.Deserializer = new DeserializerState(hash, GetDeserializer(effectiveType, reader, 0, -1, false)); tuple = info.Deserializer = new DeserializerState(hash, GetDeserializer(effectiveType, reader, 0, -1, false));
SetQueryCache(identity, info); if(addToCache) SetQueryCache(identity, info);
} }
var func = tuple.Func; var func = tuple.Func;
...@@ -446,7 +446,7 @@ public static async Task<GridReader> QueryMultipleAsync(this IDbConnection cnn, ...@@ -446,7 +446,7 @@ public static async Task<GridReader> QueryMultipleAsync(this IDbConnection cnn,
{ {
object param = command.Parameters; object param = command.Parameters;
Identity identity = new Identity(command.CommandText, command.CommandType, cnn, typeof(GridReader), param == null ? null : param.GetType(), null); Identity identity = new Identity(command.CommandText, command.CommandType, cnn, typeof(GridReader), param == null ? null : param.GetType(), null);
CacheInfo info = GetCacheInfo(identity, param); CacheInfo info = GetCacheInfo(identity, param, command.AddToCache);
DbCommand cmd = null; DbCommand cmd = null;
IDataReader reader = null; IDataReader reader = null;
...@@ -546,5 +546,82 @@ private static async Task<IDataReader> ExecuteReaderImplAsync(IDbConnection cnn, ...@@ -546,5 +546,82 @@ private static async Task<IDataReader> ExecuteReaderImplAsync(IDbConnection cnn,
if (cmd != null) cmd.Dispose(); if (cmd != null) cmd.Dispose();
} }
} }
/// <summary>
/// Execute parameterized SQL that selects a single value
/// </summary>
/// <returns>The first cell selected</returns>
public static Task<object> ExecuteScalarAsync(
#if CSHARP30
this IDbConnection cnn, string sql, object param, IDbTransaction transaction, int? commandTimeout, CommandType? commandType
#else
this IDbConnection cnn, string sql, dynamic param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null
#endif
)
{
var command = new CommandDefinition(sql, (object)param, transaction, commandTimeout, commandType, CommandFlags.Buffered);
return ExecuteScalarImplAsync<object>(cnn, command);
}
/// <summary>
/// Execute parameterized SQL that selects a single value
/// </summary>
/// <returns>The first cell selected</returns>
public static Task<T> ExecuteScalarAsync<T>(
#if CSHARP30
this IDbConnection cnn, string sql, object param, IDbTransaction transaction, int? commandTimeout, CommandType? commandType
#else
this IDbConnection cnn, string sql, dynamic param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null
#endif
)
{
var command = new CommandDefinition(sql, (object)param, transaction, commandTimeout, commandType, CommandFlags.Buffered);
return ExecuteScalarImplAsync<T>(cnn, command);
}
/// <summary>
/// Execute parameterized SQL that selects a single value
/// </summary>
/// <returns>The first cell selected</returns>
public static Task<object> ExecuteScalarAsync(this IDbConnection cnn, CommandDefinition command)
{
return ExecuteScalarImplAsync<object>(cnn, command);
}
/// <summary>
/// Execute parameterized SQL that selects a single value
/// </summary>
/// <returns>The first cell selected</returns>
public static Task<T> ExecuteScalarAsync<T>(this IDbConnection cnn, CommandDefinition command)
{
return ExecuteScalarImplAsync<T>(cnn, command);
}
private async static Task<T> ExecuteScalarImplAsync<T>(IDbConnection cnn, CommandDefinition command)
{
Action<IDbCommand, object> paramReader = null;
object param = command.Parameters;
if (param != null)
{
var identity = new Identity(command.CommandText, command.CommandType, cnn, null, param.GetType(), null);
paramReader = GetCacheInfo(identity, command.Parameters, command.AddToCache).ParamReader;
}
DbCommand cmd = null;
bool wasClosed = cnn.State == ConnectionState.Closed;
object result;
try
{
cmd = (DbCommand)command.SetupCommand(cnn, paramReader);
if (wasClosed) await ((DbConnection)cnn).OpenAsync().ConfigureAwait(false);
result = await cmd.ExecuteScalarAsync(command.CancellationToken).ConfigureAwait(false);
}
finally
{
if (wasClosed) cnn.Close();
if (cmd != null) cmd.Dispose();
}
return Parse<T>(result);
}
} }
} }
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{302EC82F-A81B-48C5-B653-B5C75D2BD103}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Dapper.Contrib</RootNamespace>
<AssemblyName>Dapper.Contrib</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</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>
<DocumentationFile>bin\Debug\Dapper.Contrib.XML</DocumentationFile>
</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>
<DocumentationFile>bin\Release\Dapper.Contrib.XML</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<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="..\Dapper.Contrib\Properties\AssemblyInfo.cs">
<Link>AssemblyInfo.cs</Link>
</Compile>
<Compile Include="..\Dapper.Contrib\SqlMapperExtensions.cs">
<Link>SqlMapperExtensions.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Dapper NET45\Dapper NET45.csproj">
<Project>{0fff5bc7-0a4b-4d87-835e-4fad70937507}</Project>
<Name>Dapper NET45</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.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>
\ No newline at end of file
...@@ -31,5 +31,5 @@ ...@@ -31,5 +31,5 @@
// //
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
[assembly: AssemblyVersion("1.27.0.0")] [assembly: AssemblyVersion("1.28.0.0")]
[assembly: AssemblyFileVersion("1.27.0.0")] [assembly: AssemblyFileVersion("1.28.0.0")]
<?xml version="1.0"?> <?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"> <package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata> <metadata>
<id>Dapper.Contrib</id> <id>Dapper.Contrib</id>
<version>1.1</version> <version>1.1</version>
<authors>Sam Saffron,Johan Danforth</authors> <authors>Sam Saffron,Johan Danforth</authors>
<owners>Sam Saffron,Johan Danforth</owners> <owners>Sam Saffron,Johan Danforth</owners>
<licenseUrl>http://www.apache.org/licenses/LICENSE-2.0</licenseUrl> <licenseUrl>http://www.apache.org/licenses/LICENSE-2.0</licenseUrl>
<projectUrl>http://code.google.com/p/dapper-dot-net/</projectUrl> <projectUrl>http://code.google.com/p/dapper-dot-net/</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance> <requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>A collection of create,insert,update,delete helpers for dapper.net</description> <description>A collection of create,insert,update,delete helpers for dapper.net</description>
<tags>orm sql micro-orm</tags> <tags>orm sql micro-orm</tags>
<dependencies> <dependencies>
<dependency id="Dapper" /> <dependency id="Dapper" version="1.27" />
</dependencies> </dependencies>
<frameworkAssemblies> <frameworkAssemblies>
<frameworkAssembly assemblyName="System.Core" targetFramework=".NETFramework4.0-Client, .NETFramework4.0" /> <frameworkAssembly assemblyName="System.Core" targetFramework=".NETFramework4.0-Client, .NETFramework4.0" />
<frameworkAssembly assemblyName="System" targetFramework=".NETFramework4.0-Client, .NETFramework4.0" /> <frameworkAssembly assemblyName="System" targetFramework=".NETFramework4.0-Client, .NETFramework4.0" />
<frameworkAssembly assemblyName="System.Data" targetFramework=".NETFramework4.0-Client, .NETFramework4.0" /> <frameworkAssembly assemblyName="System.Data" targetFramework=".NETFramework4.0-Client, .NETFramework4.0" />
<frameworkAssembly assemblyName="Microsoft.CSharp" targetFramework=".NETFramework4.0-Client, .NETFramework4.0" /> <frameworkAssembly assemblyName="Microsoft.CSharp" targetFramework=".NETFramework4.0-Client, .NETFramework4.0" />
</frameworkAssemblies> </frameworkAssemblies>
</metadata> </metadata>
<files> <files>
<file src="SqlMapperExtensions.cs" target="content\Dapper\SqlMapperExtensions.cs" /> <file src="Dapper.Contrib NET45\bin\Release\Dapper.Contrib.*" target="lib\net45" />
</files> <file src="Dapper.Contrib\bin\Release\Dapper.Contrib.*" target="lib\net40" />
</files>
</package> </package>
\ No newline at end of file
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Debug\Dapper.Contrib.XML</DocumentationFile>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
...@@ -37,6 +38,7 @@ ...@@ -37,6 +38,7 @@
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Release\Dapper.Contrib.XML</DocumentationFile>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />
...@@ -51,9 +53,6 @@ ...@@ -51,9 +53,6 @@
<Compile Include="SqlMapperExtensions.cs" /> <Compile Include="SqlMapperExtensions.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Include="Dapper.Contrib.nuspec" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Dapper NET40\Dapper NET40.csproj"> <ProjectReference Include="..\Dapper NET40\Dapper NET40.csproj">
<Project>{daf737e1-05b5-4189-a5aa-dac6233b64d7}</Project> <Project>{daf737e1-05b5-4189-a5aa-dac6233b64d7}</Project>
......
...@@ -31,5 +31,5 @@ ...@@ -31,5 +31,5 @@
// //
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
[assembly: AssemblyVersion("1.27.0.0")] [assembly: AssemblyVersion("1.28.0.0")]
[assembly: AssemblyFileVersion("1.27.0.0")] [assembly: AssemblyFileVersion("1.28.0.0")]
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using Dapper; using Dapper;
#pragma warning disable 1573, 1591 // xml comments
namespace Dapper.Contrib.Extensions namespace Dapper.Contrib.Extensions
{ {
...@@ -240,7 +242,8 @@ private static string GetTableName(Type type) ...@@ -240,7 +242,8 @@ private static string GetTableName(Type type)
sb.AppendFormat("update {0} set ", name); sb.AppendFormat("update {0} set ", name);
var allProperties = TypePropertiesCache(type); var allProperties = TypePropertiesCache(type);
var nonIdProps = allProperties.Where(a => !keyProperties.Contains(a)); var computedProperties = ComputedPropertiesCache(type);
var nonIdProps = allProperties.Except(keyProperties.Union(computedProperties));
for (var i = 0; i < nonIdProps.Count(); i++) for (var i = 0; i < nonIdProps.Count(); i++)
{ {
......
...@@ -31,5 +31,5 @@ ...@@ -31,5 +31,5 @@
// //
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
[assembly: AssemblyVersion("1.27.0.0")] [assembly: AssemblyVersion("1.28.0.0")]
[assembly: AssemblyFileVersion("1.27.0.0")] [assembly: AssemblyFileVersion("1.28.0.0")]
...@@ -14,6 +14,7 @@ class Clause ...@@ -14,6 +14,7 @@ class Clause
{ {
public string Sql { get; set; } public string Sql { get; set; }
public object Parameters { get; set; } public object Parameters { get; set; }
public bool IsInclusive { get; set; }
} }
class Clauses : List<Clause> class Clauses : List<Clause>
...@@ -35,7 +36,18 @@ public string ResolveClauses(DynamicParameters p) ...@@ -35,7 +36,18 @@ public string ResolveClauses(DynamicParameters p)
{ {
p.AddDynamicParams(item.Parameters); p.AddDynamicParams(item.Parameters);
} }
return prefix + string.Join(joiner, this.Select(c => c.Sql)) + postfix; return this.Any(a => a.IsInclusive)
? prefix +
string.Join(joiner,
this.Where(a => !a.IsInclusive)
.Select(c => c.Sql)
.Union(new[]
{
" ( " +
string.Join(" OR ", this.Where(a => a.IsInclusive).Select(c => c.Sql).ToArray()) +
" ) "
})) + postfix
: prefix + string.Join(joiner, this.Select(c => c.Sql)) + postfix;
} }
} }
...@@ -94,7 +106,7 @@ public Template AddTemplate(string sql, dynamic parameters = null) ...@@ -94,7 +106,7 @@ public Template AddTemplate(string sql, dynamic parameters = null)
return new Template(this, sql, parameters); return new Template(this, sql, parameters);
} }
void AddClause(string name, string sql, object parameters, string joiner, string prefix = "", string postfix = "") void AddClause(string name, string sql, object parameters, string joiner, string prefix = "", string postfix = "", bool IsInclusive = false)
{ {
Clauses clauses; Clauses clauses;
if (!data.TryGetValue(name, out clauses)) if (!data.TryGetValue(name, out clauses))
...@@ -106,6 +118,12 @@ void AddClause(string name, string sql, object parameters, string joiner, string ...@@ -106,6 +118,12 @@ void AddClause(string name, string sql, object parameters, string joiner, string
seq++; seq++;
} }
public SqlBuilder Intersect(string sql, dynamic parameters = null)
{
AddClause("intersect", sql, parameters, joiner: "\nINTERSECT\n ", prefix: "\n ", postfix: "\n");
return this;
}
public SqlBuilder InnerJoin(string sql, dynamic parameters = null) public SqlBuilder InnerJoin(string sql, dynamic parameters = null)
{ {
AddClause("innerjoin", sql, parameters, joiner: "\nINNER JOIN ", prefix: "\nINNER JOIN ", postfix: "\n"); AddClause("innerjoin", sql, parameters, joiner: "\nINNER JOIN ", prefix: "\nINNER JOIN ", postfix: "\n");
...@@ -130,6 +148,12 @@ public SqlBuilder Where(string sql, dynamic parameters = null) ...@@ -130,6 +148,12 @@ public SqlBuilder Where(string sql, dynamic parameters = null)
return this; return this;
} }
public SqlBuilder OrWhere(string sql, dynamic parameters = null)
{
AddClause("where", sql, parameters, " AND ", prefix: "WHERE ", postfix: "\n", IsInclusive: true);
return this;
}
public SqlBuilder OrderBy(string sql, dynamic parameters = null) public SqlBuilder OrderBy(string sql, dynamic parameters = null)
{ {
AddClause("orderby", sql, parameters, " , ", prefix: "ORDER BY ", postfix: "\n"); AddClause("orderby", sql, parameters, " , ", prefix: "ORDER BY ", postfix: "\n");
......
...@@ -31,5 +31,5 @@ ...@@ -31,5 +31,5 @@
// //
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
[assembly: AssemblyVersion("1.27.0.0")] [assembly: AssemblyVersion("1.28.0.0")]
[assembly: AssemblyFileVersion("1.27.0.0")] [assembly: AssemblyFileVersion("1.28.0.0")]
...@@ -17,12 +17,14 @@ public void TestBasicStringUsage() ...@@ -17,12 +17,14 @@ public void TestBasicStringUsage()
} }
public void TestClassWithStringUsage() public void TestClassWithStringUsage()
{ {
var arr = connection.Query<BasicType>("select 'abc' as [Value] union all select @txt", new { txt = "def" }).ToArray(); var arr = connection.Query<BasicType>("select 'abc' as [Value], '123' as [Another_Value] union all select @txt, @txt2", new { txt = "def", txt2 = "456" }).ToArray();
arr.Select(x => x.Value).IsSequenceEqualTo(new[] { "abc", "def" }); arr.Select(x => x.Value).IsSequenceEqualTo(new[] { "abc", "def" });
arr.Select(x => x.AnotherValue).IsSequenceEqualTo(new[] { "123", "456" });
} }
class BasicType class BasicType
{ {
public string Value { get; set; } public string Value { get; set; }
public string AnotherValue { get; set; }
} }
public void TestDynamicSimulatedQuery() { public void TestDynamicSimulatedQuery() {
......
...@@ -31,5 +31,5 @@ ...@@ -31,5 +31,5 @@
// //
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
[assembly: AssemblyVersion("1.27.0.0")] [assembly: AssemblyVersion("1.28.0.0")]
[assembly: AssemblyFileVersion("1.27.0.0")] [assembly: AssemblyFileVersion("1.28.0.0")]
...@@ -292,5 +292,26 @@ public class SomeType ...@@ -292,5 +292,26 @@ public class SomeType
public int A { get; set; } public int A { get; set; }
public string B { get; set; } public string B { get; set; }
} }
public void Issue22_ExecuteScalar()
{
using (var connection = Program.GetOpenConnection())
{
int i = connection.ExecuteScalarAsync<int>("select 123").Result;
i.IsEqualTo(123);
i = connection.ExecuteScalarAsync<int>("select cast(123 as bigint)").Result;
i.IsEqualTo(123);
long j = connection.ExecuteScalarAsync<long>("select 123").Result;
j.IsEqualTo(123L);
j = connection.ExecuteScalarAsync<long>("select cast(123 as bigint)").Result;
j.IsEqualTo(123L);
int? k = connection.ExecuteScalar<int?>("select @i", new { i = default(int?) });
k.IsNull();
}
}
} }
} }
\ No newline at end of file
...@@ -352,6 +352,6 @@ Who is using this? ...@@ -352,6 +352,6 @@ Who is using this?
--------------------- ---------------------
Dapper is in production use at: Dapper is in production use at:
[Stack Overflow](http://stackoverflow.com/), [xpfest.com](http://www.xapfest.com/), [helpdesk](http://www.jitbit.com/helpdesk-software/) [Stack Overflow](http://stackoverflow.com/), [helpdesk](http://www.jitbit.com/helpdesk-software/)
(if you would like to be listed here let me know) (if you would like to be listed here let me know)
...@@ -128,7 +128,7 @@ public void Run(int iterations) ...@@ -128,7 +128,7 @@ public void Run(int iterations)
// dapper.contrib // dapper.contrib
var mapperConnection3 = Program.GetOpenConnection(); var mapperConnection3 = Program.GetOpenConnection();
tests.Add(id => mapperConnection2.Get<Post>(id), "Dapper.Cotrib"); tests.Add(id => mapperConnection3.Get<Post>(id), "Dapper.Cotrib");
var massiveModel = new DynamicModel(Program.ConnectionString); var massiveModel = new DynamicModel(Program.ConnectionString);
var massiveConnection = Program.GetOpenConnection(); var massiveConnection = Program.GetOpenConnection();
......
...@@ -31,5 +31,5 @@ ...@@ -31,5 +31,5 @@
// //
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
[assembly: AssemblyVersion("1.27.0.0")] [assembly: AssemblyVersion("1.28.0.0")]
[assembly: AssemblyFileVersion("1.27.0.0")] [assembly: AssemblyFileVersion("1.28.0.0")]
This diff is collapsed.
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"> <package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata schemaVersion="2"> <metadata schemaVersion="2">
<id>Dapper</id> <id>Dapper</id>
<version>1.27</version> <version>1.28</version>
<title>Dapper dot net</title> <title>Dapper dot net</title>
<authors>Sam Saffron,Marc Gravell</authors> <authors>Sam Saffron,Marc Gravell</authors>
<owners>Sam Saffron,Marc Gravell</owners> <owners>Sam Saffron,Marc Gravell</owners>
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
<frameworkAssembly assemblyName="Microsoft.CSharp" targetFramework=".NETFramework4.0-Client, .NETFramework4.0" /> <frameworkAssembly assemblyName="Microsoft.CSharp" targetFramework=".NETFramework4.0-Client, .NETFramework4.0" />
</frameworkAssemblies> </frameworkAssemblies>
<releaseNotes> <releaseNotes>
* 1.28 - Much better numeric type conversion; fix for large oracle strings; map Foo_Bar to FooBar (etc); ExecuteScalar added; stability fixes
* 1.27 - Fixes for type-handler parse; ensure type-handlers get last dibs on configuring parameters * 1.27 - Fixes for type-handler parse; ensure type-handlers get last dibs on configuring parameters
* 1.26 - New type handler API for extension support * 1.26 - New type handler API for extension support
* 1.25 - Command recycling and disposing during pipelined async multi-exec; enable pipeline (via sync-over-async) for sync API * 1.25 - Command recycling and disposing during pipelined async multi-exec; enable pipeline (via sync-over-async) for sync API
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment