forked from CosmosOS/Cosmos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add dapperextensions project, some work on install, and testrunner.
- Loading branch information
1 parent
d561610
commit cadc917
Showing
66 changed files
with
3,113 additions
and
364 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> | ||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=Locals/@EntryIndexedValue"><Policy Inspect="True" Prefix="x" Suffix="" Style="AaBb" /></s:String> | ||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=Parameters/@EntryIndexedValue"><Policy Inspect="True" Prefix="a" Suffix="" Style="AaBb" /></s:String> | ||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue"><Policy Inspect="True" Prefix="m" Suffix="" Style="AaBb" /></s:String> | ||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticFields/@EntryIndexedValue"><Policy Inspect="True" Prefix="m" Suffix="" Style="AaBb" /></s:String> | ||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticReadonly/@EntryIndexedValue"><Policy Inspect="True" Prefix="m" Suffix="" Style="AaBb" /></s:String> | ||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PublicFields/@EntryIndexedValue"><Policy Inspect="True" Prefix="m" Suffix="" Style="AaBb" /></s:String> | ||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=StaticReadonly/@EntryIndexedValue"><Policy Inspect="True" Prefix="m" Suffix="" Style="AaBb" /></s:String> | ||
<s:String x:Key="/Default/Environment/AssemblyExplorer/XmlDocument/@EntryValue"><AssemblyExplorer /></s:String></wpf:ResourceDictionary> |
Binary file removed
BIN
-27.6 KB
Resources/Dependencies/Dapper/DapperExtensions.DotNetCore.1.0.1.nupkg
Binary file not shown.
Binary file removed
BIN
-86.6 KB
Resources/Dependencies/Dapper/DapperExtensions.DotNetCore.1.0.1.symbols.nupkg
Binary file not shown.
166 changes: 166 additions & 0 deletions
166
Resources/Dependencies/DapperExtensions.StrongName/DapperAsyncImplementor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,166 @@ | ||
using System.Collections.Generic; | ||
using System.Data; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Dapper; | ||
using DapperExtensions.Mapper; | ||
using DapperExtensions.Sql; | ||
|
||
namespace DapperExtensions | ||
{ | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
public interface IDapperAsyncImplementor : IDapperImplementor | ||
{ | ||
/// <summary> | ||
/// The asynchronous counterpart to <see cref="IDapperImplementor.Get{T}"/>. | ||
/// </summary> | ||
Task<T> GetAsync<T>(IDbConnection connection, dynamic id, IDbTransaction transaction = null, int? commandTimeout = null) where T : class; | ||
/// <summary> | ||
/// The asynchronous counterpart to <see cref="IDapperImplementor.GetList{T}"/>. | ||
/// </summary> | ||
Task<IEnumerable<T>> GetListAsync<T>(IDbConnection connection, object predicate = null, IList<ISort> sort = null, IDbTransaction transaction = null, int? commandTimeout = null) where T : class; | ||
/// <summary> | ||
/// The asynchronous counterpart to <see cref="IDapperImplementor.GetPage{T}"/>. | ||
/// </summary> | ||
Task<IEnumerable<T>> GetPageAsync<T>(IDbConnection connection, object predicate = null, IList<ISort> sort = null, int page = 1, int resultsPerPage = 10, IDbTransaction transaction = null, int? commandTimeout = null) where T : class; | ||
/// <summary> | ||
/// The asynchronous counterpart to <see cref="IDapperImplementor.GetSet{T}"/>. | ||
/// </summary> | ||
Task<IEnumerable<T>> GetSetAsync<T>(IDbConnection connection, object predicate = null, IList<ISort> sort = null, int firstResult = 1, int maxResults = 10, IDbTransaction transaction = null, int? commandTimeout = null) where T : class; | ||
/// <summary> | ||
/// The asynchronous counterpart to <see cref="IDapperImplementor.Count{T}"/>. | ||
/// </summary> | ||
Task<int> CountAsync<T>(IDbConnection connection, object predicate = null, IDbTransaction transaction = null, int? commandTimeout = null) where T : class; | ||
} | ||
|
||
public class DapperAsyncImplementor : DapperImplementor, IDapperAsyncImplementor | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="DapperAsyncImplementor"/> class. | ||
/// </summary> | ||
/// <param name="sqlGenerator">The SQL generator.</param> | ||
public DapperAsyncImplementor(ISqlGenerator sqlGenerator) | ||
:base(sqlGenerator) { } | ||
|
||
#region Implementation of IDapperAsyncImplementor | ||
|
||
/// <summary> | ||
/// The asynchronous counterpart to <see cref="IDapperImplementor.Get{T}"/>. | ||
/// </summary> | ||
public async Task<T> GetAsync<T>(IDbConnection connection, dynamic id, IDbTransaction transaction = null, | ||
int? commandTimeout = null) where T : class | ||
{ | ||
IClassMapper classMap = SqlGenerator.Configuration.GetMap<T>(); | ||
IPredicate predicate = GetIdPredicate(classMap, id); | ||
return (await GetListAsync<T>(connection, classMap, predicate, null, transaction, commandTimeout)).SingleOrDefault(); | ||
} | ||
|
||
/// <summary> | ||
/// The asynchronous counterpart to <see cref="IDapperImplementor.GetList{T}"/>. | ||
/// </summary> | ||
public async Task<IEnumerable<T>> GetListAsync<T>(IDbConnection connection, object predicate = null, IList<ISort> sort = null, | ||
IDbTransaction transaction = null, int? commandTimeout = null) where T : class | ||
{ | ||
IClassMapper classMap = SqlGenerator.Configuration.GetMap<T>(); | ||
IPredicate wherePredicate = GetPredicate(classMap, predicate); | ||
return await GetListAsync<T>(connection, classMap, wherePredicate, sort, transaction, commandTimeout); | ||
} | ||
|
||
/// <summary> | ||
/// The asynchronous counterpart to <see cref="IDapperImplementor.GetPage{T}"/>. | ||
/// </summary> | ||
public async Task<IEnumerable<T>> GetPageAsync<T>(IDbConnection connection, object predicate = null, IList<ISort> sort = null, int page = 1, | ||
int resultsPerPage = 10, IDbTransaction transaction = null, int? commandTimeout = null) where T : class | ||
{ | ||
IClassMapper classMap = SqlGenerator.Configuration.GetMap<T>(); | ||
IPredicate wherePredicate = GetPredicate(classMap, predicate); | ||
return await GetPageAsync<T>(connection, classMap, wherePredicate, sort, page, resultsPerPage, transaction, commandTimeout); | ||
} | ||
|
||
/// <summary> | ||
/// The asynchronous counterpart to <see cref="IDapperImplementor.GetSet{T}"/>. | ||
/// </summary> | ||
public async Task<IEnumerable<T>> GetSetAsync<T>(IDbConnection connection, object predicate = null, IList<ISort> sort = null, int firstResult = 1, | ||
int maxResults = 10, IDbTransaction transaction = null, int? commandTimeout = null) where T : class | ||
{ | ||
IClassMapper classMap = SqlGenerator.Configuration.GetMap<T>(); | ||
IPredicate wherePredicate = GetPredicate(classMap, predicate); | ||
return await GetSetAsync<T>(connection, classMap, wherePredicate, sort, firstResult, maxResults, transaction, commandTimeout); | ||
} | ||
|
||
/// <summary> | ||
/// The asynchronous counterpart to <see cref="IDapperImplementor.Count{T}"/>. | ||
/// </summary> | ||
public async Task<int> CountAsync<T>(IDbConnection connection, object predicate = null, IDbTransaction transaction = null, | ||
int? commandTimeout = null) where T : class | ||
{ | ||
IClassMapper classMap = SqlGenerator.Configuration.GetMap<T>(); | ||
IPredicate wherePredicate = GetPredicate(classMap, predicate); | ||
Dictionary<string, object> parameters = new Dictionary<string, object>(); | ||
string sql = SqlGenerator.Count(classMap, wherePredicate, parameters); | ||
DynamicParameters dynamicParameters = new DynamicParameters(); | ||
foreach (var parameter in parameters) | ||
{ | ||
dynamicParameters.Add(parameter.Key, parameter.Value); | ||
} | ||
|
||
return (int)(await connection.QueryAsync(sql, dynamicParameters, transaction, commandTimeout, CommandType.Text)).Single().Total; | ||
} | ||
|
||
#endregion | ||
|
||
#region Helpers | ||
|
||
/// <summary> | ||
/// The asynchronous counterpart to <see cref="IDapperImplementor.GetList{T}"/>. | ||
/// </summary> | ||
protected async Task<IEnumerable<T>> GetListAsync<T>(IDbConnection connection, IClassMapper classMap, IPredicate predicate, IList<ISort> sort, IDbTransaction transaction, int? commandTimeout) where T : class | ||
{ | ||
Dictionary<string, object> parameters = new Dictionary<string, object>(); | ||
string sql = SqlGenerator.Select(classMap, predicate, sort, parameters); | ||
DynamicParameters dynamicParameters = new DynamicParameters(); | ||
foreach (var parameter in parameters) | ||
{ | ||
dynamicParameters.Add(parameter.Key, parameter.Value); | ||
} | ||
|
||
return await connection.QueryAsync<T>(sql, dynamicParameters, transaction, commandTimeout, CommandType.Text); | ||
} | ||
|
||
/// <summary> | ||
/// The asynchronous counterpart to <see cref="IDapperImplementor.GetPage{T}"/>. | ||
/// </summary> | ||
protected async Task<IEnumerable<T>> GetPageAsync<T>(IDbConnection connection, IClassMapper classMap, IPredicate predicate, IList<ISort> sort, int page, int resultsPerPage, IDbTransaction transaction, int? commandTimeout) where T : class | ||
{ | ||
Dictionary<string, object> parameters = new Dictionary<string, object>(); | ||
string sql = SqlGenerator.SelectPaged(classMap, predicate, sort, page, resultsPerPage, parameters); | ||
DynamicParameters dynamicParameters = new DynamicParameters(); | ||
foreach (var parameter in parameters) | ||
{ | ||
dynamicParameters.Add(parameter.Key, parameter.Value); | ||
} | ||
|
||
return await connection.QueryAsync<T>(sql, dynamicParameters, transaction, commandTimeout, CommandType.Text); | ||
} | ||
|
||
/// <summary> | ||
/// The asynchronous counterpart to <see cref="IDapperImplementor.GetSet{T}"/>. | ||
/// </summary> | ||
protected async Task<IEnumerable<T>> GetSetAsync<T>(IDbConnection connection, IClassMapper classMap, IPredicate predicate, IList<ISort> sort, int firstResult, int maxResults, IDbTransaction transaction, int? commandTimeout) where T : class | ||
{ | ||
Dictionary<string, object> parameters = new Dictionary<string, object>(); | ||
string sql = SqlGenerator.SelectSet(classMap, predicate, sort, firstResult, maxResults, parameters); | ||
DynamicParameters dynamicParameters = new DynamicParameters(); | ||
foreach (var parameter in parameters) | ||
{ | ||
dynamicParameters.Add(parameter.Key, parameter.Value); | ||
} | ||
|
||
return await connection.QueryAsync<T>(sql, dynamicParameters, transaction, commandTimeout, CommandType.Text); | ||
} | ||
|
||
#endregion | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
Resources/Dependencies/DapperExtensions.StrongName/DapperExtensions.StrongName.xproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion> | ||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> | ||
</PropertyGroup> | ||
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" /> | ||
<PropertyGroup Label="Globals"> | ||
<ProjectGuid>caa1a673-6521-4954-bf05-37ffe016e5c3</ProjectGuid> | ||
<RootNamespace>DapperExtensions</RootNamespace> | ||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath> | ||
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<SchemaVersion>2.0</SchemaVersion> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> | ||
<ProduceOutputsOnBuild>True</ProduceOutputsOnBuild> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'"> | ||
<ProduceOutputsOnBuild>True</ProduceOutputsOnBuild> | ||
</PropertyGroup> | ||
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" /> | ||
</Project> |
Oops, something went wrong.