diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1ff0c42 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore index 409da21..ed459d6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,174 +1,38 @@ -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. - -# User-specific files -*.suo -*.user -*.sln.docstates - -# Build results -[Dd]ebug/ -[Dd]ebugPublic/ -[Rr]elease/ -x64/ -build/ -bld/ -[Bb]in/ -[Oo]bj/ - -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -#NUNIT -*.VisualState.xml -TestResult.xml - -# Build Results of an ATL Project -[Dd]ebugPS/ -[Rr]eleasePS/ -dlldata.c - -*_i.c -*_p.c -*_i.h -*.ilk -*.meta -*.obj -*.pch -*.pdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*.log -*.vspscc -*.vssscc -.builds -*.pidb -*.svclog -*.scc - -# Chutzpah Test files -_Chutzpah* - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opensdf -*.sdf -*.cachefile - -# Visual Studio profiler -*.psess -*.vsp -*.vspx - -# TFS 2012 Local Workspace -$tf/ - -# Guidance Automation Toolkit -*.gpState - -# ReSharper is a .NET coding add-in -_ReSharper*/ -*.[Rr]e[Ss]harper -*.DotSettings.user - -# JustCode is a .NET coding addin-in -.JustCode - -# TeamCity is a build add-in -_TeamCity* - -# DotCover is a Code Coverage Tool -*.dotCover - -# NCrunch -*.ncrunch* -_NCrunch_* -.*crunch*.local.xml - -# MightyMoose -*.mm.* -AutoTest.Net/ - -# Web workbench (sass) -.sass-cache/ - -# Installshield output folder -[Ee]xpress/ - -# DocProject is a documentation generator add-in -DocProject/buildhelp/ -DocProject/Help/*.HxT -DocProject/Help/*.HxC -DocProject/Help/*.hhc -DocProject/Help/*.hhk -DocProject/Help/*.hhp -DocProject/Help/Html2 -DocProject/Help/html - -# Click-Once directory -publish/ - -# Publish Web Output -*.[Pp]ublish.xml -*.azurePubxml - -# NuGet Packages Directory -packages/ -## TODO: If the tool you use requires repositories.config uncomment the next line -#!packages/repositories.config - -# Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets -# This line needs to be after the ignore of the build folder (and the packages folder if the line above has been uncommented) -!packages/build/ - -# Windows Azure Build Output -csx/ -*.build.csdef - -# Windows Store app package directory -AppPackages/ - -# Others -sql/ -*.Cache -ClientBin/ -[Ss]tyle[Cc]op.* -~$* -*~ -*.dbmdl -*.dbproj.schemaview -*.pfx -*.publishsettings -node_modules/ - -# RIA/Silverlight projects -Generated_Code/ - -# Backup & report files from converting an old project file to a newer -# Visual Studio version. Backup files are not needed, because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML -UpgradeLog*.htm - -# SQL Server files -*.mdf -*.ldf - -# Business Intelligence projects -*.rdl.data -*.bim.layout -*.bim_*.settings - -# Microsoft Fakes -FakesAssemblies/ +[Oo]bj/ +[Bb]in/ +TestResults/ +.nuget/ +*.sln.ide/ +_ReSharper.*/ +packages/ +artifacts/ +PublishProfiles/ +.vs/ +bower_components/ +node_modules/ +**/wwwroot/lib/ +debugSettings.json +project.lock.json +*.user +*.suo +*.cache +*.docstates +_ReSharper.* +nuget.exe +*net45.csproj +*net451.csproj +*k10.csproj +*.psess +*.vsp +*.pidb +*.userprefs +*DS_Store +*.ncrunchsolution +*.*sdf +*.ipch +.settings +*.sln.ide +node_modules +**/[Cc]ompiler/[Rr]esources/**/*.js +deploy/ +/.build diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..8e4ca07 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,24 @@ +language: csharp +sudo: required +dist: trusty +addons: + apt: + packages: + - gettext + - libcurl4-openssl-dev + - libicu-dev + - libssl-dev + - libunwind8 + - zlib1g +before_install: + - if test "$TRAVIS_OS_NAME" == "osx"; then brew update; brew install icu4c; brew install openssl; brew link --force openssl; fi +mono: + - 4.0.5 +os: + - linux + - osx +osx_image: xcode7.1 +script: + - ./build.sh --quiet verify +env: + - KOREBUILD_TEST_SKIPMONO=1 \ No newline at end of file diff --git a/Dapper.FluentMap.sln b/Dapper.FluentMap.sln new file mode 100644 index 0000000..0d2af46 --- /dev/null +++ b/Dapper.FluentMap.sln @@ -0,0 +1,49 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25123.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{580E3446-6579-4414-9875-970849E635E5}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{04C7C13D-7D23-42C4-9D6F-B76D94BCAA8C}" + ProjectSection(SolutionItems) = preProject + global.json = global.json + NuGet.Config = NuGet.Config + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{742442F2-CAE7-4DC8-BD73-8C54C0005A53}" +EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Dapper.FluentMap", "src\Dapper.FluentMap\Dapper.FluentMap.xproj", "{457E0B9B-F6A4-42C6-BFAE-6F8C71D1F435}" +EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Dapper.FluentMap.Tests", "test\Dapper.FluentMap.Tests\Dapper.FluentMap.Tests.xproj", "{8901F2FD-F98B-484B-A20A-7844A39C7458}" +EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Dapper.FluentMap.Dommel", "src\Dapper.FluentMap.Dommel\Dapper.FluentMap.Dommel.xproj", "{E60B79F6-FE71-44E0-BE88-BFA269378EDB}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {457E0B9B-F6A4-42C6-BFAE-6F8C71D1F435}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {457E0B9B-F6A4-42C6-BFAE-6F8C71D1F435}.Debug|Any CPU.Build.0 = Debug|Any CPU + {457E0B9B-F6A4-42C6-BFAE-6F8C71D1F435}.Release|Any CPU.ActiveCfg = Release|Any CPU + {457E0B9B-F6A4-42C6-BFAE-6F8C71D1F435}.Release|Any CPU.Build.0 = Release|Any CPU + {8901F2FD-F98B-484B-A20A-7844A39C7458}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8901F2FD-F98B-484B-A20A-7844A39C7458}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8901F2FD-F98B-484B-A20A-7844A39C7458}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8901F2FD-F98B-484B-A20A-7844A39C7458}.Release|Any CPU.Build.0 = Release|Any CPU + {E60B79F6-FE71-44E0-BE88-BFA269378EDB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E60B79F6-FE71-44E0-BE88-BFA269378EDB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E60B79F6-FE71-44E0-BE88-BFA269378EDB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E60B79F6-FE71-44E0-BE88-BFA269378EDB}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {457E0B9B-F6A4-42C6-BFAE-6F8C71D1F435} = {580E3446-6579-4414-9875-970849E635E5} + {8901F2FD-F98B-484B-A20A-7844A39C7458} = {742442F2-CAE7-4DC8-BD73-8C54C0005A53} + {E60B79F6-FE71-44E0-BE88-BFA269378EDB} = {580E3446-6579-4414-9875-970849E635E5} + EndGlobalSection +EndGlobal diff --git a/LICENSE b/LICENSE index 8a7361b..7f57282 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2014 Henk Mollema +Copyright (c) 2016 Henk Mollema Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/NuGet.Config b/NuGet.Config new file mode 100644 index 0000000..7604d00 --- /dev/null +++ b/NuGet.Config @@ -0,0 +1,7 @@ + + + + + + + diff --git a/README.md b/README.md index 0726acf..abfe340 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,9 @@ [Dapper.FluentMap](http://henkmollema.github.io/Dapper-FluentMap) ================ -[![Build status](https://ci.appveyor.com/api/projects/status/x6grw3cjuyud9c76/branch/master?svg=true)](https://ci.appveyor.com/project/henkmollema/dapper-fluentmap/branch/master) +[![Build status](https://ci.appveyor.com/api/projects/status/x6grw3cjuyud9c76?svg=true)](https://ci.appveyor.com/project/henkmollema/dapper-fluentmap) +[![NuGet Version](http://img.shields.io/nuget/v/Dapper.FluentMap.svg?style=flat)](https://www.nuget.org/packages/Dapper.FluentMap/ "NuGet version") +[![NuGet Downloads](http://img.shields.io/nuget/dt/Dapper.FluentMap.svg?style=flat)](https://www.nuget.org/packages/Dapper.FluentMap/) ### Introduction @@ -9,8 +11,8 @@ This [Dapper](https://github.com/StackExchange/dapper-dot-net) extension allows
-### Download using NuGet -#### `PM> Install-Package Dapper.FluentMap` +### Download +[![Download Dapper.FluentMap on NuGet](http://i.imgur.com/Rs483do.png "Download Dapper.FluentMap on NuGet")](https://www.nuget.org/packages/Dapper.FluentMap)
diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..3fab83e --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,7 @@ +init: + - git config --global core.autocrlf true +build_script: + - build.cmd verify +clone_depth: 1 +test: off +deploy: off \ No newline at end of file diff --git a/build.cmd b/build.cmd new file mode 100644 index 0000000..7d4894c --- /dev/null +++ b/build.cmd @@ -0,0 +1,2 @@ +@ECHO OFF +PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0build.ps1' %*; exit $LASTEXITCODE" \ No newline at end of file diff --git a/build.ps1 b/build.ps1 new file mode 100644 index 0000000..8f2f996 --- /dev/null +++ b/build.ps1 @@ -0,0 +1,67 @@ +$ErrorActionPreference = "Stop" + +function DownloadWithRetry([string] $url, [string] $downloadLocation, [int] $retries) +{ + while($true) + { + try + { + Invoke-WebRequest $url -OutFile $downloadLocation + break + } + catch + { + $exceptionMessage = $_.Exception.Message + Write-Host "Failed to download '$url': $exceptionMessage" + if ($retries -gt 0) { + $retries-- + Write-Host "Waiting 10 seconds before retrying. Retries left: $retries" + Start-Sleep -Seconds 10 + + } + else + { + $exception = $_.Exception + throw $exception + } + } + } +} + +cd $PSScriptRoot + +$repoFolder = $PSScriptRoot +$env:REPO_FOLDER = $repoFolder + +$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +if ($env:KOREBUILD_ZIP) +{ + $koreBuildZip=$env:KOREBUILD_ZIP +} + +$buildFolder = ".build" +$buildFile="$buildFolder\KoreBuild.ps1" + +if (!(Test-Path $buildFolder)) { + Write-Host "Downloading KoreBuild from $koreBuildZip" + + $tempFolder=$env:TEMP + "\KoreBuild-" + [guid]::NewGuid() + New-Item -Path "$tempFolder" -Type directory | Out-Null + + $localZipFile="$tempFolder\korebuild.zip" + + DownloadWithRetry -url $koreBuildZip -downloadLocation $localZipFile -retries 6 + + Add-Type -AssemblyName System.IO.Compression.FileSystem + [System.IO.Compression.ZipFile]::ExtractToDirectory($localZipFile, $tempFolder) + + New-Item -Path "$buildFolder" -Type directory | Out-Null + copy-item "$tempFolder\**\build\*" $buildFolder -Recurse + + # Cleanup + if (Test-Path $tempFolder) { + Remove-Item -Recurse -Force $tempFolder + } +} + +&"$buildFile" $args \ No newline at end of file diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..f420810 --- /dev/null +++ b/build.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash +repoFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +cd $repoFolder + +koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +if [ ! -z $KOREBUILD_ZIP ]; then + koreBuildZip=$KOREBUILD_ZIP +fi + +buildFolder=".build" +buildFile="$buildFolder/KoreBuild.sh" + +if test ! -d $buildFolder; then + echo "Downloading KoreBuild from $koreBuildZip" + + tempFolder="/tmp/KoreBuild-$(uuidgen)" + mkdir $tempFolder + + localZipFile="$tempFolder/korebuild.zip" + + retries=6 + until (wget -O $localZipFile $koreBuildZip 2>/dev/null || curl -o $localZipFile --location $koreBuildZip 2>/dev/null) + do + echo "Failed to download '$koreBuildZip'" + if [ "$retries" -le 0 ]; then + exit 1 + fi + retries=$((retries - 1)) + echo "Waiting 10 seconds before retrying. Retries left: $retries" + sleep 10s + done + + unzip -q -d $tempFolder $localZipFile + + mkdir $buildFolder + cp -r $tempFolder/**/build/** $buildFolder + + chmod +x $buildFile + + # Cleanup + if test ! -d $tempFolder; then + rm -rf $tempFolder + fi +fi + +$buildFile -r $repoFolder "$@" \ No newline at end of file diff --git a/examples/DapperFluentMapInitializer.cs b/examples/DapperFluentMapInitializer.cs deleted file mode 100644 index 68f6b0b..0000000 --- a/examples/DapperFluentMapInitializer.cs +++ /dev/null @@ -1,26 +0,0 @@ -using Dapper.FluentMap; - -namespace App -{ - public class DapperFluentMapInitializer - { - public static void Init() - { - FluentMapper.Intialize(config => - { - // Configure entities explicitly. - config.AddConvention() - .ForEntity() - .ForEntity; - - // Configure all entities in a certain assembly with an optional namespaces filter. - config.AddConvention() - .ForEntitiesInAssembly(typeof(Product).Assembly, "App.Domain.Model"); - - // Configure all entities in the current assembly with an optional namespaces filter. - config.AddConvention() - .ForEntitiesInCurrentAssembly("App.Domain.Model.Catalog", "App.Domain.Model.Order"); - }); - } - } -} diff --git a/examples/ProductMap.cs b/examples/ProductMap.cs deleted file mode 100644 index d530df3..0000000 --- a/examples/ProductMap.cs +++ /dev/null @@ -1,25 +0,0 @@ -using Dapper.FluentMap.Mapping; - -namespace App.Data.Mapping -{ - /// - /// Represents a manual mapping for the Product entity. - /// - public class ProductMap : EntityMap - { - public ProductMap() - { - // Map property 'Name' to column 'strName'. - Map(p => p.Name) - .ToColumn("strName"); - - // Map property 'Description' to 'strdescription', ignoring casing. - Map(p => p.Description) - .ToColumn("strdescription", caseSensitive: false); - - // Ignore the 'LastModified' property when mapping. - Map(p => p.LastModified) - .Ignore(); - } - } -} diff --git a/examples/PropertyTransformConvention.cs b/examples/PropertyTransformConvention.cs deleted file mode 100644 index a79c912..0000000 --- a/examples/PropertyTransformConvention.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System.Text.RegularExpressions; -using Dapper.FluentMap.Conventions; - -namespace Dapper.FluentMap.TestConsole.Data.Mapping -{ - /// - /// Represents a convention which transforms property names to database column names. - /// - public class PropertyTransformConvention : Convention - { - public PropertyTransformConvention() - { - // Map 'UrlOptimizedName' to 'Url_Optimized_Name'. - Properties() - .Configure(c => c.Transform(s => Regex.Replace(input: s, pattern: "([A-Z])([A-Z][a-z])|([a-z0-9])([A-Z])", replacement: "$1$3_$2$4"))); - } - } -} diff --git a/examples/TypePrefixConvention.cs b/examples/TypePrefixConvention.cs deleted file mode 100644 index d8a1955..0000000 --- a/examples/TypePrefixConvention.cs +++ /dev/null @@ -1,30 +0,0 @@ -using Dapper.FluentMap.Conventions; - -namespace App.Data.Mapping -{ - /// - /// Represents a convention which adds type prefixes to database column names. - /// - public class TypePrefixConvention : Convention - { - public TypePrefixConvention() - { - // Map all properties of type int and with the name 'id' to column 'autID'. - Properties() - .Where(c => c.Name.ToLower() == "id") - .Configure(c => c.HasColumnName("autID")); - - // Prefix all properties of type string with 'str' when mapping to column names. - Properties() - .Configure(c => c.HasPrefix("str")); - - // Prefix all properties of type string with 'str' when mapping to column names. - Properties() - .Configure(c => c.HasPrefix("str")); - - // Prefix all properties of type int with 'int' when mapping to column names. - Properties() - .Configure(c => c.HasPrefix("int")); - } - } -} diff --git a/global.json b/global.json new file mode 100644 index 0000000..5e6422e --- /dev/null +++ b/global.json @@ -0,0 +1,3 @@ +{ + "projects": [ "src", "test" ] +} diff --git a/nuget/Dapper.FluentMap.1.0.0.nupkg b/nuget/Dapper.FluentMap.1.0.0.nupkg deleted file mode 100644 index fda7216..0000000 Binary files a/nuget/Dapper.FluentMap.1.0.0.nupkg and /dev/null differ diff --git a/nuget/Dapper.FluentMap.1.0.1.nupkg b/nuget/Dapper.FluentMap.1.0.1.nupkg deleted file mode 100644 index e6e0fd8..0000000 Binary files a/nuget/Dapper.FluentMap.1.0.1.nupkg and /dev/null differ diff --git a/nuget/Dapper.FluentMap.1.0.2.nupkg b/nuget/Dapper.FluentMap.1.0.2.nupkg deleted file mode 100644 index fc27857..0000000 Binary files a/nuget/Dapper.FluentMap.1.0.2.nupkg and /dev/null differ diff --git a/nuget/Dapper.FluentMap.1.1.0.nupkg b/nuget/Dapper.FluentMap.1.1.0.nupkg deleted file mode 100644 index e5620f2..0000000 Binary files a/nuget/Dapper.FluentMap.1.1.0.nupkg and /dev/null differ diff --git a/nuget/Dapper.FluentMap.1.1.1.nupkg b/nuget/Dapper.FluentMap.1.1.1.nupkg deleted file mode 100644 index 8969ffd..0000000 Binary files a/nuget/Dapper.FluentMap.1.1.1.nupkg and /dev/null differ diff --git a/nuget/Dapper.FluentMap.1.2.0.nupkg b/nuget/Dapper.FluentMap.1.2.0.nupkg deleted file mode 100644 index 03c3fb8..0000000 Binary files a/nuget/Dapper.FluentMap.1.2.0.nupkg and /dev/null differ diff --git a/nuget/Dapper.FluentMap.1.2.1.nupkg b/nuget/Dapper.FluentMap.1.2.1.nupkg deleted file mode 100644 index a25324a..0000000 Binary files a/nuget/Dapper.FluentMap.1.2.1.nupkg and /dev/null differ diff --git a/nuget/Dapper.FluentMap.1.3.0.nupkg b/nuget/Dapper.FluentMap.1.3.0.nupkg deleted file mode 100644 index 70c41f0..0000000 Binary files a/nuget/Dapper.FluentMap.1.3.0.nupkg and /dev/null differ diff --git a/nuget/Dapper.FluentMap.1.3.1.nupkg b/nuget/Dapper.FluentMap.1.3.1.nupkg deleted file mode 100644 index 6a46328..0000000 Binary files a/nuget/Dapper.FluentMap.1.3.1.nupkg and /dev/null differ diff --git a/nuget/Dapper.FluentMap.1.3.2.nupkg b/nuget/Dapper.FluentMap.1.3.2.nupkg deleted file mode 100644 index 0d4450d..0000000 Binary files a/nuget/Dapper.FluentMap.1.3.2.nupkg and /dev/null differ diff --git a/nuget/Dapper.FluentMap.1.3.3.nupkg b/nuget/Dapper.FluentMap.1.3.3.nupkg deleted file mode 100644 index 28baaf2..0000000 Binary files a/nuget/Dapper.FluentMap.1.3.3.nupkg and /dev/null differ diff --git a/nuget/Dapper.FluentMap.1.3.4.nupkg b/nuget/Dapper.FluentMap.1.3.4.nupkg deleted file mode 100644 index d27d868..0000000 Binary files a/nuget/Dapper.FluentMap.1.3.4.nupkg and /dev/null differ diff --git a/nuget/Dapper.FluentMap.1.4.0.nupkg b/nuget/Dapper.FluentMap.1.4.0.nupkg deleted file mode 100644 index d0fc5e7..0000000 Binary files a/nuget/Dapper.FluentMap.1.4.0.nupkg and /dev/null differ diff --git a/nuget/Dapper.FluentMap.1.5.0-beta1.nupkg b/nuget/Dapper.FluentMap.1.5.0-beta1.nupkg deleted file mode 100644 index eb68dad..0000000 Binary files a/nuget/Dapper.FluentMap.1.5.0-beta1.nupkg and /dev/null differ diff --git a/nuget/Dapper.FluentMap.Dommel.1.0.0.nupkg b/nuget/Dapper.FluentMap.Dommel.1.0.0.nupkg deleted file mode 100644 index 414e226..0000000 Binary files a/nuget/Dapper.FluentMap.Dommel.1.0.0.nupkg and /dev/null differ diff --git a/nuget/Dapper.FluentMap.Dommel.1.0.1.nupkg b/nuget/Dapper.FluentMap.Dommel.1.0.1.nupkg deleted file mode 100644 index fa47779..0000000 Binary files a/nuget/Dapper.FluentMap.Dommel.1.0.1.nupkg and /dev/null differ diff --git a/nuget/Dapper.FluentMap.Dommel.1.0.2.nupkg b/nuget/Dapper.FluentMap.Dommel.1.0.2.nupkg deleted file mode 100644 index 3a2563d..0000000 Binary files a/nuget/Dapper.FluentMap.Dommel.1.0.2.nupkg and /dev/null differ diff --git a/nuget/Dapper.FluentMap.Dommel.1.0.3.nupkg b/nuget/Dapper.FluentMap.Dommel.1.0.3.nupkg deleted file mode 100644 index b4c2d60..0000000 Binary files a/nuget/Dapper.FluentMap.Dommel.1.0.3.nupkg and /dev/null differ diff --git a/nuget/Dapper.FluentMap.Dommel.1.1.0.nupkg b/nuget/Dapper.FluentMap.Dommel.1.1.0.nupkg deleted file mode 100644 index 7a58af5..0000000 Binary files a/nuget/Dapper.FluentMap.Dommel.1.1.0.nupkg and /dev/null differ diff --git a/nuget/Dapper.FluentMap.Dommel.1.2.0.nupkg b/nuget/Dapper.FluentMap.Dommel.1.2.0.nupkg deleted file mode 100644 index d5dcd02..0000000 Binary files a/nuget/Dapper.FluentMap.Dommel.1.2.0.nupkg and /dev/null differ diff --git a/nuget/Dapper.FluentMap.Dommel.1.3.0-beta1.nupkg b/nuget/Dapper.FluentMap.Dommel.1.3.0-beta1.nupkg deleted file mode 100644 index c3ba723..0000000 Binary files a/nuget/Dapper.FluentMap.Dommel.1.3.0-beta1.nupkg and /dev/null differ diff --git a/src/Dapper.FluentMap.Dommel/Dapper.FluentMap.Dommel.csproj b/src/Dapper.FluentMap.Dommel/Dapper.FluentMap.Dommel.csproj deleted file mode 100644 index 4235577..0000000 --- a/src/Dapper.FluentMap.Dommel/Dapper.FluentMap.Dommel.csproj +++ /dev/null @@ -1,81 +0,0 @@ - - - - - Debug - AnyCPU - {74FD33BB-78DC-4170-9871-DEBE8FF71646} - Library - Properties - Dapper.FluentMap.Dommel - Dapper.FluentMap.Dommel - v4.0 - 512 - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - bin\Release\Dapper.FluentMap.Dommel.XML - - - - ..\packages\Dapper.1.50.0-beta8\lib\net40\Dapper.dll - True - - - ..\packages\Dommel.1.5.0\lib\net40\Dommel.dll - True - - - - - - - - - - - - - - - - - - - - - {a04cca46-b05d-45d7-8adc-5cef70d26b60} - Dapper.FluentMap - - - - - Designer - - - - - \ No newline at end of file diff --git a/src/Dapper.FluentMap.Dommel/Dapper.FluentMap.Dommel.xproj b/src/Dapper.FluentMap.Dommel/Dapper.FluentMap.Dommel.xproj new file mode 100644 index 0000000..42fec3b --- /dev/null +++ b/src/Dapper.FluentMap.Dommel/Dapper.FluentMap.Dommel.xproj @@ -0,0 +1,21 @@ + + + + 14.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + + e60b79f6-fe71-44e0-be88-bfa269378edb + Dapper.FluentMap.Dommel + .\obj + .\bin\ + v4.5.2 + + + + 2.0 + + + diff --git a/src/Dapper.FluentMap.Dommel/Mapping/DommelEntityMap.cs b/src/Dapper.FluentMap.Dommel/Mapping/DommelEntityMap.cs index da0a368..d6164cf 100644 --- a/src/Dapper.FluentMap.Dommel/Mapping/DommelEntityMap.cs +++ b/src/Dapper.FluentMap.Dommel/Mapping/DommelEntityMap.cs @@ -31,6 +31,9 @@ protected override DommelPropertyMap GetPropertyMap(PropertyInfo info) return new DommelPropertyMap(info); } + /// + /// Gets the table name for this entity map. + /// public string TableName { get; private set; } /// diff --git a/src/Dapper.FluentMap.Dommel/Mapping/DommelPropertyMap.cs b/src/Dapper.FluentMap.Dommel/Mapping/DommelPropertyMap.cs index b85c8f2..1019c9c 100644 --- a/src/Dapper.FluentMap.Dommel/Mapping/DommelPropertyMap.cs +++ b/src/Dapper.FluentMap.Dommel/Mapping/DommelPropertyMap.cs @@ -9,7 +9,7 @@ namespace Dapper.FluentMap.Dommel.Mapping public class DommelPropertyMap : PropertyMapBase, IPropertyMap { /// - /// Initializes a new instance of the class + /// Initializes a new instance of the class /// with the specified object. /// /// The information about the property. @@ -18,6 +18,9 @@ public DommelPropertyMap(PropertyInfo info) { } + /// + /// Gets a value indicating whether this property is a primary key. + /// public bool Key { get; private set; } /// diff --git a/src/Dapper.FluentMap.Dommel/Resolvers/DommelColumnNameResolver.cs b/src/Dapper.FluentMap.Dommel/Resolvers/DommelColumnNameResolver.cs index 00d26eb..94c3813 100644 --- a/src/Dapper.FluentMap.Dommel/Resolvers/DommelColumnNameResolver.cs +++ b/src/Dapper.FluentMap.Dommel/Resolvers/DommelColumnNameResolver.cs @@ -1,36 +1,37 @@ -using System.Linq; -using System.Reflection; -using Dapper.FluentMap.Dommel.Mapping; -using Dapper.FluentMap.Mapping; -using Dommel; - -namespace Dapper.FluentMap.Dommel.Resolvers -{ - /// - /// Implements the interface by using the configured mapping. - /// - public class DommelColumnNameResolver : DommelMapper.IColumnNameResolver - { - public string ResolveColumnName(PropertyInfo propertyInfo) - { - if (propertyInfo.DeclaringType != null) - { - IEntityMap entityMap; - if (FluentMapper.EntityMaps.TryGetValue(propertyInfo.DeclaringType, out entityMap)) - { - var mapping = entityMap as IDommelEntityMap; - if (mapping != null) - { - var propertyMaps = entityMap.PropertyMaps.Where(m => m.PropertyInfo.Name == propertyInfo.Name).ToList(); - if (propertyMaps.Count == 1) - { - return propertyMaps[0].ColumnName; - } - } - } - } - - return DommelMapper.Resolvers.Default.ColumnNameResolver.ResolveColumnName(propertyInfo); - } - } -} \ No newline at end of file +using System.Linq; +using System.Reflection; +using Dapper.FluentMap.Dommel.Mapping; +using Dapper.FluentMap.Mapping; +using Dommel; + +namespace Dapper.FluentMap.Dommel.Resolvers +{ + /// + /// Implements the interface by using the configured mapping. + /// + public class DommelColumnNameResolver : DommelMapper.IColumnNameResolver + { + /// + public string ResolveColumnName(PropertyInfo propertyInfo) + { + if (propertyInfo.DeclaringType != null) + { + IEntityMap entityMap; + if (FluentMapper.EntityMaps.TryGetValue(propertyInfo.DeclaringType, out entityMap)) + { + var mapping = entityMap as IDommelEntityMap; + if (mapping != null) + { + var propertyMaps = entityMap.PropertyMaps.Where(m => m.PropertyInfo.Name == propertyInfo.Name).ToList(); + if (propertyMaps.Count == 1) + { + return propertyMaps[0].ColumnName; + } + } + } + } + + return DommelMapper.Resolvers.Default.ColumnNameResolver.ResolveColumnName(propertyInfo); + } + } +} diff --git a/src/Dapper.FluentMap.Dommel/Resolvers/DommelKeyPropertyResolver.cs b/src/Dapper.FluentMap.Dommel/Resolvers/DommelKeyPropertyResolver.cs index 6174696..4cfd243 100644 --- a/src/Dapper.FluentMap.Dommel/Resolvers/DommelKeyPropertyResolver.cs +++ b/src/Dapper.FluentMap.Dommel/Resolvers/DommelKeyPropertyResolver.cs @@ -1,45 +1,46 @@ -using System; -using System.Linq; -using System.Reflection; -using Dapper.FluentMap.Dommel.Mapping; -using Dapper.FluentMap.Mapping; -using Dommel; - -namespace Dapper.FluentMap.Dommel.Resolvers -{ - /// - /// Implements the interface by using the configured mapping. - /// - public class DommelKeyPropertyResolver : DommelMapper.IKeyPropertyResolver - { - public PropertyInfo ResolveKeyProperty(Type type) - { - IEntityMap entityMap; - if (FluentMapper.EntityMaps.TryGetValue(type, out entityMap)) - { - var mapping = entityMap as IDommelEntityMap; - if (mapping != null) - { - var keyPropertyMaps = entityMap.PropertyMaps.OfType().Where(e => e.Key).ToList(); - - if (keyPropertyMaps.Count == 1) - { - return keyPropertyMaps[0].PropertyInfo; - } - - if (keyPropertyMaps.Count > 1) - { - string msg = string.Format("Found multiple key properties on type '{0}'. This is not yet supported. The following key properties were found:{1}{2}", - type.FullName, - Environment.NewLine, - string.Join(Environment.NewLine, keyPropertyMaps.Select(t => t.PropertyInfo.Name))); - - throw new Exception(msg); - } - } - } - - return DommelMapper.Resolvers.Default.KeyPropertyResolver.ResolveKeyProperty(type); - } - } -} \ No newline at end of file +using System; +using System.Linq; +using System.Reflection; +using Dapper.FluentMap.Dommel.Mapping; +using Dapper.FluentMap.Mapping; +using Dommel; + +namespace Dapper.FluentMap.Dommel.Resolvers +{ + /// + /// Implements the interface by using the configured mapping. + /// + public class DommelKeyPropertyResolver : DommelMapper.IKeyPropertyResolver + { + /// + public PropertyInfo ResolveKeyProperty(Type type) + { + IEntityMap entityMap; + if (FluentMapper.EntityMaps.TryGetValue(type, out entityMap)) + { + var mapping = entityMap as IDommelEntityMap; + if (mapping != null) + { + var keyPropertyMaps = entityMap.PropertyMaps.OfType().Where(e => e.Key).ToList(); + + if (keyPropertyMaps.Count == 1) + { + return keyPropertyMaps[0].PropertyInfo; + } + + if (keyPropertyMaps.Count > 1) + { + var msg = string.Format("Found multiple key properties on type '{0}'. This is not yet supported. The following key properties were found:{1}{2}", + type.FullName, + Environment.NewLine, + string.Join(Environment.NewLine, keyPropertyMaps.Select(t => t.PropertyInfo.Name))); + + throw new Exception(msg); + } + } + } + + return DommelMapper.Resolvers.Default.KeyPropertyResolver.ResolveKeyProperty(type); + } + } +} diff --git a/src/Dapper.FluentMap.Dommel/Resolvers/DommelPropertyResolver.cs b/src/Dapper.FluentMap.Dommel/Resolvers/DommelPropertyResolver.cs index 8c61ca2..2e61ddc 100644 --- a/src/Dapper.FluentMap.Dommel/Resolvers/DommelPropertyResolver.cs +++ b/src/Dapper.FluentMap.Dommel/Resolvers/DommelPropertyResolver.cs @@ -1,49 +1,55 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using Dapper.FluentMap.Mapping; -using Dommel; - -namespace Dapper.FluentMap.Dommel.Resolvers -{ - public class DommelPropertyResolver : DommelMapper.PropertyResolverBase - { - protected override IEnumerable FilterComplexTypes(IEnumerable properties) - { - foreach (var propertyInfo in properties) - { - Type type = propertyInfo.PropertyType; - type = Nullable.GetUnderlyingType(type) ?? type; - if (type.IsPrimitive || type.IsEnum || PrimitiveTypes.Contains(type)) - { - yield return propertyInfo; - } - } - } - - public override IEnumerable ResolveProperties(Type type) - { - IEntityMap entityMap; - if (FluentMapper.EntityMaps.TryGetValue(type, out entityMap)) - { - foreach (var property in FilterComplexTypes(type.GetProperties())) - { - // Determine whether the property should be ignored. - var propertyMap = entityMap.PropertyMaps.FirstOrDefault(p => p.PropertyInfo.Name == property.Name); - if (propertyMap == null || !propertyMap.Ignored) - { - yield return property; - } - } - } - else - { - foreach (var property in DommelMapper.Resolvers.Default.PropertyResolver.ResolveProperties(type)) - { - yield return property; - } - } - } - } -} \ No newline at end of file +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using Dapper.FluentMap.Mapping; +using Dommel; + +namespace Dapper.FluentMap.Dommel.Resolvers +{ + /// + /// Implements the interface by using the configured mapping. + /// + public class DommelPropertyResolver : DommelMapper.PropertyResolverBase + { + /// + protected override IEnumerable FilterComplexTypes(IEnumerable properties) + { + foreach (var propertyInfo in properties) + { + var type = propertyInfo.PropertyType; + type = Nullable.GetUnderlyingType(type) ?? type; + + if (type.GetTypeInfo().IsPrimitive || type.GetTypeInfo().IsEnum || PrimitiveTypes.Contains(type)) + { + yield return propertyInfo; + } + } + } + + /// + public override IEnumerable ResolveProperties(Type type) + { + IEntityMap entityMap; + if (FluentMapper.EntityMaps.TryGetValue(type, out entityMap)) + { + foreach (var property in FilterComplexTypes(type.GetProperties())) + { + // Determine whether the property should be ignored. + var propertyMap = entityMap.PropertyMaps.FirstOrDefault(p => p.PropertyInfo.Name == property.Name); + if (propertyMap == null || !propertyMap.Ignored) + { + yield return property; + } + } + } + else + { + foreach (var property in DommelMapper.Resolvers.Default.PropertyResolver.ResolveProperties(type)) + { + yield return property; + } + } + } + } +} diff --git a/src/Dapper.FluentMap.Dommel/Resolvers/DommelTableNameResolver.cs b/src/Dapper.FluentMap.Dommel/Resolvers/DommelTableNameResolver.cs index 441f13c..e5b305b 100644 --- a/src/Dapper.FluentMap.Dommel/Resolvers/DommelTableNameResolver.cs +++ b/src/Dapper.FluentMap.Dommel/Resolvers/DommelTableNameResolver.cs @@ -1,29 +1,30 @@ -using System; -using Dapper.FluentMap.Dommel.Mapping; -using Dapper.FluentMap.Mapping; -using Dommel; - -namespace Dapper.FluentMap.Dommel.Resolvers -{ - /// - /// Implements the interface by using the configured mapping. - /// - public class DommelTableNameResolver : DommelMapper.ITableNameResolver - { - public string ResolveTableName(Type type) - { - IEntityMap entityMap; - if (FluentMapper.EntityMaps.TryGetValue(type, out entityMap)) - { - var mapping = entityMap as IDommelEntityMap; - - if (mapping != null) - { - return mapping.TableName; - } - } - - return DommelMapper.Resolvers.Default.TableNameResolver.ResolveTableName(type); - } - } -} \ No newline at end of file +using System; +using Dapper.FluentMap.Dommel.Mapping; +using Dapper.FluentMap.Mapping; +using Dommel; + +namespace Dapper.FluentMap.Dommel.Resolvers +{ + /// + /// Implements the interface by using the configured mapping. + /// + public class DommelTableNameResolver : DommelMapper.ITableNameResolver + { + /// + public string ResolveTableName(Type type) + { + IEntityMap entityMap; + if (FluentMapper.EntityMaps.TryGetValue(type, out entityMap)) + { + var mapping = entityMap as IDommelEntityMap; + + if (mapping != null) + { + return mapping.TableName; + } + } + + return DommelMapper.Resolvers.Default.TableNameResolver.ResolveTableName(type); + } + } +} diff --git a/src/Dapper.FluentMap.Dommel/packages.config b/src/Dapper.FluentMap.Dommel/packages.config deleted file mode 100644 index 8caf832..0000000 --- a/src/Dapper.FluentMap.Dommel/packages.config +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/src/Dapper.FluentMap.Dommel/project.json b/src/Dapper.FluentMap.Dommel/project.json new file mode 100644 index 0000000..880cd24 --- /dev/null +++ b/src/Dapper.FluentMap.Dommel/project.json @@ -0,0 +1,26 @@ +{ + "version": "1.4.0", + "description": "Dapper.FluentMap extension for Dommel support.", + "authors": [ "Henk Mollema" ], + "copyright": "Copyright © Henk Mollema 2016", + "packOptions": { + "licenseUrl": "https://github.com/henkmollema/Dapper-FluentMap/blob/master/LICENSE", + "owners": [ "Henk Mollema" ], + "projectUrl": "https://github.com/henkmollema/Dapper-FluentMap", + "tags": [ "dapper", "fluentmap", "dommel" ] + }, + + "dependencies": { + "Dapper.FluentMap": "1.5.0", + "Dommel": "1.6.0" + }, + + "frameworks": { + "net451": { }, + "netstandard1.3": { } + }, + + "buildOptions": { + "xmlDoc": true + } +} diff --git a/src/Dapper.FluentMap.Tests/ConventionTests.cs b/src/Dapper.FluentMap.Tests/ConventionTests.cs deleted file mode 100644 index e2b4f20..0000000 --- a/src/Dapper.FluentMap.Tests/ConventionTests.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System.Diagnostics; -using Dapper.FluentMap.Conventions; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace Dapper.FluentMap.Tests -{ - [TestClass] - public class ConventionTests - { - [TestMethod] - public void ShouldMapEntitiesInCurrentAssembly() - { - PreTest(); - FluentMapper.Initialize(c => c.AddConvention() - .ForEntitiesInCurrentAssembly()); - - Debug.Assert(FluentMapper.TypeConventions.ContainsKey(typeof (TestEntity))); - var map = FluentMapper.TypeConventions[typeof (TestEntity)]; - Debug.Assert(map[0] is TestConvention); - } - - private class TestConvention : Convention - { - public TestConvention() - { - Properties(). - Where(p => p.Name.ToLower() == "id") - .Configure(c => c.HasColumnName("autID")); - } - } - - private static void PreTest() - { - FluentMapper.EntityMaps.Clear(); - FluentMapper.TypeConventions.Clear(); - } - } -} diff --git a/src/Dapper.FluentMap.Tests/Dapper.FluentMap.Tests.csproj b/src/Dapper.FluentMap.Tests/Dapper.FluentMap.Tests.csproj deleted file mode 100644 index f40743d..0000000 --- a/src/Dapper.FluentMap.Tests/Dapper.FluentMap.Tests.csproj +++ /dev/null @@ -1,102 +0,0 @@ - - - - Debug - AnyCPU - {CE214E29-ADBE-43D3-846E-97AED03132CC} - Library - Properties - Dapper.FluentMap.Tests - Dapper.FluentMap.Tests - v4.5 - 512 - {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 10.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages - False - UnitTest - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\packages\Dapper.1.38\lib\net45\Dapper.dll - - - - - - - - - - - - - - - - - - - - - - - - - {74fd33bb-78dc-4170-9871-debe8ff71646} - Dapper.FluentMap.Dommel - - - {a04cca46-b05d-45d7-8adc-5cef70d26b60} - Dapper.FluentMap - - - - - - - - - - False - - - False - - - False - - - False - - - - - - - - \ No newline at end of file diff --git a/src/Dapper.FluentMap.Tests/Properties/AssemblyInfo.cs b/src/Dapper.FluentMap.Tests/Properties/AssemblyInfo.cs deleted file mode 100644 index a946a40..0000000 --- a/src/Dapper.FluentMap.Tests/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Dapper.FluentMap.Tests")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Dapper.FluentMap.Tests")] -[assembly: AssemblyCopyright("Copyright © 2014")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("6a41b3de-965a-4d13-8694-e3b6a8218021")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/Dapper.FluentMap.Tests/packages.config b/src/Dapper.FluentMap.Tests/packages.config deleted file mode 100644 index 8002c85..0000000 --- a/src/Dapper.FluentMap.Tests/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/src/Dapper.FluentMap.sln b/src/Dapper.FluentMap.sln deleted file mode 100644 index ef514c2..0000000 --- a/src/Dapper.FluentMap.sln +++ /dev/null @@ -1,34 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.23107.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dapper.FluentMap", "Dapper.FluentMap\Dapper.FluentMap.csproj", "{A04CCA46-B05D-45D7-8ADC-5CEF70D26B60}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dapper.FluentMap.Dommel", "Dapper.FluentMap.Dommel\Dapper.FluentMap.Dommel.csproj", "{74FD33BB-78DC-4170-9871-DEBE8FF71646}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dapper.FluentMap.Tests", "Dapper.FluentMap.Tests\Dapper.FluentMap.Tests.csproj", "{CE214E29-ADBE-43D3-846E-97AED03132CC}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {A04CCA46-B05D-45D7-8ADC-5CEF70D26B60}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A04CCA46-B05D-45D7-8ADC-5CEF70D26B60}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A04CCA46-B05D-45D7-8ADC-5CEF70D26B60}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A04CCA46-B05D-45D7-8ADC-5CEF70D26B60}.Release|Any CPU.Build.0 = Release|Any CPU - {74FD33BB-78DC-4170-9871-DEBE8FF71646}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {74FD33BB-78DC-4170-9871-DEBE8FF71646}.Debug|Any CPU.Build.0 = Debug|Any CPU - {74FD33BB-78DC-4170-9871-DEBE8FF71646}.Release|Any CPU.ActiveCfg = Release|Any CPU - {74FD33BB-78DC-4170-9871-DEBE8FF71646}.Release|Any CPU.Build.0 = Release|Any CPU - {CE214E29-ADBE-43D3-846E-97AED03132CC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {CE214E29-ADBE-43D3-846E-97AED03132CC}.Debug|Any CPU.Build.0 = Debug|Any CPU - {CE214E29-ADBE-43D3-846E-97AED03132CC}.Release|Any CPU.ActiveCfg = Release|Any CPU - {CE214E29-ADBE-43D3-846E-97AED03132CC}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/src/Dapper.FluentMap/Configuration/FluentConventionConfiguration.cs b/src/Dapper.FluentMap/Configuration/FluentConventionConfiguration.cs index 5ae4481..328a475 100644 --- a/src/Dapper.FluentMap/Configuration/FluentConventionConfiguration.cs +++ b/src/Dapper.FluentMap/Configuration/FluentConventionConfiguration.cs @@ -2,7 +2,6 @@ using System.ComponentModel; using System.Linq; using System.Reflection; - using Dapper.FluentMap.Conventions; using Dapper.FluentMap.Mapping; using Dapper.FluentMap.Utils; @@ -33,7 +32,7 @@ public FluentConventionConfiguration(Convention convention) /// The current instance of . public FluentConventionConfiguration ForEntity() { - Type type = typeof(T); + var type = typeof(T); MapProperties(type); FluentMapper.TypeConventions.AddOrUpdate(type, _convention); @@ -41,17 +40,27 @@ public FluentConventionConfiguration ForEntity() return this; } +#if !COREFX /// /// Configures the current convention for all the entities in current assembly filtered by the specified namespaces. /// - /// An array of namespaces which filter the types in the current assembly. This parameter is optional. + /// + /// An array of namespaces which filter the types in the current assembly. + /// This parameter is optional. + /// /// The current instance of . public FluentConventionConfiguration ForEntitiesInCurrentAssembly(params string[] namespaces) { - foreach (var type in Assembly.GetCallingAssembly() - .GetExportedTypes() - .Where(type => namespaces.Length == 0 || namespaces.Any(n => type.Namespace == n))) + foreach (var type in Assembly.GetCallingAssembly().GetExportedTypes()) { + if (namespaces != null && + namespaces.Length > 0 && + namespaces.All(n => n != type.Namespace)) + { + // Filter by namespace. + continue; + } + MapProperties(type); FluentMapper.TypeConventions.AddOrUpdate(type, _convention); FluentMapper.AddConventionTypeMap(type); @@ -59,18 +68,29 @@ public FluentConventionConfiguration ForEntitiesInCurrentAssembly(params string[ return this; } +#endif /// /// Configures the current convention for all entities in the specified assembly filtered by the specified namespaces. /// /// The assembly to scan for entities. - /// An array of namespaces which filter the types in . This parameter is optional. + /// + /// An array of namespaces which filter the types in . + /// This parameter is optional. + /// /// The current instance of . public FluentConventionConfiguration ForEntitiesInAssembly(Assembly assembly, params string[] namespaces) { - foreach (var type in assembly.GetExportedTypes() - .Where(type => namespaces.Any(n => type.Namespace == n))) + foreach (var type in assembly.GetExportedTypes()) { + if (namespaces != null && + namespaces.Length > 0 && + namespaces.All(n => n != type.Namespace)) + { + // Filter by namespace. + continue; + } + MapProperties(type); FluentMapper.TypeConventions.AddOrUpdate(type, _convention); FluentMapper.AddConventionTypeMap(type); diff --git a/src/Dapper.FluentMap/Configuration/FluentMapConfiguration.cs b/src/Dapper.FluentMap/Configuration/FluentMapConfiguration.cs index 321ad29..16e6f42 100644 --- a/src/Dapper.FluentMap/Configuration/FluentMapConfiguration.cs +++ b/src/Dapper.FluentMap/Configuration/FluentMapConfiguration.cs @@ -14,7 +14,10 @@ public class FluentMapConfiguration /// Adds the specified to the configuration of Dapper.FluentMap. /// /// The type argument of the entity. - /// An instance of the interface containing the entity mapping configuration. + /// + /// An instance of the interface containing the + /// entity mapping configuration. + /// public void AddMap(IEntityMap mapper) where TEntity : class { if (FluentMapper.EntityMaps.TryAdd(typeof(TEntity), mapper)) diff --git a/src/Dapper.FluentMap/Conventions/Convention.cs b/src/Dapper.FluentMap/Conventions/Convention.cs index 2e2aa6a..39ddd33 100644 --- a/src/Dapper.FluentMap/Conventions/Convention.cs +++ b/src/Dapper.FluentMap/Conventions/Convention.cs @@ -19,9 +19,9 @@ protected Convention() PropertyMaps = new List(); } - internal IList ConventionConfigurations { get; private set; } + internal IList ConventionConfigurations { get; } - internal IList PropertyMaps { get; private set; } + internal IList PropertyMaps { get; } /// /// Configures a convention that applies on all properties of the entity. @@ -43,7 +43,7 @@ protected PropertyConventionConfiguration Properties() protected PropertyConventionConfiguration Properties() { // Get the underlying type for a nullale type. (int? -> int) - Type underlyingType = Nullable.GetUnderlyingType(typeof (T)) ?? typeof (T); + var underlyingType = Nullable.GetUnderlyingType(typeof(T)) ?? typeof(T); var config = new PropertyConventionConfiguration().Where(p => p.PropertyType == underlyingType); ConventionConfigurations.Add(config); diff --git a/src/Dapper.FluentMap/Conventions/PropertyConventionConfiguration.cs b/src/Dapper.FluentMap/Conventions/PropertyConventionConfiguration.cs index cec0270..c9dbcfd 100644 --- a/src/Dapper.FluentMap/Conventions/PropertyConventionConfiguration.cs +++ b/src/Dapper.FluentMap/Conventions/PropertyConventionConfiguration.cs @@ -11,7 +11,7 @@ namespace Dapper.FluentMap.Conventions public class PropertyConventionConfiguration { /// - /// Initializes a new instance of the class, + /// Initializes a new instance of the class, /// allowing configuration for a convention. /// public PropertyConventionConfiguration() @@ -19,7 +19,7 @@ public PropertyConventionConfiguration() PropertyPredicates = new List>(); } - internal IList> PropertyPredicates { get; private set; } + internal IList> PropertyPredicates { get; } internal ConventionPropertyConfiguration PropertyConfiguration { get; private set; } @@ -37,7 +37,10 @@ public PropertyConventionConfiguration Where(Func predicate) /// /// Configures the properties that this convention applies to. /// - /// An action that performs configuration against . + /// + /// An action that performs configuration against + /// . + /// public void Configure(Action configure) { var config = new ConventionPropertyConfiguration(); diff --git a/src/Dapper.FluentMap/Dapper.FluentMap.csproj b/src/Dapper.FluentMap/Dapper.FluentMap.csproj deleted file mode 100644 index 2302b94..0000000 --- a/src/Dapper.FluentMap/Dapper.FluentMap.csproj +++ /dev/null @@ -1,74 +0,0 @@ - - - - - Debug - AnyCPU - {A04CCA46-B05D-45D7-8ADC-5CEF70D26B60} - Library - Properties - Dapper.FluentMap - Dapper.FluentMap - v4.0 - 512 - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - bin\Release\Dapper.FluentMap.XML - - - - ..\packages\Dapper.1.50.0-beta8\lib\net40\Dapper.dll - True - - - - - - - - - - - - - - - - - - - - - - - - - - Designer - - - - - \ No newline at end of file diff --git a/src/Dapper.FluentMap/Dapper.FluentMap.xproj b/src/Dapper.FluentMap/Dapper.FluentMap.xproj new file mode 100644 index 0000000..bd44fad --- /dev/null +++ b/src/Dapper.FluentMap/Dapper.FluentMap.xproj @@ -0,0 +1,19 @@ + + + + 14.0.25123 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + 457e0b9b-f6a4-42c6-bfae-6f8c71d1f435 + Dapper.FluentMap + .\obj + .\bin\ + + + + 2.0 + + + \ No newline at end of file diff --git a/src/Dapper.FluentMap/FluentMapper.cs b/src/Dapper.FluentMap/FluentMapper.cs index 2b81d91..b8622a6 100644 --- a/src/Dapper.FluentMap/FluentMapper.cs +++ b/src/Dapper.FluentMap/FluentMapper.cs @@ -1,76 +1,76 @@ -using System; -using System.Collections.Concurrent; -using System.Collections.Generic; -using Dapper.FluentMap.Configuration; -using Dapper.FluentMap.Conventions; -using Dapper.FluentMap.Mapping; -using Dapper.FluentMap.TypeMaps; - -namespace Dapper.FluentMap -{ - /// - /// Main entry point for Dapper.FluentMap configuration. - /// - public static class FluentMapper - { - private static readonly FluentMapConfiguration _configuration = new FluentMapConfiguration(); - - /// - /// Gets the dictionary containing the entity mapping per entity type. - /// - public static readonly ConcurrentDictionary EntityMaps = new ConcurrentDictionary(); - - /// - /// Gets the dictionary containing the conventions per entity type. - /// - public static readonly IDictionary> TypeConventions = new Dictionary>(); - - /// - /// Initializes Dapper.FluentMap with the specified configuration. - /// This is method should be called when the application starts or when the first mapping is needed. - /// - /// A callback containing the configuration of Dapper.FluentMap. - public static void Initialize(Action configure) - { - configure(_configuration); - } - - /// - /// Registers a Dapper type map using fluent mapping for the specified . - /// - /// The type of the entity. - internal static void AddTypeMap() - { - SqlMapper.SetTypeMap(typeof (TEntity), new FluentMapTypeMap()); - } - - /// - /// Registers a Dapper type map using fluent mapping for the specified . - /// - /// The type of the entity. - internal static void AddTypeMap(Type entityType) - { - var instance = (SqlMapper.ITypeMap)Activator.CreateInstance(typeof (FluentMapTypeMap<>).MakeGenericType(entityType)); - SqlMapper.SetTypeMap(entityType, instance); - } - - /// - /// Registers a Dapper type map using conventions for the specified . - /// - /// The type of the entity. - internal static void AddConventionTypeMap() - { - SqlMapper.SetTypeMap(typeof (TEntity), new FluentConventionTypeMap()); - } - - /// - /// Registers a Dapper type map using conventions for the specified . - /// - /// The type of the entity. - internal static void AddConventionTypeMap(Type entityType) - { - var instance = (SqlMapper.ITypeMap)Activator.CreateInstance(typeof (FluentConventionTypeMap<>).MakeGenericType(entityType)); - SqlMapper.SetTypeMap(entityType, instance); - } - } -} +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using Dapper.FluentMap.Configuration; +using Dapper.FluentMap.Conventions; +using Dapper.FluentMap.Mapping; +using Dapper.FluentMap.TypeMaps; + +namespace Dapper.FluentMap +{ + /// + /// Main entry point for Dapper.FluentMap configuration. + /// + public static class FluentMapper + { + private static readonly FluentMapConfiguration _configuration = new FluentMapConfiguration(); + + /// + /// Gets the dictionary containing the entity mapping per entity type. + /// + public static readonly ConcurrentDictionary EntityMaps = new ConcurrentDictionary(); + + /// + /// Gets the dictionary containing the conventions per entity type. + /// + public static readonly ConcurrentDictionary> TypeConventions = new ConcurrentDictionary>(); + + /// + /// Initializes Dapper.FluentMap with the specified configuration. + /// This is method should be called when the application starts or when the first mapping is needed. + /// + /// A callback containing the configuration of Dapper.FluentMap. + public static void Initialize(Action configure) + { + configure(_configuration); + } + + /// + /// Registers a Dapper type map using fluent mapping for the specified . + /// + /// The type of the entity. + internal static void AddTypeMap() + { + SqlMapper.SetTypeMap(typeof(TEntity), new FluentMapTypeMap()); + } + + /// + /// Registers a Dapper type map using fluent mapping for the specified . + /// + /// The type of the entity. + internal static void AddTypeMap(Type entityType) + { + var instance = (SqlMapper.ITypeMap)Activator.CreateInstance(typeof(FluentMapTypeMap<>).MakeGenericType(entityType)); + SqlMapper.SetTypeMap(entityType, instance); + } + + /// + /// Registers a Dapper type map using conventions for the specified . + /// + /// The type of the entity. + internal static void AddConventionTypeMap() + { + SqlMapper.SetTypeMap(typeof(TEntity), new FluentConventionTypeMap()); + } + + /// + /// Registers a Dapper type map using conventions for the specified . + /// + /// The type of the entity. + internal static void AddConventionTypeMap(Type entityType) + { + var instance = (SqlMapper.ITypeMap)Activator.CreateInstance(typeof(FluentConventionTypeMap<>).MakeGenericType(entityType)); + SqlMapper.SetTypeMap(entityType, instance); + } + } +} diff --git a/src/Dapper.FluentMap/Mapping/EntityMap.cs b/src/Dapper.FluentMap/Mapping/EntityMap.cs index f3926fa..85f5060 100644 --- a/src/Dapper.FluentMap/Mapping/EntityMap.cs +++ b/src/Dapper.FluentMap/Mapping/EntityMap.cs @@ -19,7 +19,7 @@ public interface IEntityMap } /// - /// Represents a typed mapping of an entity. + /// Represents a typed mapping of an entity. /// This serves as a marker interface for generic type inference. /// /// The type of the entity to configure the mapping for. @@ -36,7 +36,7 @@ public abstract class EntityMapBase : IEntityMap where TPropertyMap : IPropertyMap { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// protected EntityMapBase() { @@ -46,7 +46,7 @@ protected EntityMapBase() /// /// Gets the collection of mapped properties. /// - public IList PropertyMaps { get; private set; } + public IList PropertyMaps { get; } /// /// Returns an instance of which can perform custom mapping @@ -75,7 +75,7 @@ private void ThrowIfDuplicateMapping(IPropertyMap map) { if (PropertyMaps.Any(p => p.PropertyInfo.Name == map.PropertyInfo.Name)) { - throw new Exception(string.Format("Duplicate mapping detected. Property '{0}' is already mapped to column '{1}'.", map.PropertyInfo.Name, map.ColumnName)); + throw new Exception($"Duplicate mapping detected. Property '{map.PropertyInfo.Name}' is already mapped to column '{map.ColumnName}'."); } } } @@ -87,6 +87,7 @@ private void ThrowIfDuplicateMapping(IPropertyMap map) public abstract class EntityMap : EntityMapBase where TEntity : class { + /// protected override PropertyMap GetPropertyMap(PropertyInfo info) { return new PropertyMap(info); diff --git a/src/Dapper.FluentMap/Mapping/PropertyMap.cs b/src/Dapper.FluentMap/Mapping/PropertyMap.cs index 0675198..09bd82a 100644 --- a/src/Dapper.FluentMap/Mapping/PropertyMap.cs +++ b/src/Dapper.FluentMap/Mapping/PropertyMap.cs @@ -38,7 +38,7 @@ public abstract class PropertyMapBase where TPropertyMap : class, IPropertyMap { /// - /// Initializes a new instance of the using + /// Initializes a new instance of the using /// the specified object representing the property to map. /// /// The object representing to the property to map. @@ -49,8 +49,8 @@ protected PropertyMapBase(PropertyInfo info) } /// - /// Initializes a new instance of the using - /// the specified object representing the property to map + /// Initializes a new instance of the using + /// the specified object representing the property to map /// and column name to map the property to. /// /// The object representing to the property to map. @@ -62,8 +62,8 @@ internal PropertyMapBase(PropertyInfo info, string columnName) } /// - /// Initializes a new instance of the using - /// the specified object representing the property to map, + /// Initializes a new instance of the using + /// the specified object representing the property to map, /// column name to map the property to and a value indicating whether the mapping should be case sensitive. /// /// The object representing to the property to map. @@ -76,13 +76,25 @@ internal PropertyMapBase(PropertyInfo info, string columnName, bool caseSensitiv CaseSensitive = caseSensitive; } + /// + /// Gets the column name for the mapping. + /// public string ColumnName { get; private set; } + /// + /// Gets a value indicating whether this mapping is case sensitive. + /// public bool CaseSensitive { get; private set; } + /// + /// Gets a value indicating the property should be ignored when mapping. + /// public bool Ignored { get; private set; } - public PropertyInfo PropertyInfo { get; private set; } + /// + /// Gets a reference to the of this mapping. + /// + public PropertyInfo PropertyInfo { get; } /// /// Maps the current property to the specified column name. @@ -108,24 +120,28 @@ public TPropertyMap Ignore() } #region EditorBrowsableStates + /// [EditorBrowsable(EditorBrowsableState.Never)] public override string ToString() { return base.ToString(); } + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) { return base.Equals(obj); } + /// [EditorBrowsable(EditorBrowsableState.Never)] public override int GetHashCode() { return base.GetHashCode(); } + /// [EditorBrowsable(EditorBrowsableState.Never)] public new Type GetType() { @@ -140,7 +156,7 @@ public override int GetHashCode() public class PropertyMap : PropertyMapBase, IPropertyMap { /// - /// Initializes a new instance of the class + /// Initializes a new instance of the class /// with the specified object. /// /// The information about the property. @@ -150,7 +166,7 @@ public PropertyMap(PropertyInfo info) } /// - /// Initializes a new instance of the class + /// Initializes a new instance of the class /// with the specified object and column name. /// /// The information about the property. @@ -161,8 +177,8 @@ public PropertyMap(PropertyInfo info, string columnName) } /// - /// Initializes a new instance of the class - /// with the specified object, column name + /// Initializes a new instance of the class + /// with the specified object, column name /// and a value indicating whether the mapping should be case sensitive. /// /// The information about the property. diff --git a/src/Dapper.FluentMap/Properties/AssemblyInfo.cs b/src/Dapper.FluentMap/Properties/AssemblyInfo.cs deleted file mode 100644 index 03f2d49..0000000 --- a/src/Dapper.FluentMap/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Dapper.FluentMap")] -[assembly: AssemblyDescription("Provides a simple API to fluently map POCO properties to database columns when using Dapper.")] -[assembly: AssemblyConfiguration("Dapper.FluentMap extension for Dommel support.")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Dapper.FluentMap")] -[assembly: AssemblyCopyright("Copyright © 2016 Henk Mollema")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("4bec5ee4-bd0e-4760-badb-5f35d076133f")] - -[assembly: AssemblyVersion("1.5.0")] -[assembly: AssemblyInformationalVersion("1.5.0-beta1")] diff --git a/src/Dapper.FluentMap/TypeMaps/FluentConventionTypeMap.cs b/src/Dapper.FluentMap/TypeMaps/FluentConventionTypeMap.cs index 009cff5..95017ef 100644 --- a/src/Dapper.FluentMap/TypeMaps/FluentConventionTypeMap.cs +++ b/src/Dapper.FluentMap/TypeMaps/FluentConventionTypeMap.cs @@ -1,83 +1,84 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; - -using Dapper.FluentMap.Conventions; -using Dapper.FluentMap.Mapping; - -namespace Dapper.FluentMap.TypeMaps -{ - /// - /// Represents a Dapper type mapping strategy which first tries to map the type using a - /// with the configured conventions. is used as fallback mapping strategy. - /// - /// The type of the entity. - internal class FluentConventionTypeMap : MultiTypeMap - { - /// - /// Initializes a new instance of the class - /// which uses the and - /// as mapping strategies. - /// - public FluentConventionTypeMap() - : base(new CustomPropertyTypeMap(typeof(TEntity), GetPropertyInfo), new DefaultTypeMap(typeof(TEntity))) - { - } - - private static PropertyInfo GetPropertyInfo(Type type, string columnName) - { - string cacheKey = string.Format("{0};{1}", type.FullName, columnName); - - PropertyInfo info; - if (TypePropertyMapCache.TryGetValue(cacheKey, out info)) - { - return info; - } - - IList conventions; - if (FluentMapper.TypeConventions.TryGetValue(type, out conventions)) - { - foreach (var convention in conventions) - { - // Find property map for current type and column name. - var maps = convention.PropertyMaps - .Where(map => map.PropertyInfo.ReflectedType == type && - MatchColumnNames(map, columnName)) - .ToList(); - - if (maps.Count > 1) - { - const string msg = "Finding mappings for column '{0}' yielded more than 1 PropertyMap. The conventions should be more specific. Type: '{1}'. Convention: '{2}'."; - throw new Exception(string.Format(msg, columnName, type, convention)); - } - - if (maps.Count == 0) - { - // This convention has no property maps, continue to next convention. - continue; - } - - info = maps[0].PropertyInfo; - TypePropertyMapCache.TryAdd(cacheKey, info); - return info; - } - } - - // If we get here, the property was not mapped. - TypePropertyMapCache.TryAdd(cacheKey, null); - return null; - } - - private static bool MatchColumnNames(IPropertyMap map, string columnName) - { - var comparison = StringComparison.Ordinal; - if (!map.CaseSensitive) - { - comparison = StringComparison.OrdinalIgnoreCase; - } - - return string.Equals(map.ColumnName, columnName, comparison); - } - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using Dapper.FluentMap.Conventions; +using Dapper.FluentMap.Mapping; + +namespace Dapper.FluentMap.TypeMaps +{ + /// + /// Represents a Dapper type mapping strategy which first tries to map the type using a + /// + /// with the configured conventions. is used as fallback mapping strategy. + /// + /// The type of the entity. + public class FluentConventionTypeMap : MultiTypeMap + { + /// + /// Initializes a new instance of the class + /// which uses the and + /// as mapping strategies. + /// + public FluentConventionTypeMap() + : base(new CustomPropertyTypeMap(typeof(TEntity), GetPropertyInfo), new DefaultTypeMap(typeof(TEntity))) + { + } + + private static PropertyInfo GetPropertyInfo(Type type, string columnName) + { + var cacheKey = $"{type.FullName};{columnName}"; + + PropertyInfo info; + if (TypePropertyMapCache.TryGetValue(cacheKey, out info)) + { + return info; + } + + IList conventions; + if (FluentMapper.TypeConventions.TryGetValue(type, out conventions)) + { + foreach (var convention in conventions) + { + // Find property map for current type and column name. + // todo: ReflectedType is unavailable on CoreFX + var maps = convention.PropertyMaps + .Where(map => map.PropertyInfo.DeclaringType == type && + MatchColumnNames(map, columnName)) + .ToList(); + + if (maps.Count > 1) + { + const string msg = "Finding mappings for column '{0}' yielded more than 1 PropertyMap. The conventions should be more specific. Type: '{1}'. Convention: '{2}'."; + throw new Exception(string.Format(msg, columnName, type, convention)); + } + + if (maps.Count == 0) + { + // This convention has no property maps, continue to next convention. + continue; + } + + info = maps[0].PropertyInfo; + TypePropertyMapCache.TryAdd(cacheKey, info); + return info; + } + } + + // If we get here, the property was not mapped. + TypePropertyMapCache.TryAdd(cacheKey, null); + return null; + } + + private static bool MatchColumnNames(IPropertyMap map, string columnName) + { + var comparison = StringComparison.Ordinal; + if (!map.CaseSensitive) + { + comparison = StringComparison.OrdinalIgnoreCase; + } + + return string.Equals(map.ColumnName, columnName, comparison); + } + } +} diff --git a/src/Dapper.FluentMap/TypeMaps/FluentTypeMap.cs b/src/Dapper.FluentMap/TypeMaps/FluentTypeMap.cs index bda2aaa..8d99e84 100644 --- a/src/Dapper.FluentMap/TypeMaps/FluentTypeMap.cs +++ b/src/Dapper.FluentMap/TypeMaps/FluentTypeMap.cs @@ -1,70 +1,70 @@ -using System; -using System.Linq; -using System.Reflection; - -using Dapper.FluentMap.Mapping; - -namespace Dapper.FluentMap.TypeMaps -{ - /// - /// Represents a Dapper type mapping strategy which first tries to map the type using a , - /// if that fails, the is used as mapping strategy. - /// - /// The type of the entity. - internal class FluentMapTypeMap : MultiTypeMap - { - /// - /// Initializes a new instance of the class - /// which uses the and - /// as mapping strategies. - /// - public FluentMapTypeMap() - : base(new CustomPropertyTypeMap(typeof(TEntity), GetPropertyInfo), new DefaultTypeMap(typeof(TEntity))) - { - } - - private static PropertyInfo GetPropertyInfo(Type type, string columnName) - { - string cacheKey = string.Format("{0};{1}", type.FullName, columnName); - - PropertyInfo info; - if (TypePropertyMapCache.TryGetValue(cacheKey, out info)) - { - return info; - } - - IEntityMap entityMap; - if (FluentMapper.EntityMaps.TryGetValue(type, out entityMap)) - { - var propertyMaps = entityMap.PropertyMaps; - - // Find the mapping for the column name. - var propertyMap = propertyMaps.FirstOrDefault(m => MatchColumnNames(m, columnName)); - - if (propertyMap != null) - { - if (!propertyMap.Ignored) - { - TypePropertyMapCache.TryAdd(cacheKey, propertyMap.PropertyInfo); - return propertyMap.PropertyInfo; - } - } - } - - // If we get here, the property was not mapped. - TypePropertyMapCache.TryAdd(cacheKey, null); - return null; - } - - private static bool MatchColumnNames(IPropertyMap map, string columnName) - { - var comparison = StringComparison.Ordinal; - if (!map.CaseSensitive) - { - comparison = StringComparison.OrdinalIgnoreCase; - } - - return string.Equals(map.ColumnName, columnName, comparison); - } - } -} +using System; +using System.Linq; +using System.Reflection; +using Dapper.FluentMap.Mapping; + +namespace Dapper.FluentMap.TypeMaps +{ + /// + /// Represents a Dapper type mapping strategy which first tries to map the type using a + /// , + /// if that fails, the is used as mapping strategy. + /// + /// The type of the entity. + public class FluentMapTypeMap : MultiTypeMap + { + /// + /// Initializes a new instance of the class + /// which uses the and + /// as mapping strategies. + /// + public FluentMapTypeMap() + : base(new CustomPropertyTypeMap(typeof(TEntity), GetPropertyInfo), new DefaultTypeMap(typeof(TEntity))) + { + } + + private static PropertyInfo GetPropertyInfo(Type type, string columnName) + { + var cacheKey = $"{type.FullName};{columnName}"; + + PropertyInfo info; + if (TypePropertyMapCache.TryGetValue(cacheKey, out info)) + { + return info; + } + + IEntityMap entityMap; + if (FluentMapper.EntityMaps.TryGetValue(type, out entityMap)) + { + var propertyMaps = entityMap.PropertyMaps; + + // Find the mapping for the column name. + var propertyMap = propertyMaps.FirstOrDefault(m => MatchColumnNames(m, columnName)); + + if (propertyMap != null) + { + if (!propertyMap.Ignored) + { + TypePropertyMapCache.TryAdd(cacheKey, propertyMap.PropertyInfo); + return propertyMap.PropertyInfo; + } + } + } + + // If we get here, the property was not mapped. + TypePropertyMapCache.TryAdd(cacheKey, null); + return null; + } + + private static bool MatchColumnNames(IPropertyMap map, string columnName) + { + var comparison = StringComparison.Ordinal; + if (!map.CaseSensitive) + { + comparison = StringComparison.OrdinalIgnoreCase; + } + + return string.Equals(map.ColumnName, columnName, comparison); + } + } +} diff --git a/src/Dapper.FluentMap/TypeMaps/MultiTypeMap.cs b/src/Dapper.FluentMap/TypeMaps/MultiTypeMap.cs index b4cb7ba..86052dc 100644 --- a/src/Dapper.FluentMap/TypeMaps/MultiTypeMap.cs +++ b/src/Dapper.FluentMap/TypeMaps/MultiTypeMap.cs @@ -8,10 +8,9 @@ namespace Dapper.FluentMap.TypeMaps /// /// Represents a Dapper type mapping strategy which consists of multiple strategies. /// - internal abstract class MultiTypeMap : SqlMapper.ITypeMap + public abstract class MultiTypeMap : SqlMapper.ITypeMap { private readonly IEnumerable _mappers; - private static readonly ConcurrentDictionary _typePropertyMapCache = new ConcurrentDictionary(); /// /// Initializes an instance of the @@ -23,6 +22,7 @@ protected MultiTypeMap(params SqlMapper.ITypeMap[] mappers) _mappers = mappers; } + /// public ConstructorInfo FindConstructor(string[] names, Type[] types) { foreach (var mapper in _mappers) @@ -46,6 +46,7 @@ public ConstructorInfo FindConstructor(string[] names, Type[] types) return null; } + /// public ConstructorInfo FindExplicitConstructor() { foreach (var mapper in _mappers) @@ -68,6 +69,7 @@ public ConstructorInfo FindExplicitConstructor() return null; } + /// public SqlMapper.IMemberMap GetConstructorParameter(ConstructorInfo constructor, string columnName) { foreach (var mapper in _mappers) @@ -91,6 +93,7 @@ public SqlMapper.IMemberMap GetConstructorParameter(ConstructorInfo constructor, return null; } + /// public SqlMapper.IMemberMap GetMember(string columnName) { foreach (var mapper in _mappers) @@ -113,12 +116,9 @@ public SqlMapper.IMemberMap GetMember(string columnName) return null; } - protected static ConcurrentDictionary TypePropertyMapCache - { - get - { - return _typePropertyMapCache; - } - } + /// + /// Gets a cache for columns and properties. + /// + protected static ConcurrentDictionary TypePropertyMapCache { get; } = new ConcurrentDictionary(); } } diff --git a/src/Dapper.FluentMap/packages.config b/src/Dapper.FluentMap/packages.config deleted file mode 100644 index a4852e8..0000000 --- a/src/Dapper.FluentMap/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/src/Dapper.FluentMap/project.json b/src/Dapper.FluentMap/project.json new file mode 100644 index 0000000..13b6997 --- /dev/null +++ b/src/Dapper.FluentMap/project.json @@ -0,0 +1,44 @@ +{ + "version": "1.5.0", + "description": "Simple API to fluently map POCO properties to database columns when using Dapper.", + "authors": [ "Henk Mollema" ], + "copyright": "Copyright © Henk Mollema 2016", + "packOptions": { + "licenseUrl": "https://github.com/henkmollema/Dapper-FluentMap/blob/master/LICENSE", + "owners": [ "Henk Mollema" ], + "projectUrl": "https://github.com/henkmollema/Dapper-FluentMap", + "tags": [ "c#", "dapper", "mapping", "fluentmap" ] + }, + + "dependencies": { + "Dapper": "1.50.0-rc2b" + }, + + "frameworks": { + "net40": { + "frameworkAssemblies": { + "System.Data": "4.0.0.0" + } + }, + + "net451": { + "frameworkAssemblies": { + "System.Data": "4.0.0.0" + } + }, + + "netstandard1.3": { + "buildOptions": { + "define": [ "COREFX" ] + }, + "dependencies": { + "NETStandard.Library": "1.5.0-rc2-24027", + "System.Reflection.TypeExtensions": "4.1.0-rc2-24027" + } + } + }, + + "buildOptions": { + "xmlDoc": true + } +} diff --git a/test/Dapper.FluentMap.Tests/ConventionTests.cs b/test/Dapper.FluentMap.Tests/ConventionTests.cs new file mode 100644 index 0000000..d80c3eb --- /dev/null +++ b/test/Dapper.FluentMap.Tests/ConventionTests.cs @@ -0,0 +1,58 @@ +using Dapper.FluentMap.Conventions; +using Xunit; + +#if COREFX +using System.Reflection; +#endif + +namespace Dapper.FluentMap.Tests +{ + public class ConventionTests + { +#if NET451 + [Fact] + public void ShouldMapEntitiesInCurrentAssembly() + { + PreTest(); + + // Arrange & Act + FluentMapper.Initialize(c => c.AddConvention().ForEntitiesInCurrentAssembly()); + + // Asert + Assert.True(FluentMapper.TypeConventions.ContainsKey(typeof(TestEntity))); + var map = FluentMapper.TypeConventions[typeof(TestEntity)]; + Assert.True(map[0] is TestConvention); + } +#elif COREFX + [Fact] + public void ShouldMapEntitiesInCurrentAssembly() + { + PreTest(); + + // Arrange & Act + FluentMapper.Initialize(c => c.AddConvention().ForEntitiesInAssembly(typeof(ConventionTests).GetTypeInfo().Assembly)); + + // Asert + Assert.True(FluentMapper.TypeConventions.ContainsKey(typeof(TestEntity))); + var map = FluentMapper.TypeConventions[typeof(TestEntity)]; + Assert.True(map[0] is TestConvention); + } +#endif + + private class TestConvention : Convention + { + public TestConvention() + { + Properties(). + Where(p => p.Name.ToLower() == "id") + .Configure(c => c.HasColumnName("autID")); + } + } + + private static void PreTest() + { + FluentMapper.EntityMaps.Clear(); + FluentMapper.TypeConventions.Clear(); + } + } +} diff --git a/test/Dapper.FluentMap.Tests/Dapper.FluentMap.Tests.xproj b/test/Dapper.FluentMap.Tests/Dapper.FluentMap.Tests.xproj new file mode 100644 index 0000000..b90448a --- /dev/null +++ b/test/Dapper.FluentMap.Tests/Dapper.FluentMap.Tests.xproj @@ -0,0 +1,19 @@ + + + + 14.0.25123 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + 8901f2fd-f98b-484b-a20a-7844a39c7458 + Dapper.FluentMap.Tests + .\obj + .\bin\ + + + + 2.0 + + + \ No newline at end of file diff --git a/src/Dapper.FluentMap.Tests/ManualMappingTests.cs b/test/Dapper.FluentMap.Tests/ManualMappingTests.cs similarity index 50% rename from src/Dapper.FluentMap.Tests/ManualMappingTests.cs rename to test/Dapper.FluentMap.Tests/ManualMappingTests.cs index c761f87..fb2f5a4 100644 --- a/src/Dapper.FluentMap.Tests/ManualMappingTests.cs +++ b/test/Dapper.FluentMap.Tests/ManualMappingTests.cs @@ -1,149 +1,192 @@ -using System; -using System.Linq; -using Dapper.FluentMap.Mapping; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace Dapper.FluentMap.Tests -{ - [TestClass] - public class ManualMappingTests - { - [TestMethod] - [ExpectedException(typeof (Exception))] - public void Duplicate_Mapping_Should_Throw_Exception() - { - PreTest(); - var map = new MapWithDuplicateMapping(); - } - - [TestMethod] - public void EntityMap_Should_Have_Empty_PropertyMap_Collection() - { - PreTest(); - var map = new EmptyMap(); - Assert.IsNotNull(map.PropertyMaps, "PropertyMaps collection is not initialized with an empty list."); - } - - [TestMethod] - public void EntityMap_Should_Have_PropertyMap() - { - PreTest(); - var map = new MapWithOnePropertyMap(); - Assert.IsNotNull(map.PropertyMaps, "PropertyMaps collection is not initialized with an empty list."); - Assert.IsTrue(map.PropertyMaps.Count == 1, "PropertyMaps has less or more than 1 item."); - } - - [TestMethod] - public void PropertyMap_Should_Be_CaseInsensitive() - { - PreTest(); - var map = new CaseInsensitveMap(); - var propertyMap = map.PropertyMaps.Single(); - Assert.IsTrue(propertyMap.ColumnName == "test", "ColumnName of PropertyMap is incorrect."); - Assert.IsFalse(propertyMap.CaseSensitive, "PropertyMap is not case insensitive."); - } - - [TestMethod] - public void Property_Should_Be_Ignored() - { - PreTest(); - var map = new IgnoreMap(); - var propertyMap = map.PropertyMaps.Single(); - Assert.IsTrue(propertyMap.Ignored, "Property is not ignored."); - } - - [TestMethod] - public void PropertyInfo_Name_Should_Be_Id() - { - PreTest(); - var map = new MapWithOnePropertyMap(); - var propertyMap = map.PropertyMaps.Single(); - Assert.IsTrue(propertyMap.PropertyInfo.Name == "Id", "PropertyInfo.Name is not the same as expression property."); - } - - [TestMethod] - public void FluentMapper_Initialize_Should_Add_EntityMap() - { - PreTest(); - FluentMapper.Initialize(c => c.AddMap(new MapWithOnePropertyMap())); - Assert.IsTrue(FluentMapper.EntityMaps.Count == 1, "FluentMapper.EntityMaps contains less or more than 1 mapping."); - - var entityMap = FluentMapper.EntityMaps.Single(); - Assert.IsTrue(entityMap.Key == typeof (TestEntity), "EntityMap entity type is not correct."); - Assert.IsTrue(entityMap.Value is MapWithOnePropertyMap, "EntityMap type is not correct."); - } - - [TestMethod] - public void FluentMapper_Initialize_Should_Add_Dapper_TypeMap() - { - PreTest(); - FluentMapper.Initialize(c => c.AddMap(new MapWithOnePropertyMap())); - SqlMapper.ITypeMap typeMap = SqlMapper.GetTypeMap(typeof (TestEntity)); - Assert.IsNotNull(typeMap, "TypeMap is null."); - } - - [TestMethod] - public void PropertyMap_ShouldMapInheritedProperies() - { - PreTest(); - var map = new DerivedMap(); - var idMap = map.PropertyMaps.First(); - Assert.IsTrue(idMap.PropertyInfo.ReflectedType == typeof (DerivedTestEntity)); - - var nameName = map.PropertyMaps.Skip(1).First(); - Assert.IsTrue(nameName.PropertyInfo.ReflectedType == typeof(DerivedTestEntity)); - } - - private static void PreTest() - { - FluentMapper.EntityMaps.Clear(); - FluentMapper.TypeConventions.Clear(); - } - - private class IgnoreMap : EntityMap - { - public IgnoreMap() - { - Map(p => p.Id).Ignore(); - } - } - - private class CaseInsensitveMap : EntityMap - { - public CaseInsensitveMap() - { - Map(p => p.Id).ToColumn("test", caseSensitive: false); - } - } - - private class MapWithOnePropertyMap : EntityMap - { - public MapWithOnePropertyMap() - { - Map(p => p.Id).ToColumn("test"); - } - } - - private class DerivedMap : EntityMap - { - public DerivedMap() - { - Map(p => p.Id).ToColumn("intId"); - Map(p => p.Name).ToColumn("strName"); - } - } - - private class MapWithDuplicateMapping : EntityMap - { - public MapWithDuplicateMapping() - { - Map(p => p.Id).ToColumn("id"); - Map(p => p.Id).ToColumn("id2"); - } - } - - private class EmptyMap : EntityMap - { - } - } -} +using System; +using System.Linq; +using Dapper.FluentMap.Mapping; +using Dapper.FluentMap.TypeMaps; +using Xunit; + +namespace Dapper.FluentMap.Tests +{ + public class ManualMappingTests + { + [Fact] + public void DuplicateMappingShouldThrow_Exception() + { + // Arrange + PreTest(); + + // Act & Assert + Assert.Throws(() => new MapWithDuplicateMapping()); + } + + [Fact] + public void EntityMapShouldHaveEmptyPropertyMapCollection() + { + // Arrange + PreTest(); + + // Act + var map = new EmptyMap(); + + // Assert + Assert.NotNull(map.PropertyMaps); + Assert.Empty(map.PropertyMaps); + } + + [Fact] + public void EntityMapShouldHavePropertyMap() + { + // Arrange + PreTest(); + + // Act + var map = new MapWithOnePropertyMap(); + + // Assert + Assert.NotEmpty(map.PropertyMaps); + Assert.Equal(1, map.PropertyMaps.Count); + } + + [Fact] + public void PropertyMapShouldBeCaseInsensitive() + { + // Arrange + PreTest(); + + // Act + var map = new CaseInsensitveMap(); + var propertyMap = map.PropertyMaps.Single(); + + // Assert + Assert.Equal("Test", propertyMap.ColumnName, ignoreCase: true); + Assert.False(propertyMap.CaseSensitive); + } + + [Fact] + public void PropertyShouldBeIgnored() + { + // Arrange + PreTest(); + + // Act + var map = new IgnoreMap(); + var propertyMap = map.PropertyMaps.Single(); + + // Assert + Assert.True(propertyMap.Ignored); + } + + [Fact] + public void PropertyInfoNameShouldBeId() + { + // Arrange + PreTest(); + + // Act + var map = new MapWithOnePropertyMap(); + var propertyMap = map.PropertyMaps.Single(); + + // Assert + Assert.Equal("Id", propertyMap.PropertyInfo.Name); + } + + [Fact] + public void FluentMapperInitializeShouldAddEntityMap() + { + // Arrange + PreTest(); + + // Act + FluentMapper.Initialize(c => c.AddMap(new MapWithOnePropertyMap())); + var entityMap = FluentMapper.EntityMaps.Single(); + + // Assert + Assert.Equal(1, FluentMapper.EntityMaps.Count); + Assert.Equal(typeof(TestEntity), entityMap.Key); + Assert.IsType(entityMap.Value); + } + + [Fact] + public void FluentMapperInitializeShouldAddDapperTypeMap() + { + // Arrange + PreTest(); + + // Act + FluentMapper.Initialize(c => c.AddMap(new MapWithOnePropertyMap())); + var typeMap = SqlMapper.GetTypeMap(typeof(TestEntity)); + + // Assert + Assert.NotNull(typeMap); + Assert.IsType>(typeMap); + } + + [Fact] + public void PropertyMapShouldMapInheritedProperies() + { + // Arrange + PreTest(); + + // Act + var map = new DerivedMap(); + var idMap = map.PropertyMaps.First(); + var nameMap = map.PropertyMaps.Skip(1).First(); + + // Assert + // todo: should be ReflectedType so the type is DerivedTestEntity + Assert.Equal(typeof(TestEntity), idMap.PropertyInfo.DeclaringType); + Assert.Equal(typeof(DerivedTestEntity), nameMap.PropertyInfo.DeclaringType); + } + + private static void PreTest() + { + FluentMapper.EntityMaps.Clear(); + FluentMapper.TypeConventions.Clear(); + } + + private class IgnoreMap : EntityMap + { + public IgnoreMap() + { + Map(p => p.Id).Ignore(); + } + } + + private class CaseInsensitveMap : EntityMap + { + public CaseInsensitveMap() + { + Map(p => p.Id).ToColumn("test", caseSensitive: false); + } + } + + private class MapWithOnePropertyMap : EntityMap + { + public MapWithOnePropertyMap() + { + Map(p => p.Id).ToColumn("test"); + } + } + + private class DerivedMap : EntityMap + { + public DerivedMap() + { + Map(p => p.Id).ToColumn("intId"); + Map(p => p.Name).ToColumn("strName"); + } + } + + private class MapWithDuplicateMapping : EntityMap + { + public MapWithDuplicateMapping() + { + Map(p => p.Id).ToColumn("id"); + Map(p => p.Id).ToColumn("id2"); + } + } + + private class EmptyMap : EntityMap + { + } + } +} diff --git a/src/Dapper.FluentMap.Dommel/Properties/AssemblyInfo.cs b/test/Dapper.FluentMap.Tests/Properties/AssemblyInfo.cs similarity index 66% rename from src/Dapper.FluentMap.Dommel/Properties/AssemblyInfo.cs rename to test/Dapper.FluentMap.Tests/Properties/AssemblyInfo.cs index abeda41..8b892e0 100644 --- a/src/Dapper.FluentMap.Dommel/Properties/AssemblyInfo.cs +++ b/test/Dapper.FluentMap.Tests/Properties/AssemblyInfo.cs @@ -1,26 +1,23 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Dapper.FluentMap.Dommel")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Dapper.FluentMap.Dommel")] -[assembly: AssemblyCopyright("Copyright © 2016 Henk Mollema")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("ef9b2624-ef04-4231-8f5a-55c41929b4a1")] - -[assembly: AssemblyVersion("1.3.0")] -[assembly: AssemblyInformationalVersion("1.3.0-beta1")] +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Dapper.FluentMap.Tests")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Dapper.FluentMap.Tests")] +[assembly: AssemblyCopyright("Copyright © 2015")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("ff3fae2a-eb78-46cc-b049-ed4f5123bc4b")] diff --git a/src/Dapper.FluentMap.Tests/TestEntity.cs b/test/Dapper.FluentMap.Tests/TestEntity.cs similarity index 99% rename from src/Dapper.FluentMap.Tests/TestEntity.cs rename to test/Dapper.FluentMap.Tests/TestEntity.cs index d93a3f0..44bfd8c 100644 --- a/src/Dapper.FluentMap.Tests/TestEntity.cs +++ b/test/Dapper.FluentMap.Tests/TestEntity.cs @@ -9,4 +9,4 @@ public class DerivedTestEntity : TestEntity { public string Name { get; set; } } -} \ No newline at end of file +} diff --git a/test/Dapper.FluentMap.Tests/project.json b/test/Dapper.FluentMap.Tests/project.json new file mode 100644 index 0000000..954e64c --- /dev/null +++ b/test/Dapper.FluentMap.Tests/project.json @@ -0,0 +1,28 @@ +{ + "dependencies": { + "Dapper.FluentMap": "1.5.0", + "xunit": "2.1.0", + "dotnet-test-xunit": "1.0.0-rc2-build10015", + "Microsoft.NETCore.Platforms": "1.0.1-rc2-24027" + }, + + "frameworks": { + "netcoreapp1.0": { + "buildOptions": { + "define": [ "COREFX" ] + }, + "dependencies": { + "Microsoft.NETCore.App": { + "version": "1.0.0-rc2-3002702", + "type": "platform" + } + }, + "imports": [ + "dnxcore50", + "portable-net451+win8" + ] + } + }, + + "testRunner": "xunit" +}