├── .gitignore
├── .nuget
└── packages.config
├── Commands.txt
├── Dapper.EntityFramework.Extensions.nuspec
├── Dapper.EntityFramework.Extensions.sln
├── Dapper.EntityFramework.Extensions.v12.suo
├── Dapper.EntityFramework.Extensions
├── App.config
├── Dapper.EntityFramework.Extensions.csproj
├── Extensions.cs
├── Properties
│ └── AssemblyInfo.cs
└── packages.config
├── README.md
└── Test
├── App.config
├── Models
├── Blog.cs
├── BlogPost.cs
├── BlogSettings.cs
├── Gender.cs
├── TestContext.Context.cs
├── TestContext.Context.tt
├── TestContext.Designer.cs
├── TestContext.cs
├── TestContext.edmx
├── TestContext.edmx.diagram
├── TestContext.tt
├── User.cs
└── sysdiagram.cs
├── Program.cs
├── Properties
└── AssemblyInfo.cs
├── Test.csproj
└── packages.config
/.gitignore:
--------------------------------------------------------------------------------
1 | bin/
2 | obj/
3 | *.nupkg
4 |
--------------------------------------------------------------------------------
/.nuget/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Commands.txt:
--------------------------------------------------------------------------------
1 | (*) GENERATE PACKAGE
2 |
3 | NuGet.exe pack .\Dapper.EntityFramework.Extensions.nuspec
4 | NuGet.exe pack .\Dapper.EntityFramework.Extensions.nuspec -Version 1.8.0.1
5 | NuGet.exe pack Dapper.EntityFramework.Extensions\Dapper.EntityFramework.Extensions.csproj -Build -Symbols -Properties Configuration=Release
6 |
7 | (*) PUSH PACKAGE
8 | NuGet.exe setapikey [APIKEY]
9 | NuGet.exe push Dapper.EntityFramework.Extensions.1.8.0.1.nupkg
10 |
11 |
--------------------------------------------------------------------------------
/Dapper.EntityFramework.Extensions.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Dapper.EntityFramework.Extensions
5 | 1.8.0.1
6 | Dapper entity framework extensions
7 | Thiago Amarante
8 | Thiago Amarante
9 | http://www.apache.org/licenses/LICENSE-2.0
10 | https://github.com/thiagoamarante/Dapper.EntityFramework.Extensions
11 | false
12 |
13 | Extension for EntityFramework
14 | Library brings together the best of the EntityFramework with Dapper.
15 | Basic CRUD operations (Query, Insert, Update, Delete) for your POCOs.
16 |
17 | Adds support for methods dapper in DbSet and Crud
18 | orm sql micro-orm entityframework entity framework extensions
19 | http://go.microsoft.com/fwlink/?LinkID=386613
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 | (*) Release 1.8.0.1
33 | - Support DbGeography/DbGeometry
34 |
35 | (*) Release 1.7.0.1
36 | - Insert optional return identity
37 | - Insert return identity object type
38 | - Insert and Update can change PropertyKey
39 | - Insert and Update automatic removes property of different kind of primitive and enum
40 |
41 | (*) Release 1.7.0.0
42 | - New method Query and Query with selector
43 | - Query support top
44 | - Query support where
45 | - Query support orderby
46 | - Query support selector
47 |
48 | (*) Release 1.6.0.1
49 | - Support schemas
50 | - Support EntityFramework in Transaction
51 | - Support CommandTimeout DbContext
52 |
53 |
54 |
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/Dapper.EntityFramework.Extensions.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2013
4 | VisualStudioVersion = 12.0.31101.0
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dapper.EntityFramework.Extensions", "Dapper.EntityFramework.Extensions\Dapper.EntityFramework.Extensions.csproj", "{D10801FF-2C63-4180-BFD9-A92BFCF9E2F8}"
7 | EndProject
8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{6D0D1E42-C01E-45B1-A437-26B1C8FF3906}"
9 | ProjectSection(SolutionItems) = preProject
10 | Commands.txt = Commands.txt
11 | Dapper.EntityFramework.Extensions.nuspec = Dapper.EntityFramework.Extensions.nuspec
12 | README.md = README.md
13 | EndProjectSection
14 | EndProject
15 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{8F8C8CB9-4281-469F-AE49-B197AC64CD23}"
16 | ProjectSection(SolutionItems) = preProject
17 | .nuget\packages.config = .nuget\packages.config
18 | EndProjectSection
19 | EndProject
20 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "Test\Test.csproj", "{65A076AA-3E50-4A39-AAAB-16CCC9BE694E}"
21 | EndProject
22 | Global
23 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
24 | Debug|Any CPU = Debug|Any CPU
25 | Release|Any CPU = Release|Any CPU
26 | EndGlobalSection
27 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
28 | {D10801FF-2C63-4180-BFD9-A92BFCF9E2F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
29 | {D10801FF-2C63-4180-BFD9-A92BFCF9E2F8}.Debug|Any CPU.Build.0 = Debug|Any CPU
30 | {D10801FF-2C63-4180-BFD9-A92BFCF9E2F8}.Release|Any CPU.ActiveCfg = Release|Any CPU
31 | {D10801FF-2C63-4180-BFD9-A92BFCF9E2F8}.Release|Any CPU.Build.0 = Release|Any CPU
32 | {65A076AA-3E50-4A39-AAAB-16CCC9BE694E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
33 | {65A076AA-3E50-4A39-AAAB-16CCC9BE694E}.Debug|Any CPU.Build.0 = Debug|Any CPU
34 | {65A076AA-3E50-4A39-AAAB-16CCC9BE694E}.Release|Any CPU.ActiveCfg = Release|Any CPU
35 | {65A076AA-3E50-4A39-AAAB-16CCC9BE694E}.Release|Any CPU.Build.0 = Release|Any CPU
36 | EndGlobalSection
37 | GlobalSection(SolutionProperties) = preSolution
38 | HideSolutionNode = FALSE
39 | EndGlobalSection
40 | EndGlobal
41 |
--------------------------------------------------------------------------------
/Dapper.EntityFramework.Extensions.v12.suo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thiagoamarante/Dapper.EntityFramework.Extensions/543da01abfe01ea2d1b9e6935f79db2e721c75b4/Dapper.EntityFramework.Extensions.v12.suo
--------------------------------------------------------------------------------
/Dapper.EntityFramework.Extensions/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/Dapper.EntityFramework.Extensions/Dapper.EntityFramework.Extensions.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {D10801FF-2C63-4180-BFD9-A92BFCF9E2F8}
8 | Library
9 | Properties
10 | Dapper.EntityFramework.Extensions
11 | Dapper.EntityFramework.Extensions
12 | v4.5
13 | 512
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | true
25 | full
26 | false
27 | bin\Debug\
28 | DEBUG;TRACE
29 | prompt
30 | 4
31 |
32 |
33 | pdbonly
34 | true
35 | bin\Release\
36 | TRACE
37 | prompt
38 | 4
39 |
40 |
41 |
42 | ..\..\..\..\Packages\Dapper.1.42\lib\net45\Dapper.dll
43 | True
44 |
45 |
46 | ..\..\..\..\Packages\Dapper.EntityFramework.1.33\lib\net45\Dapper.EntityFramework.dll
47 | True
48 |
49 |
50 | ..\..\..\..\Packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll
51 | True
52 |
53 |
54 | ..\..\..\..\Packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll
55 | True
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
82 |
--------------------------------------------------------------------------------
/Dapper.EntityFramework.Extensions/Extensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Data.Entity;
4 | using System.Data.Entity.Core.Objects;
5 | using System.Data.Entity.Infrastructure;
6 | using System.Linq;
7 | using System.Linq.Expressions;
8 | using System.Reflection;
9 | using Dapper;
10 | using System.Dynamic;
11 | using System.Collections.Concurrent;
12 | using System.Reflection.Emit;
13 | using System.Threading;
14 | using System.Diagnostics;
15 | using System.Collections;
16 | using System.Data.Entity.Core.Metadata.Edm;
17 |
18 | namespace Dapper
19 | {
20 | public static class Extensions
21 | {
22 | private static bool _Init = false;
23 | private static Dictionary _CacheTable = new Dictionary();
24 | private static string[] AcceptTypes = new string[] { "System.Data.Entity.Spatial.DbGeometry", "System.Data.Entity.Spatial.DbGeography" };
25 |
26 | #region Methods
27 | public static object Insert(this DbSet source, object entity, bool returnIdentity = true, string propertyKey = "Id")
28 | where TEntity : class
29 | {
30 | Init();
31 | #if DEBUG
32 | var watch = LogStart("INSERT");
33 | #endif
34 | var context = source.GetDbContext();
35 | #if DEBUG
36 | LogElapsed(watch, "GetDbContext");
37 | #endif
38 |
39 | string table = GetTableName(context);
40 | string[] properties = entity.GetType().GetProperties().Where(o => (o.PropertyType.IsEnum || AcceptTypes.Contains(o.PropertyType.FullName) || Type.GetTypeCode(o.PropertyType) != TypeCode.Object) && o.Name != propertyKey).Select(o => o.Name).ToArray();
41 | string sql = string.Concat("INSERT INTO ", table, " (",
42 | string.Join(", ", properties.Select(o => string.Concat("[", o, "]"))),
43 | ") VALUES(",
44 | string.Join(", ", properties.Select(o => "@" + o)), ");");
45 |
46 | if (returnIdentity)
47 | sql += " SELECT SCOPE_IDENTITY()";
48 |
49 | #if DEBUG
50 | LogElapsed(watch, "Parse");
51 | #endif
52 | var result = context.Database.Connection.ExecuteScalar