Commit 5576a3ed authored by Marc Gravell's avatar Marc Gravell

The "SqlMapper.cs is too damned big" file split; also removes C#3 support and...

The "SqlMapper.cs is too damned big" file split; also removes C#3 support and .NET 3.5 support (sorry, but legacy by too many years)
parent 7f22bff5
<?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>{02BA5431-EBE0-4E06-A01C-71C1A0D74379}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Dapper</RootNamespace>
<AssemblyName>Dapper</AssemblyName>
<TargetFrameworkVersion>v3.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>TRACE;DEBUG;CSHARP30</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>3</LangVersion>
<DocumentationFile>bin\Debug\Dapper.xml</DocumentationFile>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE;CSHARP30</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>3</LangVersion>
<DocumentationFile>bin\Release\Dapper.xml</DocumentationFile>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>..\Dapper.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.XML" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\Dapper NET40\Properties\AssemblyInfo.cs">
<Link>AssemblyInfo.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.cs">
<Link>SqlMapper.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</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
<?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>{B26305D8-3A89-4D68-A981-9BBF378B81FA}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Dapper</RootNamespace>
<AssemblyName>Dapper</AssemblyName>
<TargetFrameworkVersion>v3.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>TRACE;DEBUG;CSHARP30</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>3</LangVersion>
<DocumentationFile>bin\Debug\Dapper.xml</DocumentationFile>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE;CSHARP30</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>3</LangVersion>
<DocumentationFile>bin\Release\Dapper.xml</DocumentationFile>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.XML" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\Dapper NET40\Properties\AssemblyInfo.cs">
<Link>AssemblyInfo.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.cs">
<Link>SqlMapper.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</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
......@@ -51,12 +51,129 @@
<Reference Include="System.XML" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\Dapper NET40\CommandDefinition.cs">
<Link>CommandDefinition.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\CommandFlags.cs">
<Link>CommandFlags.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\CustomPropertyTypeMap.cs">
<Link>CustomPropertyTypeMap.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\DataTableHandler.cs">
<Link>DataTableHandler.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\DbString.cs">
<Link>DbString.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\DefaultTypeMap.cs">
<Link>DefaultTypeMap.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\DynamicParameters.CachedOutputSetters.cs">
<Link>DynamicParameters.CachedOutputSetters.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\DynamicParameters.cs">
<Link>DynamicParameters.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\DynamicParameters.ParamInfo.cs">
<Link>DynamicParameters.ParamInfo.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\ExplicitConstructorAttribute.cs">
<Link>ExplicitConstructorAttribute.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\FeatureSupport.cs">
<Link>FeatureSupport.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\Properties\AssemblyInfo.cs">
<Link>AssemblyInfo.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SimpleMemberMap.cs">
<Link>SimpleMemberMap.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlDataRecordHandler.cs">
<Link>SqlDataRecordHandler.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlDataRecordListTVPParameter.cs">
<Link>SqlDataRecordListTVPParameter.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.CacheInfo.cs">
<Link>SqlMapper.CacheInfo.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.cs">
<Link>SqlMapper.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.DapperRow.cs">
<Link>SqlMapper.DapperRow.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.DapperRowMetaObject.cs">
<Link>SqlMapper.DapperRowMetaObject.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.DataTable.cs">
<Link>SqlMapper.DataTable.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.DeserializerState.cs">
<Link>SqlMapper.DeserializerState.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.DontMap.cs">
<Link>SqlMapper.DontMap.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.GridReader.cs">
<Link>SqlMapper.GridReader.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.ICustomQueryParameter.cs">
<Link>SqlMapper.ICustomQueryParameter.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.Identity.cs">
<Link>SqlMapper.Identity.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.IDynamicParameters.cs">
<Link>SqlMapper.IDynamicParameters.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.IMemberMap.cs">
<Link>SqlMapper.IMemberMap.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.IParameterCallbacks.cs">
<Link>SqlMapper.IParameterCallbacks.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.IParameterLookup.cs">
<Link>SqlMapper.IParameterLookup.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.ITypeHandler.cs">
<Link>SqlMapper.ITypeHandler.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.ITypeMap.cs">
<Link>SqlMapper.ITypeMap.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.Link.cs">
<Link>SqlMapper.Link.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.LiteralToken.cs">
<Link>SqlMapper.LiteralToken.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.Settings.cs">
<Link>SqlMapper.Settings.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.TypeHandler.cs">
<Link>SqlMapper.TypeHandler.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.TypeHandlerCache.cs">
<Link>SqlMapper.TypeHandlerCache.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\TableValuedParameter.cs">
<Link>TableValuedParameter.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\TypeExtensions.cs">
<Link>TypeExtensions.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\UdtTypeHandler.cs">
<Link>UdtTypeHandler.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\WrappedDataReader.cs">
<Link>WrappedDataReader.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\WrappedReader.cs">
<Link>WrappedReader.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
......
using System;
using System.Data;
using System.Reflection;
using System.Reflection.Emit;
using System.Threading;
#if DNXCORE50
using IDbDataParameter = global::System.Data.Common.DbParameter;
using IDataParameter = global::System.Data.Common.DbParameter;
using IDbTransaction = global::System.Data.Common.DbTransaction;
using IDbConnection = global::System.Data.Common.DbConnection;
using IDbCommand = global::System.Data.Common.DbCommand;
using IDataReader = global::System.Data.Common.DbDataReader;
using IDataRecord = global::System.Data.Common.DbDataReader;
using IDataParameterCollection = global::System.Data.Common.DbParameterCollection;
using DataException = global::System.InvalidOperationException;
using ApplicationException = global::System.InvalidOperationException;
#endif
namespace Dapper
{ /// <summary>
/// Represents the key aspects of a sql operation
/// </summary>
public struct CommandDefinition
{
internal static CommandDefinition ForCallback(object parameters)
{
if (parameters is DynamicParameters)
{
return new CommandDefinition(parameters);
}
else
{
return default(CommandDefinition);
}
}
private readonly string commandText;
private readonly object parameters;
private readonly IDbTransaction transaction;
private readonly int? commandTimeout;
private readonly CommandType? commandType;
private readonly CommandFlags flags;
internal void OnCompleted()
{
if (parameters is SqlMapper.IParameterCallbacks)
{
((SqlMapper.IParameterCallbacks)parameters).OnCompleted();
}
}
/// <summary>
/// The command (sql or a stored-procedure name) to execute
/// </summary>
public string CommandText { get { return commandText; } }
/// <summary>
/// The parameters associated with the command
/// </summary>
public object Parameters { get { return parameters; } }
/// <summary>
/// The active transaction for the command
/// </summary>
public IDbTransaction Transaction { get { return transaction; } }
/// <summary>
/// The effective timeout for the command
/// </summary>
public int? CommandTimeout { get { return commandTimeout; } }
/// <summary>
/// The type of command that the command-text represents
/// </summary>
public CommandType? CommandType { get { return commandType; } }
/// <summary>
/// Should data be buffered before returning?
/// </summary>
public bool Buffered { get { return (flags & CommandFlags.Buffered) != 0; } }
/// <summary>
/// Should the plan for this query be cached?
/// </summary>
internal bool AddToCache { get { return (flags & CommandFlags.NoCache) == 0; } }
/// <summary>
/// Additional state flags against this command
/// </summary>
public CommandFlags Flags { get { return flags; } }
/// <summary>
/// Can async queries be pipelined?
/// </summary>
public bool Pipelined { get { return (flags & CommandFlags.Pipelined) != 0; } }
/// <summary>
/// Initialize the command definition
/// </summary>
public CommandDefinition(string commandText, object parameters = null, IDbTransaction transaction = null, int? commandTimeout = null,
CommandType? commandType = null, CommandFlags flags = CommandFlags.Buffered
#if ASYNC
, CancellationToken cancellationToken = default(CancellationToken)
#endif
)
{
this.commandText = commandText;
this.parameters = parameters;
this.transaction = transaction;
this.commandTimeout = commandTimeout;
this.commandType = commandType;
this.flags = flags;
#if ASYNC
this.cancellationToken = cancellationToken;
#endif
}
private CommandDefinition(object parameters) : this()
{
this.parameters = parameters;
}
#if ASYNC
private readonly CancellationToken cancellationToken;
/// <summary>
/// For asynchronous operations, the cancellation-token
/// </summary>
public CancellationToken CancellationToken { get { return cancellationToken; } }
#endif
internal IDbCommand SetupCommand(IDbConnection cnn, Action<IDbCommand, object> paramReader)
{
var cmd = cnn.CreateCommand();
var init = GetInit(cmd.GetType());
if (init != null) init(cmd);
if (transaction != null)
cmd.Transaction = transaction;
cmd.CommandText = commandText;
if (commandTimeout.HasValue)
{
cmd.CommandTimeout = commandTimeout.Value;
}
else if (SqlMapper.Settings.CommandTimeout.HasValue)
{
cmd.CommandTimeout = SqlMapper.Settings.CommandTimeout.Value;
}
if (commandType.HasValue)
cmd.CommandType = commandType.Value;
if (paramReader != null)
{
paramReader(cmd, parameters);
}
return cmd;
}
static SqlMapper.Link<Type, Action<IDbCommand>> commandInitCache;
static Action<IDbCommand> GetInit(Type commandType)
{
if (commandType == null) return null; // GIGO
Action<IDbCommand> action;
if (SqlMapper.Link<Type, Action<IDbCommand>>.TryGet(commandInitCache, commandType, out action))
{
return action;
}
var bindByName = GetBasicPropertySetter(commandType, "BindByName", typeof(bool));
var initialLongFetchSize = GetBasicPropertySetter(commandType, "InitialLONGFetchSize", typeof(int));
action = null;
if (bindByName != null || initialLongFetchSize != null)
{
var method = new DynamicMethod(commandType.Name + "_init", null, new Type[] { typeof(IDbCommand) });
var il = method.GetILGenerator();
if (bindByName != null)
{
// .BindByName = true
il.Emit(OpCodes.Ldarg_0);
il.Emit(OpCodes.Castclass, commandType);
il.Emit(OpCodes.Ldc_I4_1);
il.EmitCall(OpCodes.Callvirt, bindByName, null);
}
if (initialLongFetchSize != null)
{
// .InitialLONGFetchSize = -1
il.Emit(OpCodes.Ldarg_0);
il.Emit(OpCodes.Castclass, commandType);
il.Emit(OpCodes.Ldc_I4_M1);
il.EmitCall(OpCodes.Callvirt, initialLongFetchSize, null);
}
il.Emit(OpCodes.Ret);
action = (Action<IDbCommand>)method.CreateDelegate(typeof(Action<IDbCommand>));
}
// cache it
SqlMapper.Link<Type, Action<IDbCommand>>.TryAdd(ref commandInitCache, commandType, ref action);
return action;
}
static MethodInfo GetBasicPropertySetter(Type declaringType, string name, Type expectedType)
{
var prop = declaringType.GetProperty(name, BindingFlags.Public | BindingFlags.Instance);
ParameterInfo[] indexers;
if (prop != null && prop.CanWrite && prop.PropertyType == expectedType
&& ((indexers = prop.GetIndexParameters()) == null || indexers.Length == 0))
{
return prop.GetSetMethod();
}
return null;
}
}
}
using System;
namespace Dapper
{
/// <summary>
/// Additional state flags that control command behaviour
/// </summary>
[Flags]
public enum CommandFlags
{
/// <summary>
/// No additional flags
/// </summary>
None = 0,
/// <summary>
/// Should data be buffered before returning?
/// </summary>
Buffered = 1,
/// <summary>
/// Can async queries be pipelined?
/// </summary>
Pipelined = 2,
/// <summary>
/// Should the plan cache be bypassed?
/// </summary>
NoCache = 4,
}
}
using System;
using System.Reflection;
namespace Dapper
{
/// <summary>
/// Implements custom property mapping by user provided criteria (usually presence of some custom attribute with column to member mapping)
/// </summary>
public sealed class CustomPropertyTypeMap : SqlMapper.ITypeMap
{
private readonly Type _type;
private readonly Func<Type, string, PropertyInfo> _propertySelector;
/// <summary>
/// Creates custom property mapping
/// </summary>
/// <param name="type">Target entity type</param>
/// <param name="propertySelector">Property selector based on target type and DataReader column name</param>
public CustomPropertyTypeMap(Type type, Func<Type, string, PropertyInfo> propertySelector)
{
if (type == null)
throw new ArgumentNullException("type");
if (propertySelector == null)
throw new ArgumentNullException("propertySelector");
_type = type;
_propertySelector = propertySelector;
}
/// <summary>
/// Always returns default constructor
/// </summary>
/// <param name="names">DataReader column names</param>
/// <param name="types">DataReader column types</param>
/// <returns>Default constructor</returns>
public ConstructorInfo FindConstructor(string[] names, Type[] types)
{
return _type.GetConstructor(new Type[0]);
}
/// <summary>
/// Always returns null
/// </summary>
/// <returns></returns>
public ConstructorInfo FindExplicitConstructor()
{
return null;
}
/// <summary>
/// Not implemented as far as default constructor used for all cases
/// </summary>
/// <param name="constructor"></param>
/// <param name="columnName"></param>
/// <returns></returns>
public SqlMapper.IMemberMap GetConstructorParameter(ConstructorInfo constructor, string columnName)
{
throw new NotSupportedException();
}
/// <summary>
/// Returns property based on selector strategy
/// </summary>
/// <param name="columnName">DataReader column name</param>
/// <returns>Poperty member map</returns>
public SqlMapper.IMemberMap GetMember(string columnName)
{
var prop = _propertySelector(_type, columnName);
return prop != null ? new SimpleMemberMap(columnName, prop) : null;
}
}
}
......@@ -45,8 +45,91 @@
<Reference Include="System.XML" />
</ItemGroup>
<ItemGroup>
<Compile Include="CommandDefinition.cs" />
<Compile Include="CommandFlags.cs" />
<Compile Include="CustomPropertyTypeMap.cs" />
<Compile Include="DataTableHandler.cs" />
<Compile Include="DbString.cs" />
<Compile Include="DefaultTypeMap.cs" />
<Compile Include="DynamicParameters.cs" />
<Compile Include="ExplicitConstructorAttribute.cs" />
<Compile Include="FeatureSupport.cs" />
<Compile Include="SimpleMemberMap.cs" />
<Compile Include="SqlDataRecordHandler.cs" />
<Compile Include="SqlDataRecordListTVPParameter.cs" />
<Compile Include="SqlMapper.CacheInfo.cs">
<DependentUpon>SqlMapper.cs</DependentUpon>
</Compile>
<Compile Include="SqlMapper.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SqlMapper.DapperRow.cs">
<DependentUpon>SqlMapper.cs</DependentUpon>
</Compile>
<Compile Include="SqlMapper.DataTable.cs">
<DependentUpon>SqlMapper.cs</DependentUpon>
</Compile>
<Compile Include="SqlMapper.DeserializerState.cs">
<DependentUpon>SqlMapper.cs</DependentUpon>
</Compile>
<Compile Include="SqlMapper.DontMap.cs">
<DependentUpon>SqlMapper.cs</DependentUpon>
</Compile>
<Compile Include="SqlMapper.GridReader.cs">
<DependentUpon>SqlMapper.cs</DependentUpon>
</Compile>
<Compile Include="SqlMapper.IDynamicParameters.cs">
<DependentUpon>SqlMapper.cs</DependentUpon>
</Compile>
<Compile Include="SqlMapper.IMemberMap.cs">
<DependentUpon>SqlMapper.cs</DependentUpon>
</Compile>
<Compile Include="SqlMapper.IParameterLookup.cs">
<DependentUpon>SqlMapper.cs</DependentUpon>
</Compile>
<Compile Include="SqlMapper.ITypeHandler.cs">
<DependentUpon>SqlMapper.cs</DependentUpon>
</Compile>
<Compile Include="SqlMapper.ITypeMap.cs">
<DependentUpon>SqlMapper.cs</DependentUpon>
</Compile>
<Compile Include="SqlMapper.Link.cs">
<DependentUpon>SqlMapper.cs</DependentUpon>
</Compile>
<Compile Include="SqlMapper.LiteralToken.cs">
<DependentUpon>SqlMapper.cs</DependentUpon>
</Compile>
<Compile Include="SqlMapper.Settings.cs">
<DependentUpon>SqlMapper.cs</DependentUpon>
</Compile>
<Compile Include="TableValuedParameter.cs" />
<Compile Include="TypeExtensions.cs" />
<Compile Include="SqlMapper.TypeHandler.cs">
<DependentUpon>SqlMapper.cs</DependentUpon>
</Compile>
<Compile Include="UdtTypeHandler.cs" />
<Compile Include="WrappedDataReader.cs" />
<Compile Include="WrappedReader.cs" />
<Compile Include="SqlMapper.ICustomQueryParameter.cs">
<DependentUpon>SqlMapper.cs</DependentUpon>
</Compile>
<Compile Include="SqlMapper.IParameterCallbacks.cs">
<DependentUpon>SqlMapper.cs</DependentUpon>
</Compile>
<Compile Include="DynamicParameters.ParamInfo.cs">
<DependentUpon>DynamicParameters.cs</DependentUpon>
</Compile>
<Compile Include="DynamicParameters.CachedOutputSetters.cs">
<DependentUpon>DynamicParameters.cs</DependentUpon>
</Compile>
<Compile Include="SqlMapper.DapperRowMetaObject.cs">
<DependentUpon>SqlMapper.cs</DependentUpon>
</Compile>
<Compile Include="SqlMapper.Identity.cs">
<DependentUpon>SqlMapper.cs</DependentUpon>
</Compile>
<Compile Include="SqlMapper.TypeHandlerCache.cs">
<DependentUpon>SqlMapper.cs</DependentUpon>
</Compile>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
......
using System;
using System.Data;
#if !DNXCORE50
namespace Dapper
{
sealed class DataTableHandler : Dapper.SqlMapper.ITypeHandler
{
public object Parse(Type destinationType, object value)
{
throw new NotImplementedException();
}
public void SetValue(IDbDataParameter parameter, object value)
{
TableValuedParameter.Set(parameter, value as DataTable, null);
}
}
}
#endif
\ No newline at end of file
using System;
using System.Data;
#if DNXCORE50
using IDbDataParameter = global::System.Data.Common.DbParameter;
using IDataParameter = global::System.Data.Common.DbParameter;
using IDbTransaction = global::System.Data.Common.DbTransaction;
using IDbConnection = global::System.Data.Common.DbConnection;
using IDbCommand = global::System.Data.Common.DbCommand;
using IDataReader = global::System.Data.Common.DbDataReader;
using IDataRecord = global::System.Data.Common.DbDataReader;
using IDataParameterCollection = global::System.Data.Common.DbParameterCollection;
using DataException = global::System.InvalidOperationException;
using ApplicationException = global::System.InvalidOperationException;
#endif
namespace Dapper
{
/// <summary>
/// This class represents a SQL string, it can be used if you need to denote your parameter is a Char vs VarChar vs nVarChar vs nChar
/// </summary>
public sealed class DbString : Dapper.SqlMapper.ICustomQueryParameter
{
/// <summary>
/// Default value for IsAnsi.
/// </summary>
public static bool IsAnsiDefault { get; set; }
/// <summary>
/// A value to set the default value of strings
/// going through Dapper. Default is 4000, any value larger than this
/// field will not have the default value applied.
/// </summary>
public const int DefaultLength = 4000;
/// <summary>
/// Create a new DbString
/// </summary>
public DbString()
{
Length = -1;
IsAnsi = IsAnsiDefault;
}
/// <summary>
/// Ansi vs Unicode
/// </summary>
public bool IsAnsi { get; set; }
/// <summary>
/// Fixed length
/// </summary>
public bool IsFixedLength { get; set; }
/// <summary>
/// Length of the string -1 for max
/// </summary>
public int Length { get; set; }
/// <summary>
/// The value of the string
/// </summary>
public string Value { get; set; }
/// <summary>
/// Add the parameter to the command... internal use only
/// </summary>
/// <param name="command"></param>
/// <param name="name"></param>
public void AddParameter(IDbCommand command, string name)
{
if (IsFixedLength && Length == -1)
{
throw new InvalidOperationException("If specifying IsFixedLength, a Length must also be specified");
}
var param = command.CreateParameter();
param.ParameterName = name;
param.Value = SqlMapper.SanitizeParameterValue(Value);
if (Length == -1 && Value != null && Value.Length <= DefaultLength)
{
param.Size = DefaultLength;
}
else
{
param.Size = Length;
}
param.DbType = IsAnsi ? (IsFixedLength ? DbType.AnsiStringFixedLength : DbType.AnsiString) : (IsFixedLength ? DbType.StringFixedLength : DbType.String);
command.Parameters.Add(param);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
namespace Dapper
{
/// <summary>
/// Represents default type mapping strategy used by Dapper
/// </summary>
sealed class DefaultTypeMap : SqlMapper.ITypeMap
{
private readonly List<FieldInfo> _fields;
private readonly List<PropertyInfo> _properties;
private readonly Type _type;
/// <summary>
/// Creates default type map
/// </summary>
/// <param name="type">Entity type</param>
public DefaultTypeMap(Type type)
{
if (type == null)
throw new ArgumentNullException("type");
_fields = GetSettableFields(type);
_properties = GetSettableProps(type);
_type = type;
}
#if DNXCORE50
static bool IsParameterMatch(ParameterInfo[] x, ParameterInfo[] y)
{
if (ReferenceEquals(x, y)) return true;
if (x == null || y == null) return false;
if (x.Length != y.Length) return false;
for (int i = 0; i < x.Length; i++)
if (x[i].ParameterType != y[i].ParameterType) return false;
return true;
}
#endif
internal static MethodInfo GetPropertySetter(PropertyInfo propertyInfo, Type type)
{
if (propertyInfo.DeclaringType == type) return propertyInfo.GetSetMethod(true);
#if DNXCORE50
return propertyInfo.DeclaringType.GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)
.Single(x => x.Name == propertyInfo.Name
&& x.PropertyType == propertyInfo.PropertyType
&& IsParameterMatch(x.GetIndexParameters(), propertyInfo.GetIndexParameters())
).GetSetMethod(true);
#else
return propertyInfo.DeclaringType.GetProperty(
propertyInfo.Name,
BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance,
Type.DefaultBinder,
propertyInfo.PropertyType,
propertyInfo.GetIndexParameters().Select(p => p.ParameterType).ToArray(),
null).GetSetMethod(true);
#endif
}
internal static List<PropertyInfo> GetSettableProps(Type t)
{
return t
.GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)
.Where(p => GetPropertySetter(p, t) != null)
.ToList();
}
internal static List<FieldInfo> GetSettableFields(Type t)
{
return t.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance).ToList();
}
/// <summary>
/// Finds best constructor
/// </summary>
/// <param name="names">DataReader column names</param>
/// <param name="types">DataReader column types</param>
/// <returns>Matching constructor or default one</returns>
public ConstructorInfo FindConstructor(string[] names, Type[] types)
{
var constructors = _type.GetConstructors(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
foreach (ConstructorInfo ctor in constructors.OrderBy(c => c.IsPublic ? 0 : (c.IsPrivate ? 2 : 1)).ThenBy(c => c.GetParameters().Length))
{
ParameterInfo[] ctorParameters = ctor.GetParameters();
if (ctorParameters.Length == 0)
return ctor;
if (ctorParameters.Length != types.Length)
continue;
int i = 0;
for (; i < ctorParameters.Length; i++)
{
if (!String.Equals(ctorParameters[i].Name, names[i], StringComparison.OrdinalIgnoreCase))
break;
if (types[i] == typeof(byte[]) && ctorParameters[i].ParameterType.FullName == SqlMapper.LinqBinary)
continue;
var unboxedType = Nullable.GetUnderlyingType(ctorParameters[i].ParameterType) ?? ctorParameters[i].ParameterType;
if (unboxedType != types[i]
&& !(unboxedType.IsEnum() && Enum.GetUnderlyingType(unboxedType) == types[i])
&& !(unboxedType == typeof(char) && types[i] == typeof(string))
&& !(unboxedType.IsEnum() && types[i] == typeof(string)))
{
break;
}
}
if (i == ctorParameters.Length)
return ctor;
}
return null;
}
/// <summary>
/// Returns the constructor, if any, that has the ExplicitConstructorAttribute on it.
/// </summary>
public ConstructorInfo FindExplicitConstructor()
{
var constructors = _type.GetConstructors(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
#if DNXCORE50
var withAttr = constructors.Where(c => c.CustomAttributes.Any(x => x.AttributeType == typeof(ExplicitConstructorAttribute))).ToList();
#else
var withAttr = constructors.Where(c => c.GetCustomAttributes(typeof(ExplicitConstructorAttribute), true).Length > 0).ToList();
#endif
if (withAttr.Count == 1)
{
return withAttr[0];
}
return null;
}
/// <summary>
/// Gets mapping for constructor parameter
/// </summary>
/// <param name="constructor">Constructor to resolve</param>
/// <param name="columnName">DataReader column name</param>
/// <returns>Mapping implementation</returns>
public SqlMapper.IMemberMap GetConstructorParameter(ConstructorInfo constructor, string columnName)
{
var parameters = constructor.GetParameters();
return new SimpleMemberMap(columnName, parameters.FirstOrDefault(p => string.Equals(p.Name, columnName, StringComparison.OrdinalIgnoreCase)));
}
/// <summary>
/// Gets member mapping for column
/// </summary>
/// <param name="columnName">DataReader column name</param>
/// <returns>Mapping implementation</returns>
public SqlMapper.IMemberMap GetMember(string columnName)
{
var property = Properties.FirstOrDefault(p => string.Equals(p.Name, columnName, StringComparison.Ordinal))
?? Properties.FirstOrDefault(p => string.Equals(p.Name, columnName, StringComparison.OrdinalIgnoreCase));
if (property == null && MatchNamesWithUnderscores)
{
property = Properties.FirstOrDefault(p => string.Equals(p.Name, columnName.Replace("_", ""), StringComparison.Ordinal))
?? Properties.FirstOrDefault(p => string.Equals(p.Name, columnName.Replace("_", ""), StringComparison.OrdinalIgnoreCase));
}
if (property != null)
return new SimpleMemberMap(columnName, property);
var field = _fields.FirstOrDefault(p => string.Equals(p.Name, columnName, StringComparison.Ordinal))
?? _fields.FirstOrDefault(p => string.Equals(p.Name, columnName, StringComparison.OrdinalIgnoreCase));
if (field == null && MatchNamesWithUnderscores)
{
field = _fields.FirstOrDefault(p => string.Equals(p.Name, columnName.Replace("_", ""), StringComparison.Ordinal))
?? _fields.FirstOrDefault(p => string.Equals(p.Name, columnName.Replace("_", ""), StringComparison.OrdinalIgnoreCase));
}
if (field != null)
return new SimpleMemberMap(columnName, field);
return null;
}
/// <summary>
/// Should column names like User_Id be allowed to match properties/fields like UserId ?
/// </summary>
public static bool MatchNamesWithUnderscores { get; set; }
public List<PropertyInfo> Properties
{
get
{
return _properties;
}
}
}
}
using System;
using System.Collections;
using System.Collections.Generic;
#if DNXCORE50
using IDbDataParameter = global::System.Data.Common.DbParameter;
using IDataParameter = global::System.Data.Common.DbParameter;
using IDbTransaction = global::System.Data.Common.DbTransaction;
using IDbConnection = global::System.Data.Common.DbConnection;
using IDbCommand = global::System.Data.Common.DbCommand;
using IDataReader = global::System.Data.Common.DbDataReader;
using IDataRecord = global::System.Data.Common.DbDataReader;
using IDataParameterCollection = global::System.Data.Common.DbParameterCollection;
using DataException = global::System.InvalidOperationException;
using ApplicationException = global::System.InvalidOperationException;
#endif
namespace Dapper
{
partial class DynamicParameters
{
internal static class CachedOutputSetters<T>
{
#if DNXCORE50
public static readonly Dictionary<string, Action<object, DynamicParameters>> Cache = new Dictionary<string, Action<object, DynamicParameters>>();
#else
public static readonly Hashtable Cache = new Hashtable();
#endif
}
}
}
using System;
using System.Data;
#if DNXCORE50
using IDbDataParameter = global::System.Data.Common.DbParameter;
using IDataParameter = global::System.Data.Common.DbParameter;
using IDbTransaction = global::System.Data.Common.DbTransaction;
using IDbConnection = global::System.Data.Common.DbConnection;
using IDbCommand = global::System.Data.Common.DbCommand;
using IDataReader = global::System.Data.Common.DbDataReader;
using IDataRecord = global::System.Data.Common.DbDataReader;
using IDataParameterCollection = global::System.Data.Common.DbParameterCollection;
using DataException = global::System.InvalidOperationException;
using ApplicationException = global::System.InvalidOperationException;
#endif
namespace Dapper
{
partial class DynamicParameters
{
sealed class ParamInfo
{
public string Name { get; set; }
public object Value { get; set; }
public ParameterDirection ParameterDirection { get; set; }
public DbType? DbType { get; set; }
public int? Size { get; set; }
public IDbDataParameter AttachedParam { get; set; }
internal Action<object, DynamicParameters> OutputCallback { get; set; }
internal object OutputTarget { get; set; }
internal bool CameFromTemplate { get; set; }
public byte? Precision { get; set; }
public byte? Scale { get; set; }
}
}
}
This diff is collapsed.
using System;
namespace Dapper
{
/// <summary>
/// Tell Dapper to use an explicit constructor, passing nulls or 0s for all parameters
/// </summary>
[AttributeUsage(AttributeTargets.Constructor, AllowMultiple = false)]
public sealed class ExplicitConstructorAttribute : Attribute
{
}
}
using System;
using System.Data;
#if DNXCORE50
using IDbDataParameter = global::System.Data.Common.DbParameter;
using IDataParameter = global::System.Data.Common.DbParameter;
using IDbTransaction = global::System.Data.Common.DbTransaction;
using IDbConnection = global::System.Data.Common.DbConnection;
using IDbCommand = global::System.Data.Common.DbCommand;
using IDataReader = global::System.Data.Common.DbDataReader;
using IDataRecord = global::System.Data.Common.DbDataReader;
using IDataParameterCollection = global::System.Data.Common.DbParameterCollection;
using DataException = global::System.InvalidOperationException;
using ApplicationException = global::System.InvalidOperationException;
#endif
namespace Dapper
{
/// <summary>
/// Handles variances in features per DBMS
/// </summary>
class FeatureSupport
{
private static readonly FeatureSupport
@default = new FeatureSupport(false),
postgres = new FeatureSupport(true);
/// <summary>
/// Gets the feature set based on the passed connection
/// </summary>
public static FeatureSupport Get(IDbConnection connection)
{
string name = connection == null ? null : connection.GetType().Name;
if (string.Equals(name, "npgsqlconnection", StringComparison.OrdinalIgnoreCase)) return postgres;
return @default;
}
private FeatureSupport(bool arrays)
{
Arrays = arrays;
}
/// <summary>
/// True if the db supports array columns e.g. Postgresql
/// </summary>
public bool Arrays { get; private set; }
}
}
using System;
using System.Reflection;
namespace Dapper
{
/// <summary>
/// Represents simple member map for one of target parameter or property or field to source DataReader column
/// </summary>
sealed class SimpleMemberMap : SqlMapper.IMemberMap
{
private readonly string _columnName;
private readonly PropertyInfo _property;
private readonly FieldInfo _field;
private readonly ParameterInfo _parameter;
/// <summary>
/// Creates instance for simple property mapping
/// </summary>
/// <param name="columnName">DataReader column name</param>
/// <param name="property">Target property</param>
public SimpleMemberMap(string columnName, PropertyInfo property)
{
if (columnName == null)
throw new ArgumentNullException("columnName");
if (property == null)
throw new ArgumentNullException("property");
_columnName = columnName;
_property = property;
}
/// <summary>
/// Creates instance for simple field mapping
/// </summary>
/// <param name="columnName">DataReader column name</param>
/// <param name="field">Target property</param>
public SimpleMemberMap(string columnName, FieldInfo field)
{
if (columnName == null)
throw new ArgumentNullException("columnName");
if (field == null)
throw new ArgumentNullException("field");
_columnName = columnName;
_field = field;
}
/// <summary>
/// Creates instance for simple constructor parameter mapping
/// </summary>
/// <param name="columnName">DataReader column name</param>
/// <param name="parameter">Target constructor parameter</param>
public SimpleMemberMap(string columnName, ParameterInfo parameter)
{
if (columnName == null)
throw new ArgumentNullException("columnName");
if (parameter == null)
throw new ArgumentNullException("parameter");
_columnName = columnName;
_parameter = parameter;
}
/// <summary>
/// DataReader column name
/// </summary>
public string ColumnName
{
get { return _columnName; }
}
/// <summary>
/// Target member type
/// </summary>
public Type MemberType
{
get
{
if (_field != null)
return _field.FieldType;
if (_property != null)
return _property.PropertyType;
if (_parameter != null)
return _parameter.ParameterType;
return null;
}
}
/// <summary>
/// Target property
/// </summary>
public PropertyInfo Property
{
get { return _property; }
}
/// <summary>
/// Target field
/// </summary>
public FieldInfo Field
{
get { return _field; }
}
/// <summary>
/// Target constructor parameter
/// </summary>
public ParameterInfo Parameter
{
get { return _parameter; }
}
}
}
using System;
using System.Collections.Generic;
using System.Data;
#if !DNXCORE50
namespace Dapper
{
sealed class SqlDataRecordHandler : Dapper.SqlMapper.ITypeHandler
{
public object Parse(Type destinationType, object value)
{
throw new NotSupportedException();
}
public void SetValue(IDbDataParameter parameter, object value)
{
SqlDataRecordListTVPParameter.Set(parameter, value as IEnumerable<Microsoft.SqlServer.Server.SqlDataRecord>, null);
}
}
}
#endif
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Data;
using System.Reflection;
#if !DNXCORE50
namespace Dapper
{
/// <summary>
/// Used to pass a IEnumerable&lt;SqlDataRecord&gt; as a SqlDataRecordListTVPParameter
/// </summary>
sealed class SqlDataRecordListTVPParameter : Dapper.SqlMapper.ICustomQueryParameter
{
private readonly IEnumerable<Microsoft.SqlServer.Server.SqlDataRecord> data;
private readonly string typeName;
/// <summary>
/// Create a new instance of SqlDataRecordListTVPParameter
/// </summary>
public SqlDataRecordListTVPParameter(IEnumerable<Microsoft.SqlServer.Server.SqlDataRecord> data, string typeName)
{
this.data = data;
this.typeName = typeName;
}
static readonly Action<System.Data.SqlClient.SqlParameter, string> setTypeName;
static SqlDataRecordListTVPParameter()
{
var prop = typeof(System.Data.SqlClient.SqlParameter).GetProperty("TypeName", BindingFlags.Instance | BindingFlags.Public);
if (prop != null && prop.PropertyType == typeof(string) && prop.CanWrite)
{
setTypeName = (Action<System.Data.SqlClient.SqlParameter, string>)
Delegate.CreateDelegate(typeof(Action<System.Data.SqlClient.SqlParameter, string>), prop.GetSetMethod());
}
}
void SqlMapper.ICustomQueryParameter.AddParameter(IDbCommand command, string name)
{
var param = command.CreateParameter();
param.ParameterName = name;
Set(param, data, typeName);
command.Parameters.Add(param);
}
internal static void Set(IDbDataParameter parameter, IEnumerable<Microsoft.SqlServer.Server.SqlDataRecord> data, string typeName)
{
parameter.Value = (object)data ?? DBNull.Value;
var sqlParam = parameter as System.Data.SqlClient.SqlParameter;
if (sqlParam != null)
{
sqlParam.SqlDbType = SqlDbType.Structured;
sqlParam.TypeName = typeName;
}
}
}
}
#endif
\ No newline at end of file
using System;
using System.Data;
using System.Threading;
#if DNXCORE50
using IDbDataParameter = global::System.Data.Common.DbParameter;
using IDataParameter = global::System.Data.Common.DbParameter;
using IDbTransaction = global::System.Data.Common.DbTransaction;
using IDbConnection = global::System.Data.Common.DbConnection;
using IDbCommand = global::System.Data.Common.DbCommand;
using IDataReader = global::System.Data.Common.DbDataReader;
using IDataRecord = global::System.Data.Common.DbDataReader;
using IDataParameterCollection = global::System.Data.Common.DbParameterCollection;
using DataException = global::System.InvalidOperationException;
using ApplicationException = global::System.InvalidOperationException;
#endif
namespace Dapper
{
partial class SqlMapper
{
class CacheInfo
{
public DeserializerState Deserializer { get; set; }
public Func<IDataReader, object>[] OtherDeserializers { get; set; }
public Action<IDbCommand, object> ParamReader { get; set; }
private int hitCount;
public int GetHitCount() { return Interlocked.CompareExchange(ref hitCount, 0, 0); }
public void RecordHit() { Interlocked.Increment(ref hitCount); }
}
}
}
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
namespace Dapper
{
partial class SqlMapper
{
private sealed class DapperRow
: System.Dynamic.IDynamicMetaObjectProvider
, IDictionary<string, object>
{
readonly DapperTable table;
object[] values;
public DapperRow(DapperTable table, object[] values)
{
if (table == null) throw new ArgumentNullException("table");
if (values == null) throw new ArgumentNullException("values");
this.table = table;
this.values = values;
}
private sealed class DeadValue
{
public static readonly DeadValue Default = new DeadValue();
private DeadValue() { }
}
int ICollection<KeyValuePair<string, object>>.Count
{
get
{
int count = 0;
for (int i = 0; i < values.Length; i++)
{
if (!(values[i] is DeadValue)) count++;
}
return count;
}
}
public bool TryGetValue(string name, out object value)
{
var index = table.IndexOfName(name);
if (index < 0)
{ // doesn't exist
value = null;
return false;
}
// exists, **even if** we don't have a value; consider table rows heterogeneous
value = index < values.Length ? values[index] : null;
if (value is DeadValue)
{ // pretend it isn't here
value = null;
return false;
}
return true;
}
public override string ToString()
{
var sb = GetStringBuilder().Append("{DapperRow");
foreach (var kv in this)
{
var value = kv.Value;
sb.Append(", ").Append(kv.Key);
if (value != null)
{
sb.Append(" = '").Append(kv.Value).Append('\'');
}
else
{
sb.Append(" = NULL");
}
}
return sb.Append('}').__ToStringRecycle();
}
System.Dynamic.DynamicMetaObject System.Dynamic.IDynamicMetaObjectProvider.GetMetaObject(
System.Linq.Expressions.Expression parameter)
{
return new DapperRowMetaObject(parameter, System.Dynamic.BindingRestrictions.Empty, this);
}
public IEnumerator<KeyValuePair<string, object>> GetEnumerator()
{
var names = table.FieldNames;
for (var i = 0; i < names.Length; i++)
{
object value = i < values.Length ? values[i] : null;
if (!(value is DeadValue))
{
yield return new KeyValuePair<string, object>(names[i], value);
}
}
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
#region Implementation of ICollection<KeyValuePair<string,object>>
void ICollection<KeyValuePair<string, object>>.Add(KeyValuePair<string, object> item)
{
IDictionary<string, object> dic = this;
dic.Add(item.Key, item.Value);
}
void ICollection<KeyValuePair<string, object>>.Clear()
{ // removes values for **this row**, but doesn't change the fundamental table
for (int i = 0; i < values.Length; i++)
values[i] = DeadValue.Default;
}
bool ICollection<KeyValuePair<string, object>>.Contains(KeyValuePair<string, object> item)
{
object value;
return TryGetValue(item.Key, out value) && Equals(value, item.Value);
}
void ICollection<KeyValuePair<string, object>>.CopyTo(KeyValuePair<string, object>[] array, int arrayIndex)
{
foreach (var kv in this)
{
array[arrayIndex++] = kv; // if they didn't leave enough space; not our fault
}
}
bool ICollection<KeyValuePair<string, object>>.Remove(KeyValuePair<string, object> item)
{
IDictionary<string, object> dic = this;
return dic.Remove(item.Key);
}
bool ICollection<KeyValuePair<string, object>>.IsReadOnly
{
get { return false; }
}
#endregion
#region Implementation of IDictionary<string,object>
bool IDictionary<string, object>.ContainsKey(string key)
{
int index = table.IndexOfName(key);
if (index < 0 || index >= values.Length || values[index] is DeadValue) return false;
return true;
}
void IDictionary<string, object>.Add(string key, object value)
{
SetValue(key, value, true);
}
bool IDictionary<string, object>.Remove(string key)
{
int index = table.IndexOfName(key);
if (index < 0 || index >= values.Length || values[index] is DeadValue) return false;
values[index] = DeadValue.Default;
return true;
}
object IDictionary<string, object>.this[string key]
{
get { object val; TryGetValue(key, out val); return val; }
set { SetValue(key, value, false); }
}
public object SetValue(string key, object value)
{
return SetValue(key, value, false);
}
private object SetValue(string key, object value, bool isAdd)
{
if (key == null) throw new ArgumentNullException("key");
int index = table.IndexOfName(key);
if (index < 0)
{
index = table.AddField(key);
}
else if (isAdd && index < values.Length && !(values[index] is DeadValue))
{
// then semantically, this value already exists
throw new ArgumentException("An item with the same key has already been added", "key");
}
int oldLength = values.Length;
if (oldLength <= index)
{
// we'll assume they're doing lots of things, and
// grow it to the full width of the table
Array.Resize(ref values, table.FieldCount);
for (int i = oldLength; i < values.Length; i++)
{
values[i] = DeadValue.Default;
}
}
return values[index] = value;
}
ICollection<string> IDictionary<string, object>.Keys
{
get { return this.Select(kv => kv.Key).ToArray(); }
}
ICollection<object> IDictionary<string, object>.Values
{
get { return this.Select(kv => kv.Value).ToArray(); }
}
#endregion
}
}
}
using System;
using System.Collections.Generic;
using System.Reflection;
namespace Dapper
{
partial class SqlMapper
{
sealed class DapperRowMetaObject : System.Dynamic.DynamicMetaObject
{
static readonly MethodInfo getValueMethod = typeof(IDictionary<string, object>).GetProperty("Item").GetGetMethod();
static readonly MethodInfo setValueMethod = typeof(DapperRow).GetMethod("SetValue", new Type[] { typeof(string), typeof(object) });
public DapperRowMetaObject(
System.Linq.Expressions.Expression expression,
System.Dynamic.BindingRestrictions restrictions
)
: base(expression, restrictions)
{
}
public DapperRowMetaObject(
System.Linq.Expressions.Expression expression,
System.Dynamic.BindingRestrictions restrictions,
object value
)
: base(expression, restrictions, value)
{
}
System.Dynamic.DynamicMetaObject CallMethod(
MethodInfo method,
System.Linq.Expressions.Expression[] parameters
)
{
var callMethod = new System.Dynamic.DynamicMetaObject(
System.Linq.Expressions.Expression.Call(
System.Linq.Expressions.Expression.Convert(Expression, LimitType),
method,
parameters),
System.Dynamic.BindingRestrictions.GetTypeRestriction(Expression, LimitType)
);
return callMethod;
}
public override System.Dynamic.DynamicMetaObject BindGetMember(System.Dynamic.GetMemberBinder binder)
{
var parameters = new System.Linq.Expressions.Expression[]
{
System.Linq.Expressions.Expression.Constant(binder.Name)
};
var callMethod = CallMethod(getValueMethod, parameters);
return callMethod;
}
// Needed for Visual basic dynamic support
public override System.Dynamic.DynamicMetaObject BindInvokeMember(System.Dynamic.InvokeMemberBinder binder, System.Dynamic.DynamicMetaObject[] args)
{
var parameters = new System.Linq.Expressions.Expression[]
{
System.Linq.Expressions.Expression.Constant(binder.Name)
};
var callMethod = CallMethod(getValueMethod, parameters);
return callMethod;
}
public override System.Dynamic.DynamicMetaObject BindSetMember(System.Dynamic.SetMemberBinder binder, System.Dynamic.DynamicMetaObject value)
{
var parameters = new System.Linq.Expressions.Expression[]
{
System.Linq.Expressions.Expression.Constant(binder.Name),
value.Expression,
};
var callMethod = CallMethod(setValueMethod, parameters);
return callMethod;
}
}
}
}
using System;
using System.Collections.Generic;
namespace Dapper
{
partial class SqlMapper
{
private sealed class DapperTable
{
string[] fieldNames;
readonly Dictionary<string, int> fieldNameLookup;
internal string[] FieldNames { get { return fieldNames; } }
public DapperTable(string[] fieldNames)
{
if (fieldNames == null) throw new ArgumentNullException("fieldNames");
this.fieldNames = fieldNames;
fieldNameLookup = new Dictionary<string, int>(fieldNames.Length, StringComparer.Ordinal);
// if there are dups, we want the **first** key to be the "winner" - so iterate backwards
for (int i = fieldNames.Length - 1; i >= 0; i--)
{
string key = fieldNames[i];
if (key != null) fieldNameLookup[key] = i;
}
}
internal int IndexOfName(string name)
{
int result;
return (name != null && fieldNameLookup.TryGetValue(name, out result)) ? result : -1;
}
internal int AddField(string name)
{
if (name == null) throw new ArgumentNullException("name");
if (fieldNameLookup.ContainsKey(name)) throw new InvalidOperationException("Field already exists: " + name);
int oldLen = fieldNames.Length;
Array.Resize(ref fieldNames, oldLen + 1); // yes, this is sub-optimal, but this is not the expected common case
fieldNames[oldLen] = name;
fieldNameLookup[name] = oldLen;
return oldLen;
}
internal bool FieldExists(string key)
{
return key != null && fieldNameLookup.ContainsKey(key);
}
public int FieldCount { get { return fieldNames.Length; } }
}
}
}
using System;
using System.Data;
#if DNXCORE50
using IDbDataParameter = global::System.Data.Common.DbParameter;
using IDataParameter = global::System.Data.Common.DbParameter;
using IDbTransaction = global::System.Data.Common.DbTransaction;
using IDbConnection = global::System.Data.Common.DbConnection;
using IDbCommand = global::System.Data.Common.DbCommand;
using IDataReader = global::System.Data.Common.DbDataReader;
using IDataRecord = global::System.Data.Common.DbDataReader;
using IDataParameterCollection = global::System.Data.Common.DbParameterCollection;
using DataException = global::System.InvalidOperationException;
using ApplicationException = global::System.InvalidOperationException;
#endif
namespace Dapper
{
partial class SqlMapper
{
struct DeserializerState
{
public readonly int Hash;
public readonly Func<IDataReader, object> Func;
public DeserializerState(int hash, Func<IDataReader, object> func)
{
Hash = hash;
Func = func;
}
}
}
}
namespace Dapper
{
partial class SqlMapper
{
/// <summary>
/// Dummy type for excluding from multi-map
/// </summary>
class DontMap { }
}
}
This diff is collapsed.
using System.Data;
#if DNXCORE50
using IDbDataParameter = global::System.Data.Common.DbParameter;
using IDataParameter = global::System.Data.Common.DbParameter;
using IDbTransaction = global::System.Data.Common.DbTransaction;
using IDbConnection = global::System.Data.Common.DbConnection;
using IDbCommand = global::System.Data.Common.DbCommand;
using IDataReader = global::System.Data.Common.DbDataReader;
using IDataRecord = global::System.Data.Common.DbDataReader;
using IDataParameterCollection = global::System.Data.Common.DbParameterCollection;
using DataException = global::System.InvalidOperationException;
using ApplicationException = global::System.InvalidOperationException;
#endif
namespace Dapper
{
partial class SqlMapper
{
/// <summary>
/// Implement this interface to pass an arbitrary db specific parameter to Dapper
/// </summary>
public interface ICustomQueryParameter
{
/// <summary>
/// Add the parameter needed to the command before it executes
/// </summary>
/// <param name="command">The raw command prior to execution</param>
/// <param name="name">Parameter name</param>
void AddParameter(IDbCommand command, string name);
}
}
}
using System.Data;
#if DNXCORE50
using IDbDataParameter = global::System.Data.Common.DbParameter;
using IDataParameter = global::System.Data.Common.DbParameter;
using IDbTransaction = global::System.Data.Common.DbTransaction;
using IDbConnection = global::System.Data.Common.DbConnection;
using IDbCommand = global::System.Data.Common.DbCommand;
using IDataReader = global::System.Data.Common.DbDataReader;
using IDataRecord = global::System.Data.Common.DbDataReader;
using IDataParameterCollection = global::System.Data.Common.DbParameterCollection;
using DataException = global::System.InvalidOperationException;
using ApplicationException = global::System.InvalidOperationException;
#endif
namespace Dapper
{
partial class SqlMapper
{
/// <summary>
/// Implement this interface to pass an arbitrary db specific set of parameters to Dapper
/// </summary>
public interface IDynamicParameters
{
/// <summary>
/// Add all the parameters needed to the command just before it executes
/// </summary>
/// <param name="command">The raw command prior to execution</param>
/// <param name="identity">Information about the query</param>
void AddParameters(IDbCommand command, Identity identity);
}
}
}
using System;
using System.Reflection;
namespace Dapper
{
partial class SqlMapper
{
/// <summary>
/// Implements this interface to provide custom member mapping
/// </summary>
public interface IMemberMap
{
/// <summary>
/// Source DataReader column name
/// </summary>
string ColumnName { get; }
/// <summary>
/// Target member type
/// </summary>
Type MemberType { get; }
/// <summary>
/// Target property
/// </summary>
PropertyInfo Property { get; }
/// <summary>
/// Target field
/// </summary>
FieldInfo Field { get; }
/// <summary>
/// Target constructor parameter
/// </summary>
ParameterInfo Parameter { get; }
}
}
}
namespace Dapper
{
partial class SqlMapper
{
/// <summary>
/// Extends IDynamicParameters with facilities for executing callbacks after commands have completed
/// </summary>
public interface IParameterCallbacks : IDynamicParameters
{
/// <summary>
/// Invoked when the command has executed
/// </summary>
void OnCompleted();
}
}
}
namespace Dapper
{
partial class SqlMapper
{
/// <summary>
/// Extends IDynamicParameters providing by-name lookup of parameter values
/// </summary>
public interface IParameterLookup : IDynamicParameters
{
/// <summary>
/// Get the value of the specified parameter (return null if not found)
/// </summary>
object this[string name] { get; }
}
}
}
using System;
using System.Data;
#if DNXCORE50
using IDbDataParameter = global::System.Data.Common.DbParameter;
using IDataParameter = global::System.Data.Common.DbParameter;
using IDbTransaction = global::System.Data.Common.DbTransaction;
using IDbConnection = global::System.Data.Common.DbConnection;
using IDbCommand = global::System.Data.Common.DbCommand;
using IDataReader = global::System.Data.Common.DbDataReader;
using IDataRecord = global::System.Data.Common.DbDataReader;
using IDataParameterCollection = global::System.Data.Common.DbParameterCollection;
using DataException = global::System.InvalidOperationException;
using ApplicationException = global::System.InvalidOperationException;
#endif
namespace Dapper
{
partial class SqlMapper
{
/// <summary>
/// Implement this interface to perform custom type-based parameter handling and value parsing
/// </summary>
public interface ITypeHandler
{
/// <summary>
/// Assign the value of a parameter before a command executes
/// </summary>
/// <param name="parameter">The parameter to configure</param>
/// <param name="value">Parameter value</param>
void SetValue(IDbDataParameter parameter, object value);
/// <summary>
/// Parse a database value back to a typed value
/// </summary>
/// <param name="value">The value from the database</param>
/// <param name="destinationType">The type to parse to</param>
/// <returns>The typed value</returns>
object Parse(Type destinationType, object value);
}
}
}
using System;
using System.Reflection;
namespace Dapper
{
partial class SqlMapper
{
/// <summary>
/// Implement this interface to change default mapping of reader columns to type members
/// </summary>
public interface ITypeMap
{
/// <summary>
/// Finds best constructor
/// </summary>
/// <param name="names">DataReader column names</param>
/// <param name="types">DataReader column types</param>
/// <returns>Matching constructor or default one</returns>
ConstructorInfo FindConstructor(string[] names, Type[] types);
/// <summary>
/// Returns a constructor which should *always* be used.
///
/// Parameters will be default values, nulls for reference types and zero'd for value types.
///
/// Use this class to force object creation away from parameterless constructors you don't control.
/// </summary>
ConstructorInfo FindExplicitConstructor();
/// <summary>
/// Gets mapping for constructor parameter
/// </summary>
/// <param name="constructor">Constructor to resolve</param>
/// <param name="columnName">DataReader column name</param>
/// <returns>Mapping implementation</returns>
IMemberMap GetConstructorParameter(ConstructorInfo constructor, string columnName);
/// <summary>
/// Gets member mapping for column
/// </summary>
/// <param name="columnName">DataReader column name</param>
/// <returns>Mapping implementation</returns>
IMemberMap GetMember(string columnName);
}
}
}
using System;
using System.Data;
#if DNXCORE50
using IDbDataParameter = global::System.Data.Common.DbParameter;
using IDataParameter = global::System.Data.Common.DbParameter;
using IDbTransaction = global::System.Data.Common.DbTransaction;
using IDbConnection = global::System.Data.Common.DbConnection;
using IDbCommand = global::System.Data.Common.DbCommand;
using IDataReader = global::System.Data.Common.DbDataReader;
using IDataRecord = global::System.Data.Common.DbDataReader;
using IDataParameterCollection = global::System.Data.Common.DbParameterCollection;
using DataException = global::System.InvalidOperationException;
using ApplicationException = global::System.InvalidOperationException;
#endif
namespace Dapper
{
partial class SqlMapper
{
/// <summary>
/// Identity of a cached query in Dapper, used for extensibility
/// </summary>
public class Identity : IEquatable<Identity>
{
internal Identity ForGrid(Type primaryType, int gridIndex)
{
return new Identity(sql, commandType, connectionString, primaryType, parametersType, null, gridIndex);
}
internal Identity ForGrid(Type primaryType, Type[] otherTypes, int gridIndex)
{
return new Identity(sql, commandType, connectionString, primaryType, parametersType, otherTypes, gridIndex);
}
/// <summary>
/// Create an identity for use with DynamicParameters, internal use only
/// </summary>
/// <param name="type"></param>
/// <returns></returns>
public Identity ForDynamicParameters(Type type)
{
return new Identity(sql, commandType, connectionString, this.type, type, null, -1);
}
internal Identity(string sql, CommandType? commandType, IDbConnection connection, Type type, Type parametersType, Type[] otherTypes)
: this(sql, commandType, connection.ConnectionString, type, parametersType, otherTypes, 0)
{ }
private Identity(string sql, CommandType? commandType, string connectionString, Type type, Type parametersType, Type[] otherTypes, int gridIndex)
{
this.sql = sql;
this.commandType = commandType;
this.connectionString = connectionString;
this.type = type;
this.parametersType = parametersType;
this.gridIndex = gridIndex;
unchecked
{
hashCode = 17; // we *know* we are using this in a dictionary, so pre-compute this
hashCode = hashCode * 23 + commandType.GetHashCode();
hashCode = hashCode * 23 + gridIndex.GetHashCode();
hashCode = hashCode * 23 + (sql == null ? 0 : sql.GetHashCode());
hashCode = hashCode * 23 + (type == null ? 0 : type.GetHashCode());
if (otherTypes != null)
{
foreach (var t in otherTypes)
{
hashCode = hashCode * 23 + (t == null ? 0 : t.GetHashCode());
}
}
hashCode = hashCode * 23 + (connectionString == null ? 0 : SqlMapper.connectionStringComparer.GetHashCode(connectionString));
hashCode = hashCode * 23 + (parametersType == null ? 0 : parametersType.GetHashCode());
}
}
/// <summary>
///
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
public override bool Equals(object obj)
{
return Equals(obj as Identity);
}
/// <summary>
/// The sql
/// </summary>
public readonly string sql;
/// <summary>
/// The command type
/// </summary>
public readonly CommandType? commandType;
/// <summary>
///
/// </summary>
public readonly int hashCode, gridIndex;
/// <summary>
///
/// </summary>
public readonly Type type;
/// <summary>
///
/// </summary>
public readonly string connectionString;
/// <summary>
///
/// </summary>
public readonly Type parametersType;
/// <summary>
///
/// </summary>
/// <returns></returns>
public override int GetHashCode()
{
return hashCode;
}
/// <summary>
/// Compare 2 Identity objects
/// </summary>
/// <param name="other"></param>
/// <returns></returns>
public bool Equals(Identity other)
{
return
other != null &&
gridIndex == other.gridIndex &&
type == other.type &&
sql == other.sql &&
commandType == other.commandType &&
SqlMapper.connectionStringComparer.Equals(connectionString, other.connectionString) &&
parametersType == other.parametersType;
}
}
}
}
using System.Threading;
namespace Dapper
{
partial class SqlMapper
{
/// <summary>
/// This is a micro-cache; suitable when the number of terms is controllable (a few hundred, for example),
/// and strictly append-only; you cannot change existing values. All key matches are on **REFERENCE**
/// equality. The type is fully thread-safe.
/// </summary>
internal class Link<TKey, TValue> where TKey : class
{
public static bool TryGet(Link<TKey, TValue> link, TKey key, out TValue value)
{
while (link != null)
{
if ((object)key == (object)link.Key)
{
value = link.Value;
return true;
}
link = link.Tail;
}
value = default(TValue);
return false;
}
public static bool TryAdd(ref Link<TKey, TValue> head, TKey key, ref TValue value)
{
bool tryAgain;
do
{
var snapshot = Interlocked.CompareExchange(ref head, null, null);
TValue found;
if (TryGet(snapshot, key, out found))
{ // existing match; report the existing value instead
value = found;
return false;
}
var newNode = new Link<TKey, TValue>(key, value, snapshot);
// did somebody move our cheese?
tryAgain = Interlocked.CompareExchange(ref head, newNode, snapshot) != snapshot;
} while (tryAgain);
return true;
}
private Link(TKey key, TValue value, Link<TKey, TValue> tail)
{
Key = key;
Value = value;
Tail = tail;
}
public TKey Key { get; private set; }
public TValue Value { get; private set; }
public Link<TKey, TValue> Tail { get; private set; }
}
}
}
using System.Collections.Generic;
namespace Dapper
{
partial class SqlMapper
{
/// <summary>
/// Represents a placeholder for a value that should be replaced as a literal value in the resulting sql
/// </summary>
internal struct LiteralToken
{
private readonly string token, member;
/// <summary>
/// The text in the original command that should be replaced
/// </summary>
public string Token { get { return token; } }
/// <summary>
/// The name of the member referred to by the token
/// </summary>
public string Member { get { return member; } }
internal LiteralToken(string token, string member)
{
this.token = token;
this.member = member;
}
internal static readonly IList<LiteralToken> None = new LiteralToken[0];
}
}
}
namespace Dapper
{
partial class SqlMapper
{
/// <summary>
/// Permits specifying certain SqlMapper values globally.
/// </summary>
public static class Settings
{
static Settings()
{
SetDefaults();
}
/// <summary>
/// Resets all Settings to their default values
/// </summary>
public static void SetDefaults()
{
CommandTimeout = null;
}
/// <summary>
/// Specifies the default Command Timeout for all Queries
/// </summary>
public static int? CommandTimeout { get; set; }
}
}
}
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
#if DNXCORE50
using IDbDataParameter = global::System.Data.Common.DbParameter;
using IDataParameter = global::System.Data.Common.DbParameter;
using IDbTransaction = global::System.Data.Common.DbTransaction;
using IDbConnection = global::System.Data.Common.DbConnection;
using IDbCommand = global::System.Data.Common.DbCommand;
using IDataReader = global::System.Data.Common.DbDataReader;
using IDataRecord = global::System.Data.Common.DbDataReader;
using IDataParameterCollection = global::System.Data.Common.DbParameterCollection;
using DataException = global::System.InvalidOperationException;
using ApplicationException = global::System.InvalidOperationException;
#endif
namespace Dapper
{
partial class SqlMapper
{
/// <summary>
/// Base-class for simple type-handlers
/// </summary>
public abstract class TypeHandler<T> : ITypeHandler
{
/// <summary>
/// Assign the value of a parameter before a command executes
/// </summary>
/// <param name="parameter">The parameter to configure</param>
/// <param name="value">Parameter value</param>
public abstract void SetValue(IDbDataParameter parameter, T value);
/// <summary>
/// Parse a database value back to a typed value
/// </summary>
/// <param name="value">The value from the database</param>
/// <returns>The typed value</returns>
public abstract T Parse(object value);
void ITypeHandler.SetValue(IDbDataParameter parameter, object value)
{
if (value is DBNull)
{
parameter.Value = value;
}
else
{
SetValue(parameter, (T)value);
}
}
object ITypeHandler.Parse(Type destinationType, object value)
{
return Parse(value);
}
}
}
}
using System;
using System.ComponentModel;
using System.Data;
#if DNXCORE50
using IDbDataParameter = global::System.Data.Common.DbParameter;
using IDataParameter = global::System.Data.Common.DbParameter;
using IDbTransaction = global::System.Data.Common.DbTransaction;
using IDbConnection = global::System.Data.Common.DbConnection;
using IDbCommand = global::System.Data.Common.DbCommand;
using IDataReader = global::System.Data.Common.DbDataReader;
using IDataRecord = global::System.Data.Common.DbDataReader;
using IDataParameterCollection = global::System.Data.Common.DbParameterCollection;
using DataException = global::System.InvalidOperationException;
using ApplicationException = global::System.InvalidOperationException;
#endif
namespace Dapper
{
partial class SqlMapper
{
/// <summary>
/// Not intended for direct usage
/// </summary>
[Obsolete("Not intended for direct usage", false)]
#if !DNXCORE50
[Browsable(false)]
#endif
[EditorBrowsable(EditorBrowsableState.Never)]
public static class TypeHandlerCache<T>
{
/// <summary>
/// Not intended for direct usage
/// </summary>
[Obsolete("Not intended for direct usage", true)]
public static T Parse(object value)
{
return (T)handler.Parse(typeof(T), value);
}
/// <summary>
/// Not intended for direct usage
/// </summary>
[Obsolete("Not intended for direct usage", true)]
public static void SetValue(IDbDataParameter parameter, object value)
{
handler.SetValue(parameter, value);
}
internal static void SetHandler(ITypeHandler handler)
{
#pragma warning disable 618
TypeHandlerCache<T>.handler = handler;
#pragma warning restore 618
}
private static ITypeHandler handler;
}
}
}
This diff is collapsed.
using System;
using System.Data;
using System.Reflection;
#if !DNXCORE50
namespace Dapper
{
/// <summary>
/// Used to pass a DataTable as a TableValuedParameter
/// </summary>
sealed class TableValuedParameter : Dapper.SqlMapper.ICustomQueryParameter
{
private readonly DataTable table;
private readonly string typeName;
/// <summary>
/// Create a new instance of TableValuedParameter
/// </summary>
public TableValuedParameter(DataTable table) : this(table, null) { }
/// <summary>
/// Create a new instance of TableValuedParameter
/// </summary>
public TableValuedParameter(DataTable table, string typeName)
{
this.table = table;
this.typeName = typeName;
}
static readonly Action<System.Data.SqlClient.SqlParameter, string> setTypeName;
static TableValuedParameter()
{
var prop = typeof(System.Data.SqlClient.SqlParameter).GetProperty("TypeName", BindingFlags.Instance | BindingFlags.Public);
if (prop != null && prop.PropertyType == typeof(string) && prop.CanWrite)
{
setTypeName = (Action<System.Data.SqlClient.SqlParameter, string>)
Delegate.CreateDelegate(typeof(Action<System.Data.SqlClient.SqlParameter, string>), prop.GetSetMethod());
}
}
void SqlMapper.ICustomQueryParameter.AddParameter(IDbCommand command, string name)
{
var param = command.CreateParameter();
param.ParameterName = name;
Set(param, table, typeName);
command.Parameters.Add(param);
}
internal static void Set(IDbDataParameter parameter, DataTable table, string typeName)
{
parameter.Value = SqlMapper.SanitizeParameterValue(table);
if (string.IsNullOrEmpty(typeName) && table != null)
{
typeName = SqlMapper.GetTypeName(table);
}
if (!string.IsNullOrEmpty(typeName))
{
var sqlParam = parameter as System.Data.SqlClient.SqlParameter;
if (sqlParam != null)
{
if (setTypeName != null) setTypeName(sqlParam, typeName);
sqlParam.SqlDbType = SqlDbType.Structured;
}
}
}
}
}
#endif
\ No newline at end of file
using System;
using System.Reflection;
using System.Collections.Generic;
#if DNXCORE50
using IDbDataParameter = global::System.Data.Common.DbParameter;
using IDataParameter = global::System.Data.Common.DbParameter;
using IDbTransaction = global::System.Data.Common.DbTransaction;
using IDbConnection = global::System.Data.Common.DbConnection;
using IDbCommand = global::System.Data.Common.DbCommand;
using IDataReader = global::System.Data.Common.DbDataReader;
using IDataRecord = global::System.Data.Common.DbDataReader;
using IDataParameterCollection = global::System.Data.Common.DbParameterCollection;
using DataException = global::System.InvalidOperationException;
using ApplicationException = global::System.InvalidOperationException;
#endif
namespace Dapper
{
internal static class TypeExtensions
{
public static bool IsValueType(this Type type)
{
#if DNXCORE50
return typeof(ValueType).IsAssignableFrom(type) && type != typeof(ValueType);
#else
return type.IsValueType;
#endif
}
public static bool IsEnum(this Type type)
{
#if DNXCORE50
return typeof(Enum).IsAssignableFrom(type) && type != typeof(Enum);
#else
return type.IsEnum;
#endif
}
#if DNXCORE50
public static TypeCode GetTypeCode(Type type)
{
if (type == null) return TypeCode.Empty;
TypeCode result;
if (typeCodeLookup.TryGetValue(type, out result)) return result;
if (type.IsEnum())
{
type = Enum.GetUnderlyingType(type);
if (typeCodeLookup.TryGetValue(type, out result)) return result;
}
return TypeCode.Object;
}
static readonly Dictionary<Type, TypeCode> typeCodeLookup = new Dictionary<Type, TypeCode>
{
{typeof(bool), TypeCode.Boolean },
{typeof(byte), TypeCode.Byte },
{typeof(char), TypeCode.Char},
{typeof(DateTime), TypeCode.DateTime},
{typeof(decimal), TypeCode.Decimal},
{typeof(double), TypeCode.Double },
{typeof(short), TypeCode.Int16 },
{typeof(int), TypeCode.Int32 },
{typeof(long), TypeCode.Int64 },
{typeof(object), TypeCode.Object},
{typeof(sbyte), TypeCode.SByte },
{typeof(float), TypeCode.Single },
{typeof(string), TypeCode.String },
{typeof(ushort), TypeCode.UInt16 },
{typeof(uint), TypeCode.UInt32 },
{typeof(ulong), TypeCode.UInt64 },
};
#else
public static TypeCode GetTypeCode(Type type)
{
return Type.GetTypeCode(type);
}
#endif
public static MethodInfo GetPublicInstanceMethod(this Type type, string name, Type[] types)
{
#if DNXCORE50
var method = type.GetMethod(name, types);
return (method != null && method.IsPublic && !method.IsStatic) ? method : null;
#else
return type.GetMethod(name, BindingFlags.Instance | BindingFlags.Public, null, types, null);
#endif
}
}
}
using System;
using System.Data;
namespace Dapper
{
partial class SqlMapper
{
#if !DNXCORE50
/// <summary>
/// A type handler for data-types that are supported by the underlying provider, but which need
/// a well-known UdtTypeName to be specified
/// </summary>
public class UdtTypeHandler : ITypeHandler
{
private readonly string udtTypeName;
/// <summary>
/// Creates a new instance of UdtTypeHandler with the specified UdtTypeName
/// </summary>
public UdtTypeHandler(string udtTypeName)
{
if (string.IsNullOrEmpty(udtTypeName)) throw new ArgumentException("Cannot be null or empty", udtTypeName);
this.udtTypeName = udtTypeName;
}
object ITypeHandler.Parse(Type destinationType, object value)
{
return value is DBNull ? null : value;
}
void ITypeHandler.SetValue(IDbDataParameter parameter, object value)
{
parameter.Value = SanitizeParameterValue(value);
if (parameter is System.Data.SqlClient.SqlParameter && !(value is DBNull))
{
((System.Data.SqlClient.SqlParameter)parameter).SqlDbType = SqlDbType.Udt;
((System.Data.SqlClient.SqlParameter)parameter).UdtTypeName = udtTypeName;
}
}
}
#endif
}
}
using System.Data;
#if DNXCORE50
using IDbDataParameter = global::System.Data.Common.DbParameter;
using IDataParameter = global::System.Data.Common.DbParameter;
using IDbTransaction = global::System.Data.Common.DbTransaction;
using IDbConnection = global::System.Data.Common.DbConnection;
using IDbCommand = global::System.Data.Common.DbCommand;
using IDataReader = global::System.Data.Common.DbDataReader;
using IDataRecord = global::System.Data.Common.DbDataReader;
using IDataParameterCollection = global::System.Data.Common.DbParameterCollection;
using DataException = global::System.InvalidOperationException;
using ApplicationException = global::System.InvalidOperationException;
#endif
namespace Dapper
{
#if DNXCORE50
/// <summary>
/// Describes a reader that controls the lifetime of both a command and a reader,
/// exposing the downstream command/reader as properties.
/// </summary>
public abstract class WrappedDataReader : IDataReader
{
/// <summary>
/// Obtain the underlying reader
/// </summary>
public abstract IDataReader Reader { get; }
/// <summary>
/// Obtain the underlying command
/// </summary>
public abstract IDbCommand Command { get; }
}
#else
/// <summary>
/// Describes a reader that controls the lifetime of both a command and a reader,
/// exposing the downstream command/reader as properties.
/// </summary>
public interface IWrappedDataReader : IDataReader
{
/// <summary>
/// Obtain the underlying reader
/// </summary>
IDataReader Reader { get; }
/// <summary>
/// Obtain the underlying command
/// </summary>
IDbCommand Command { get; }
}
#endif
}
This diff is collapsed.
......@@ -49,12 +49,129 @@
<Reference Include="System.XML" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\Dapper NET40\CommandDefinition.cs">
<Link>CommandDefinition.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\CommandFlags.cs">
<Link>CommandFlags.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\CustomPropertyTypeMap.cs">
<Link>CustomPropertyTypeMap.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\DataTableHandler.cs">
<Link>DataTableHandler.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\DbString.cs">
<Link>DbString.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\DefaultTypeMap.cs">
<Link>DefaultTypeMap.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\DynamicParameters.CachedOutputSetters.cs">
<Link>DynamicParameters.CachedOutputSetters.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\DynamicParameters.cs">
<Link>DynamicParameters.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\DynamicParameters.ParamInfo.cs">
<Link>DynamicParameters.ParamInfo.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\ExplicitConstructorAttribute.cs">
<Link>ExplicitConstructorAttribute.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\FeatureSupport.cs">
<Link>FeatureSupport.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\Properties\AssemblyInfo.cs">
<Link>AssemblyInfo.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SimpleMemberMap.cs">
<Link>SimpleMemberMap.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlDataRecordHandler.cs">
<Link>SqlDataRecordHandler.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlDataRecordListTVPParameter.cs">
<Link>SqlDataRecordListTVPParameter.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.CacheInfo.cs">
<Link>SqlMapper.CacheInfo.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.cs">
<Link>SqlMapper.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.DapperRow.cs">
<Link>SqlMapper.DapperRow.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.DapperRowMetaObject.cs">
<Link>SqlMapper.DapperRowMetaObject.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.DataTable.cs">
<Link>SqlMapper.DataTable.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.DeserializerState.cs">
<Link>SqlMapper.DeserializerState.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.DontMap.cs">
<Link>SqlMapper.DontMap.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.GridReader.cs">
<Link>SqlMapper.GridReader.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.ICustomQueryParameter.cs">
<Link>SqlMapper.ICustomQueryParameter.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.Identity.cs">
<Link>SqlMapper.Identity.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.IDynamicParameters.cs">
<Link>SqlMapper.IDynamicParameters.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.IMemberMap.cs">
<Link>SqlMapper.IMemberMap.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.IParameterCallbacks.cs">
<Link>SqlMapper.IParameterCallbacks.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.IParameterLookup.cs">
<Link>SqlMapper.IParameterLookup.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.ITypeHandler.cs">
<Link>SqlMapper.ITypeHandler.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.ITypeMap.cs">
<Link>SqlMapper.ITypeMap.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.Link.cs">
<Link>SqlMapper.Link.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.LiteralToken.cs">
<Link>SqlMapper.LiteralToken.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.Settings.cs">
<Link>SqlMapper.Settings.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.TypeHandler.cs">
<Link>SqlMapper.TypeHandler.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.TypeHandlerCache.cs">
<Link>SqlMapper.TypeHandlerCache.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\TableValuedParameter.cs">
<Link>TableValuedParameter.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\TypeExtensions.cs">
<Link>TypeExtensions.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\UdtTypeHandler.cs">
<Link>UdtTypeHandler.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\WrappedDataReader.cs">
<Link>WrappedDataReader.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\WrappedReader.cs">
<Link>WrappedReader.cs</Link>
</Compile>
<Compile Include="..\Dapper NET45\SqlMapperAsync.cs">
<Link>SqlMapperAsync.cs</Link>
</Compile>
......
......@@ -43,12 +43,129 @@
<Reference Include="System.XML" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\Dapper NET40\CommandDefinition.cs">
<Link>CommandDefinition.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\CommandFlags.cs">
<Link>CommandFlags.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\CustomPropertyTypeMap.cs">
<Link>CustomPropertyTypeMap.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\DataTableHandler.cs">
<Link>DataTableHandler.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\DbString.cs">
<Link>DbString.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\DefaultTypeMap.cs">
<Link>DefaultTypeMap.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\DynamicParameters.CachedOutputSetters.cs">
<Link>DynamicParameters.CachedOutputSetters.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\DynamicParameters.cs">
<Link>DynamicParameters.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\DynamicParameters.ParamInfo.cs">
<Link>DynamicParameters.ParamInfo.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\ExplicitConstructorAttribute.cs">
<Link>ExplicitConstructorAttribute.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\FeatureSupport.cs">
<Link>FeatureSupport.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\Properties\AssemblyInfo.cs">
<Link>AssemblyInfo.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SimpleMemberMap.cs">
<Link>SimpleMemberMap.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlDataRecordHandler.cs">
<Link>SqlDataRecordHandler.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlDataRecordListTVPParameter.cs">
<Link>SqlDataRecordListTVPParameter.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.CacheInfo.cs">
<Link>SqlMapper.CacheInfo.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.cs">
<Link>SqlMapper.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.DapperRow.cs">
<Link>SqlMapper.DapperRow.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.DapperRowMetaObject.cs">
<Link>SqlMapper.DapperRowMetaObject.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.DataTable.cs">
<Link>SqlMapper.DataTable.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.DeserializerState.cs">
<Link>SqlMapper.DeserializerState.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.DontMap.cs">
<Link>SqlMapper.DontMap.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.GridReader.cs">
<Link>SqlMapper.GridReader.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.ICustomQueryParameter.cs">
<Link>SqlMapper.ICustomQueryParameter.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.Identity.cs">
<Link>SqlMapper.Identity.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.IDynamicParameters.cs">
<Link>SqlMapper.IDynamicParameters.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.IMemberMap.cs">
<Link>SqlMapper.IMemberMap.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.IParameterCallbacks.cs">
<Link>SqlMapper.IParameterCallbacks.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.IParameterLookup.cs">
<Link>SqlMapper.IParameterLookup.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.ITypeHandler.cs">
<Link>SqlMapper.ITypeHandler.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.ITypeMap.cs">
<Link>SqlMapper.ITypeMap.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.Link.cs">
<Link>SqlMapper.Link.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.LiteralToken.cs">
<Link>SqlMapper.LiteralToken.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.Settings.cs">
<Link>SqlMapper.Settings.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.TypeHandler.cs">
<Link>SqlMapper.TypeHandler.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\SqlMapper.TypeHandlerCache.cs">
<Link>SqlMapper.TypeHandlerCache.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\TableValuedParameter.cs">
<Link>TableValuedParameter.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\TypeExtensions.cs">
<Link>TypeExtensions.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\UdtTypeHandler.cs">
<Link>UdtTypeHandler.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\WrappedDataReader.cs">
<Link>WrappedDataReader.cs</Link>
</Compile>
<Compile Include="..\Dapper NET40\WrappedReader.cs">
<Link>WrappedReader.cs</Link>
</Compile>
<Compile Include="SqlMapperAsync.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
......
This diff is collapsed.

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.22823.1
VisualStudioVersion = 14.0.24606.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Dapper", "Dapper\Dapper.xproj", "{088D8CC4-E71E-44B6-9B87-4060B043983D}"
EndProject
......@@ -16,10 +16,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{03340C6E
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Core", "Core", "{ECD7C7BC-176D-49E7-8DB2-FCF248702F87}"
ProjectSection(SolutionItems) = preProject
Dapper NET40\SqlMapper.cs = Dapper NET40\SqlMapper.cs
Dapper NET45\SqlMapperAsync.cs = Dapper NET45\SqlMapperAsync.cs
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
......
<?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>{13A52642-B160-4050-A101-F64FABE7AF9D}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Dapper.SqlBuilder</RootNamespace>
<AssemblyName>Dapper.SqlBuilder NET35</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG;CSHARP30</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</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="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\Dapper.SqlBuilder\Properties\AssemblyInfo.cs">
<Link>Properties\AssemblyInfo.cs</Link>
</Compile>
<Compile Include="..\Dapper.SqlBuilder\SqlBuilder.cs">
<Link>SqlBuilder.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Dapper NET35\Dapper NET35.csproj">
<Project>{b26305d8-3a89-4d68-a981-9bbf378b81fa}</Project>
<Name>Dapper NET35</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
This diff is collapsed.
This diff is collapsed.
<?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)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{3BAA9F79-BA0A-4092-B47B-20170DD47989}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>DapperTests_NET35</RootNamespace>
<AssemblyName>DapperTests NET35</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<TargetFrameworkProfile>
</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>TRACE;DEBUG;NET35 EXTERNALS</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;NET35 EXTERNALS</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Data.Linq" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\Tests\Assert.cs">
<Link>Assert.cs</Link>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Tests.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Dapper NET35\Dapper NET35.csproj">
<Project>{B26305D8-3A89-4D68-A981-9BBF378B81FA}</Project>
<Name>Dapper NET35</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
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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