├── .editorconfig
├── .gitattributes
├── .github
├── FUNDING.yml
├── ISSUE_TEMPLATE
│ └── bug_report.md
└── workflows
│ ├── cla.yml
│ └── main.yml
├── .gitignore
├── Build.csproj
├── Dapper.EntityFramework.StrongName
└── Dapper.EntityFramework.StrongName.csproj
├── Dapper.EntityFramework
├── Dapper.EntityFramework.csproj
├── DbGeographyHandler.cs
├── DbGeometryHandler.cs
├── Handlers.cs
├── PublicAPI.Shipped.txt
└── PublicAPI.Unshipped.txt
├── Dapper.ProviderTools
├── BulkCopy.cs
├── Dapper.ProviderTools.csproj
├── DbConnectionExtensions.cs
├── DbExceptionExtensions.cs
├── Internal
│ └── DynamicBulkCopy.cs
├── PublicAPI.Shipped.txt
└── PublicAPI.Unshipped.txt
├── Dapper.Rainbow
├── Dapper.Rainbow.csproj
├── Database.Async.cs
├── Database.cs
├── IgnorePropertyAttribute.cs
├── Snapshotter.cs
├── SqlCompactDatabase.cs
└── readme.md
├── Dapper.SqlBuilder
├── Dapper.SqlBuilder.csproj
├── PublicAPI.Shipped.txt
├── PublicAPI.Unshipped.txt
├── Readme.md
└── SqlBuilder.cs
├── Dapper.StrongName
└── Dapper.StrongName.csproj
├── Dapper.png
├── Dapper.sln
├── Dapper.sln.DotSettings
├── Dapper.snk
├── Dapper
├── CommandDefinition.cs
├── CommandFlags.cs
├── CompiledRegex.cs
├── CustomPropertyTypeMap.cs
├── Dapper.csproj
├── DataTableHandler.cs
├── DbString.cs
├── DefaultTypeMap.cs
├── DynamicParameters.CachedOutputSetters.cs
├── DynamicParameters.ParamInfo.cs
├── DynamicParameters.cs
├── ExplicitConstructorAttribute.cs
├── Extensions.cs
├── FeatureSupport.cs
├── Global.cs
├── NRT.cs
├── Properties
│ └── AssemblyInfo.cs
├── PublicAPI.Shipped.txt
├── PublicAPI.Unshipped.txt
├── PublicAPI
│ ├── net461
│ │ ├── PublicAPI.Shipped.txt
│ │ └── PublicAPI.Unshipped.txt
│ ├── net8.0
│ │ ├── PublicAPI.Shipped.txt
│ │ └── PublicAPI.Unshipped.txt
│ └── netstandard2.0
│ │ ├── PublicAPI.Shipped.txt
│ │ └── PublicAPI.Unshipped.txt
├── SimpleMemberMap.cs
├── SqlDataRecordHandler.cs
├── SqlDataRecordListTVPParameter.cs
├── SqlMapper.Async.cs
├── SqlMapper.CacheInfo.cs
├── SqlMapper.DapperRow.Descriptor.cs
├── SqlMapper.DapperRow.cs
├── SqlMapper.DapperRowMetaObject.cs
├── SqlMapper.DapperTable.cs
├── SqlMapper.DeserializerState.cs
├── SqlMapper.DontMap.cs
├── SqlMapper.GridReader.Async.cs
├── SqlMapper.GridReader.cs
├── SqlMapper.ICustomQueryParameter.cs
├── SqlMapper.IDataReader.cs
├── SqlMapper.IDynamicParameters.cs
├── SqlMapper.IMemberMap.cs
├── SqlMapper.IParameterCallbacks.cs
├── SqlMapper.IParameterLookup.cs
├── SqlMapper.ITypeHandler.cs
├── SqlMapper.ITypeMap.cs
├── SqlMapper.Identity.cs
├── SqlMapper.Link.cs
├── SqlMapper.LiteralToken.cs
├── SqlMapper.Settings.cs
├── SqlMapper.TypeDeserializerCache.cs
├── SqlMapper.TypeHandler.cs
├── SqlMapper.TypeHandlerCache.cs
├── SqlMapper.cs
├── TableValuedParameter.cs
├── TypeExtensions.cs
├── UdtTypeHandler.cs
├── WrappedDataReader.cs
├── WrappedReader.cs
└── XmlHandlers.cs
├── Directory.Build.props
├── Directory.Build.targets
├── Directory.Packages.props
├── License.txt
├── NonCLA.md
├── Readme.md
├── appveyor.yml
├── benchmarks
├── Dapper.Tests.Performance
│ ├── Benchmarks.Belgrade.cs
│ ├── Benchmarks.Dapper.cs
│ ├── Benchmarks.Dashing.cs
│ ├── Benchmarks.EntityFramework.cs
│ ├── Benchmarks.EntityFrameworkCore.cs
│ ├── Benchmarks.HandCoded.cs
│ ├── Benchmarks.Linq2DB.cs
│ ├── Benchmarks.Linq2Sql.cs
│ ├── Benchmarks.Massive.cs
│ ├── Benchmarks.Mighty.cs
│ ├── Benchmarks.NHibernate.cs
│ ├── Benchmarks.Norm.cs
│ ├── Benchmarks.PetaPoco.cs
│ ├── Benchmarks.RepoDB.cs
│ ├── Benchmarks.ServiceStack.cs
│ ├── Benchmarks.SqlMarshal.cs
│ ├── Benchmarks.Susanoo.cs
│ ├── Benchmarks.XPO.cs
│ ├── Benchmarks.cs
│ ├── Config.cs
│ ├── Dapper.Tests.Performance.csproj
│ ├── DapperCacheImpact.cs
│ ├── Dashing
│ │ ├── DashingConfiguration.cs
│ │ └── Post.cs
│ ├── EntityFramework
│ │ └── EFContext.cs
│ ├── EntityFrameworkCore
│ │ └── EFCoreContext.cs
│ ├── Helpers
│ │ ├── ORMColum.cs
│ │ └── ReturnColum.cs
│ ├── LegacyTests.cs
│ ├── Linq2DB
│ │ ├── ConnectionStringSettings.cs
│ │ ├── Linq2DBContext.cs
│ │ └── Linq2DbSettings.cs
│ ├── Linq2Sql
│ │ ├── DataClasses.dbml
│ │ ├── DataClasses.dbml.layout
│ │ └── DataClasses.designer.cs
│ ├── Massive
│ │ └── Massive.cs
│ ├── NHibernate
│ │ ├── NHibernateHelper.cs
│ │ ├── Post.hbm.xml
│ │ └── hibernate.cfg.xml
│ ├── PetaPoco
│ │ └── PetaPoco.cs
│ ├── Post.cs
│ ├── Program.cs
│ ├── SqlDataReaderHelper.cs
│ ├── XPO
│ │ └── Post.cs
│ └── app.config
└── Directory.Build.props
├── build.cmd
├── build.ps1
├── docs
├── _config.yml
├── dapper-sponsor.png
├── dapperplus.md
├── dapperplus.png
├── docs.csproj
├── index.md
└── readme.md
├── global.json
├── nuget.config
├── signatures
└── version1
│ └── cla.json
├── tests
├── Dapper.Tests
│ ├── App.config
│ ├── AsyncTests.cs
│ ├── ConstructorTests.cs
│ ├── Dapper.Tests.csproj
│ ├── DataReaderTests.cs
│ ├── DateTimeOnlyTests.cs
│ ├── DecimalTests.cs
│ ├── EnumTests.cs
│ ├── Helpers
│ │ ├── Attributes.cs
│ │ ├── Common.cs
│ │ ├── IsExternalInit.cs
│ │ ├── SqlServerTypesLoader.cs
│ │ ├── TransactedConnection.cs
│ │ └── XunitSkippable.cs
│ ├── LiteralTests.cs
│ ├── MiscTests.cs
│ ├── MultiMapTests.cs
│ ├── NullTests.cs
│ ├── ParameterTests.cs
│ ├── ProcedureTests.cs
│ ├── ProviderTests.cs
│ ├── Providers
│ │ ├── DuckDBTests.cs
│ │ ├── EntityFrameworkTests.cs
│ │ ├── FirebirdTests.cs
│ │ ├── Linq2SqlTests.cs
│ │ ├── MySQLTests.cs
│ │ ├── OLDEBTests.cs
│ │ ├── PostgresqlTests.cs
│ │ ├── SnowflakeTests.cs
│ │ └── SqliteTests.cs
│ ├── QueryMultipleTests.cs
│ ├── SharedTypes
│ │ ├── Address.cs
│ │ ├── Bar1.cs
│ │ ├── Category.cs
│ │ ├── Comment.cs
│ │ ├── Dog.cs
│ │ ├── Enums.cs
│ │ ├── Foo1.cs
│ │ ├── HazNameId.cs
│ │ ├── Index.cs
│ │ ├── Person.cs
│ │ ├── Post.cs
│ │ ├── Product.cs
│ │ ├── ReviewBoard.cs
│ │ ├── ShortEnum.cs
│ │ ├── SomeType.cs
│ │ └── User.cs
│ ├── SingleRowTests.cs
│ ├── SqlBuilderTests.cs
│ ├── TestBase.cs
│ ├── TransactionTests.cs
│ ├── TupleTests.cs
│ ├── TypeHandlerTests.cs
│ ├── WrappedReaderTests.cs
│ ├── XmlTests.cs
│ └── xunit.runner.json
├── Directory.Build.props
├── Directory.Build.targets
└── docker-compose.yml
└── version.json
/.editorconfig:
--------------------------------------------------------------------------------
1 | # EditorConfig is awesome:http://EditorConfig.org
2 |
3 | # top-most EditorConfig file
4 | root = true
5 |
6 | # Don't use tabs for indentation.
7 | [*]
8 | indent_style = space
9 | # (Please don't specify an indent_size here; that has too many unintended consequences.)
10 |
11 | # Code files
12 | [*.{cs,csx,vb,vbx}]
13 | indent_size = 4
14 | insert_final_newline = true
15 | charset = utf-8-bom
16 |
17 | # Xml project files
18 | [*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}]
19 | indent_size = 2
20 |
21 | # Xml config files
22 | [*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}]
23 | indent_size = 2
24 |
25 | # JSON files
26 | [*.json]
27 | indent_size = 2
28 |
29 | # Dotnet code style settings:
30 | [*.{cs,vb}]
31 | # Sort using and Import directives with System.* appearing first
32 | dotnet_sort_system_directives_first = true
33 | # Avoid "this." and "Me." if not necessary
34 | dotnet_style_qualification_for_field = false:suggestion
35 | dotnet_style_qualification_for_property = false:suggestion
36 | dotnet_style_qualification_for_method = false:suggestion
37 | dotnet_style_qualification_for_event = false:suggestion
38 |
39 | # Use language keywords instead of framework type names for type references
40 | dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
41 | dotnet_style_predefined_type_for_member_access = true:suggestion
42 |
43 | # Suggest more modern language features when available
44 | dotnet_style_object_initializer = true:suggestion
45 | dotnet_style_collection_initializer = true:suggestion
46 | dotnet_style_coalesce_expression = true:suggestion
47 | dotnet_style_null_propagation = true:suggestion
48 | dotnet_style_explicit_tuple_names = true:suggestion
49 |
50 | # CSharp code style settings:
51 | [*.cs]
52 | # Prefer "var" everywhere
53 | #csharp_style_var_for_built_in_types = true:suggestion
54 | #csharp_style_var_when_type_is_apparent = false:suggestion
55 | #csharp_style_var_elsewhere = true:suggestion
56 |
57 | # Prefer method-like constructs to have a expression-body
58 | csharp_style_expression_bodied_methods = true:none
59 | csharp_style_expression_bodied_constructors = true:none
60 | csharp_style_expression_bodied_operators = true:none
61 |
62 | # Prefer property-like constructs to have an expression-body
63 | csharp_style_expression_bodied_properties = true:none
64 | csharp_style_expression_bodied_indexers = true:none
65 | csharp_style_expression_bodied_accessors = true:none
66 |
67 | # Suggest more modern language features when available
68 | csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
69 | csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
70 | csharp_style_inlined_variable_declaration = true:suggestion
71 | csharp_style_throw_expression = true:suggestion
72 | csharp_style_conditional_delegate_call = true:suggestion
73 |
74 | # Newline settings
75 | csharp_new_line_before_open_brace = all
76 | csharp_new_line_before_else = true
77 | csharp_new_line_before_catch = true
78 | csharp_new_line_before_finally = true
79 | csharp_new_line_before_members_in_object_initializers = true
80 | csharp_new_line_before_members_in_anonymous_types = true
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | * text=auto
2 |
3 | *.doc diff=astextplain
4 | *.DOC diff=astextplain
5 | *.docx diff=astextplain
6 | *.DOCX diff=astextplain
7 | *.dot diff=astextplain
8 | *.DOT diff=astextplain
9 | *.pdf diff=astextplain
10 | *.PDF diff=astextplain
11 | *.rtf diff=astextplain
12 | *.RTF diff=astextplain
13 |
14 | *.jpg binary
15 | *.png binary
16 | *.gif binary
17 |
18 | *.cs -text diff=csharp
19 | *.vb -text
20 | *.c -text
21 | *.cpp -text
22 | *.cxx -text
23 | *.h -text
24 | *.hxx -text
25 | *.py -text
26 | *.rb -text
27 | *.java -text
28 | *.html -text
29 | *.htm -text
30 | *.css -text
31 | *.scss -text
32 | *.sass -text
33 | *.less -text
34 | *.js -text
35 | *.lisp -text
36 | *.clj -text
37 | *.sql -text
38 | *.php -text
39 | *.lua -text
40 | *.m -text
41 | *.asm -text
42 | *.erl -text
43 | *.fs -text
44 | *.fsx -text
45 | *.hs -text
46 |
47 | *.csproj -text merge=union
48 | *.vbproj -text merge=union
49 | *.fsproj -text merge=union
50 | *.dbproj -text merge=union
51 | *.sln -text merge=union
52 |
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | github: [mgravell, dapperlib]
4 | custom: ["https://www.buymeacoffee.com/marcgravell"]
5 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: ''
5 | labels: bug, needs-triage
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Check your library version, and try updating**
11 | To help, we're going to need to know your library version. If it isn't the latest: *go do that* - it might
12 | fix the problem, and even if it doesn't: you're going to need to update if we find a problem and fix it,
13 | so you might as well get ready for that now.
14 |
15 | **Describe the bug**
16 | A clear and concise description of what the bug is.
17 |
18 | **To Reproduce**
19 | Steps to reproduce the behavior:
20 | 1. Go to '...'
21 | 2. Click on '....'
22 | 3. Scroll down to '....'
23 | 4. See error
24 |
25 | **Expected and actual behavior**
26 | A clear and concise description of what you expected to happen, and what actually happens.
27 |
28 | **Additional context**
29 | Add any other context about the problem here:
30 | - what DB backend (and version) are you using, if relevant?
31 | - what ADO.NET provider (and version) are you using, if relevant?
32 | - what OS and .NET runtime (and version) are you using, if relevant?
33 |
--------------------------------------------------------------------------------
/.github/workflows/cla.yml:
--------------------------------------------------------------------------------
1 | name: "CLA Assistant"
2 | on:
3 | issue_comment:
4 | types: [created]
5 | pull_request_target:
6 | types: [opened,closed,synchronize]
7 |
8 | # explicitly configure permissions, in case your GITHUB_TOKEN workflow permissions are set to read-only in repository settings
9 | permissions:
10 | actions: write
11 | contents: write
12 | pull-requests: write
13 | statuses: write
14 |
15 | jobs:
16 | CLAAssistant:
17 | runs-on: ubuntu-latest
18 | steps:
19 | - name: "CLA Assistant"
20 | if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target'
21 | uses: contributor-assistant/github-action@v2.3.0
22 | env:
23 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24 | # the below token should have repo scope and must be manually added by you in the repository's secret
25 | # This token is required only if you have configured to store the signatures in a remote repository/organization
26 | PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
27 | with:
28 | path-to-signatures: 'signatures/version1/cla.json'
29 | path-to-document: 'https://raw.githubusercontent.com/DapperLib/Dapper/main/NonCLA.md' # e.g. a CLA or a DCO document
30 | # branch should not be protected
31 | branch: 'main'
32 | # allowlist: user1,bot*
33 |
34 | # the followings are the optional inputs - If the optional inputs are not given, then default values will be taken
35 | #remote-organization-name: enter the remote organization name where the signatures should be stored (Default is storing the signatures in the same repository)
36 | #remote-repository-name: enter the remote repository name where the signatures should be stored (Default is storing the signatures in the same repository)
37 | #create-file-commit-message: 'For example: Creating file for storing CLA Signatures'
38 | #signed-commit-message: 'For example: $contributorName has signed the CLA in $owner/$repo#$pullRequestNo'
39 | #custom-notsigned-prcomment: 'pull request comment with Introductory message to ask new contributors to sign'
40 | #custom-pr-sign-comment: 'The signature to be committed in order to sign the CLA'
41 | #custom-allsigned-prcomment: 'pull request comment when all contributors has signed, defaults to **CLA Assistant Lite bot** All Contributors have signed the CLA.'
42 | #lock-pullrequest-aftermerge: false - if you don't want this bot to automatically lock the pull request after merging (default - true)
43 | #use-dco-flag: true - If you are using DCO instead of CLA
44 |
--------------------------------------------------------------------------------
/.github/workflows/main.yml:
--------------------------------------------------------------------------------
1 | name: Main Build
2 |
3 | on:
4 | pull_request:
5 | push:
6 | branches:
7 | - main
8 | paths:
9 | - '*'
10 | - '!/docs/*' # Don't run workflow when files are only in the /docs directory
11 |
12 | jobs:
13 | vm-job:
14 | name: Ubuntu
15 | runs-on: ubuntu-latest
16 | services:
17 | postgres:
18 | image: postgres
19 | ports:
20 | - 5432/tcp
21 | env:
22 | POSTGRES_USER: postgres
23 | POSTGRES_PASSWORD: postgres
24 | POSTGRES_DB: test
25 | options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
26 | sqlserver:
27 | image: mcr.microsoft.com/mssql/server:2019-latest
28 | ports:
29 | - 1433/tcp
30 | env:
31 | ACCEPT_EULA: Y
32 | SA_PASSWORD: "Password."
33 | mysql:
34 | image: mysql
35 | ports:
36 | - 3306/tcp
37 | env:
38 | MYSQL_ROOT_PASSWORD: root
39 | MYSQL_DATABASE: test
40 | steps:
41 | - name: Checkout code
42 | uses: actions/checkout@v1
43 | - name: Setup dotnet
44 | uses: actions/setup-dotnet@v4
45 | with:
46 | dotnet-version: '9.0.x'
47 | - name: .NET Build
48 | run: dotnet build Build.csproj -c Release /p:CI=true
49 | - name: Dapper Tests
50 | run: dotnet test tests/Dapper.Tests/Dapper.Tests.csproj -c Release --logger GitHubActions -p:CI=true -p:TestTfmsInParallel=false
51 | env:
52 | MySqlConnectionString: Server=localhost;Port=${{ job.services.mysql.ports[3306] }};Uid=root;Pwd=root;Database=test;Allow User Variables=true
53 | OLEDBConnectionString: Provider=SQLOLEDB;Server=tcp:localhost,${{ job.services.sqlserver.ports[1433] }};Database=tempdb;User Id=sa;Password=Password.;
54 | PostgesConnectionString: Server=localhost;Port=${{ job.services.postgres.ports[5432] }};Database=test;User Id=postgres;Password=postgres;
55 | SqlServerConnectionString: Server=tcp:localhost,${{ job.services.sqlserver.ports[1433] }};Database=tempdb;User Id=sa;Password=Password.;
56 | - name: .NET Lib Pack
57 | run: dotnet pack Build.csproj --no-build -c Release /p:PackageOutputPath=%CD%\.nupkgs /p:CI=true
58 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /*.suo
2 | .vs/
3 | .vscode/
4 | bin/
5 | obj/
6 | /*.user
7 | _Resharper*
8 | .hgtags
9 | NuGet.exe
10 | *.user
11 | *.nupkg
12 | .nupkgs/
13 | .docstats
14 | *.ide/
15 | *.lock.json
16 | *.coverage
17 | Test.DB.*
18 | TestResults/
19 | Dapper.Tests/*.sdf
20 | Dapper.Tests/SqlServerTypes/
21 | .dotnet/*
22 | BenchmarkDotNet.Artifacts/
23 | .idea/
24 | .DS_Store
--------------------------------------------------------------------------------
/Build.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/Dapper.EntityFramework.StrongName/Dapper.EntityFramework.StrongName.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | Dapper.EntityFramework.StrongName
4 | Dapper: Entity Framework type handlers (with a strong name)
5 | Extension handlers for entity framework
6 | Marc Gravell;Nick Craver
7 | net461
8 | ../Dapper.snk
9 | true
10 | true
11 | Dapper.EntityFramework.StrongName
12 | orm;sql;micro-orm
13 | enable
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/Dapper.EntityFramework/Dapper.EntityFramework.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | Dapper.EntityFramework
4 | Extension handlers for entity framework
5 | Dapper entity framework type handlers
6 | 1.50.2
7 | Marc Gravell;Nick Craver
8 | net461
9 | orm;sql;micro-orm
10 | enable
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | all
19 | runtime; build; native; contentfiles; analyzers
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Dapper.EntityFramework/DbGeographyHandler.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.SqlServer.Types;
2 | using System;
3 | using System.Data;
4 | using System.Data.Entity.Spatial;
5 | using System.Data.SqlClient;
6 | using System.Data.SqlTypes;
7 |
8 | namespace Dapper.EntityFramework
9 | {
10 | ///
11 | /// Type-handler for the DbGeography spatial type.
12 | ///
13 | public class DbGeographyHandler : SqlMapper.TypeHandler
14 | {
15 | ///
16 | /// Create a new handler instance.
17 | ///
18 | protected DbGeographyHandler() { /* create new */ }
19 |
20 | ///
21 | /// Default handler instance
22 | ///
23 | public static readonly DbGeographyHandler Default = new DbGeographyHandler();
24 |
25 | ///
26 | /// Assign the value of a parameter before a command executes.
27 | ///
28 | /// The parameter to configure.
29 | /// Parameter value.
30 | public override void SetValue(IDbDataParameter parameter, DbGeography? value)
31 | {
32 | object? parsed = null;
33 | if (value is not null)
34 | {
35 | parsed = SqlGeography.STGeomFromWKB(new SqlBytes(value.AsBinary()), value.CoordinateSystemId);
36 | }
37 | parameter.Value = parsed ?? DBNull.Value;
38 | if (parameter is SqlParameter sqlParameter)
39 | {
40 | sqlParameter.UdtTypeName = "geography";
41 | }
42 | }
43 |
44 | ///
45 | /// Parse a database value back to a typed value.
46 | ///
47 | /// The value from the database.
48 | /// The typed value.
49 | public override DbGeography? Parse(object? value)
50 | {
51 | if (value is null || value is DBNull) return null;
52 | if (value is SqlGeography geo)
53 | {
54 | return DbGeography.FromBinary(geo.STAsBinary().Value, geo.STSrid.Value);
55 | }
56 | return DbGeography.FromText(value.ToString());
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/Dapper.EntityFramework/DbGeometryHandler.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.SqlServer.Types;
2 | using System;
3 | using System.Data;
4 | using System.Data.Entity.Spatial;
5 | using System.Data.SqlClient;
6 | using System.Data.SqlTypes;
7 |
8 | namespace Dapper.EntityFramework
9 | {
10 | ///
11 | /// Type-handler for the DbGeometry spatial type.
12 | ///
13 | public class DbGeometryHandler : SqlMapper.TypeHandler
14 | {
15 | ///
16 | /// Create a new handler instance.
17 | ///
18 | protected DbGeometryHandler() { /* create new */ }
19 |
20 | ///
21 | /// Default handler instance.
22 | ///
23 | public static readonly DbGeometryHandler Default = new DbGeometryHandler();
24 |
25 | ///
26 | /// Assign the value of a parameter before a command executes.
27 | ///
28 | /// The parameter to configure.
29 | /// Parameter value.
30 | public override void SetValue(IDbDataParameter parameter, DbGeometry? value)
31 | {
32 | object? parsed = null;
33 | if (value is not null)
34 | {
35 | parsed = SqlGeometry.STGeomFromWKB(new SqlBytes(value.AsBinary()), value.CoordinateSystemId);
36 | }
37 | parameter.Value = parsed ?? DBNull.Value;
38 | if (parameter is SqlParameter sqlP)
39 | {
40 | sqlP.UdtTypeName = "geometry";
41 | }
42 | }
43 |
44 | ///
45 | /// Parse a database value back to a typed value.
46 | ///
47 | /// The value from the database.
48 | /// The typed value.
49 | public override DbGeometry? Parse(object? value)
50 | {
51 | if (value is null || value is DBNull) return null;
52 | if (value is SqlGeometry geo)
53 | {
54 | return DbGeometry.FromBinary(geo.STAsBinary().Value, geo.STSrid.Value);
55 | }
56 | return DbGeometry.FromText(value.ToString());
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/Dapper.EntityFramework/Handlers.cs:
--------------------------------------------------------------------------------
1 | namespace Dapper.EntityFramework
2 | {
3 | ///
4 | /// Acts on behalf of all type-handlers in this package
5 | ///
6 | public static class Handlers
7 | {
8 | ///
9 | /// Register all type-handlers in this package
10 | ///
11 | public static void Register()
12 | {
13 | SqlMapper.AddTypeHandler(DbGeographyHandler.Default);
14 | SqlMapper.AddTypeHandler(DbGeometryHandler.Default);
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Dapper.EntityFramework/PublicAPI.Shipped.txt:
--------------------------------------------------------------------------------
1 | #nullable enable
2 | Dapper.EntityFramework.DbGeographyHandler
3 | Dapper.EntityFramework.DbGeographyHandler.DbGeographyHandler() -> void
4 | Dapper.EntityFramework.DbGeometryHandler
5 | Dapper.EntityFramework.DbGeometryHandler.DbGeometryHandler() -> void
6 | Dapper.EntityFramework.Handlers
7 | override Dapper.EntityFramework.DbGeographyHandler.Parse(object? value) -> System.Data.Entity.Spatial.DbGeography?
8 | override Dapper.EntityFramework.DbGeographyHandler.SetValue(System.Data.IDbDataParameter! parameter, System.Data.Entity.Spatial.DbGeography? value) -> void
9 | override Dapper.EntityFramework.DbGeometryHandler.Parse(object? value) -> System.Data.Entity.Spatial.DbGeometry?
10 | override Dapper.EntityFramework.DbGeometryHandler.SetValue(System.Data.IDbDataParameter! parameter, System.Data.Entity.Spatial.DbGeometry? value) -> void
11 | static Dapper.EntityFramework.Handlers.Register() -> void
12 | static readonly Dapper.EntityFramework.DbGeographyHandler.Default -> Dapper.EntityFramework.DbGeographyHandler!
13 | static readonly Dapper.EntityFramework.DbGeometryHandler.Default -> Dapper.EntityFramework.DbGeometryHandler!
--------------------------------------------------------------------------------
/Dapper.EntityFramework/PublicAPI.Unshipped.txt:
--------------------------------------------------------------------------------
1 | #nullable enable
--------------------------------------------------------------------------------
/Dapper.ProviderTools/Dapper.ProviderTools.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | Dapper.ProviderTools
4 | orm;sql;micro-orm
5 | Dapper Provider Tools
6 | Provider-agnostic ADO.NET helper utilities
7 | Marc Gravell
8 | net461;netstandard2.0;net8.0
9 | true
10 | enable
11 |
12 |
13 |
14 | all
15 | runtime; build; native; contentfiles; analyzers
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/Dapper.ProviderTools/DbExceptionExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Concurrent;
3 | using System.Data.Common;
4 | using System.Linq.Expressions;
5 | using System.Reflection;
6 |
7 | namespace Dapper.ProviderTools
8 | {
9 | ///
10 | /// Helper utilities for working with database exceptions
11 | ///
12 | public static class DbExceptionExtensions
13 | {
14 | ///
15 | /// Indicates whether the provided exception has an integer Number property with the supplied value
16 | ///
17 | public static bool IsNumber(this DbException exception, int number)
18 | => exception is not null && ByTypeHelpers.Get(exception.GetType()).IsNumber(exception, number);
19 |
20 |
21 | private sealed class ByTypeHelpers
22 | {
23 | private static readonly ConcurrentDictionary s_byType
24 | = new ConcurrentDictionary();
25 | private readonly Func? _getNumber;
26 |
27 | public bool IsNumber(DbException exception, int number)
28 | => _getNumber is not null && _getNumber(exception) == number;
29 |
30 | public static ByTypeHelpers Get(Type type)
31 | {
32 | if (!s_byType.TryGetValue(type, out var value))
33 | {
34 | s_byType[type] = value = new ByTypeHelpers(type);
35 | }
36 | return value;
37 | }
38 |
39 | private ByTypeHelpers(Type type)
40 | {
41 | _getNumber = TryGetInstanceProperty("Number", type);
42 | }
43 |
44 | private static Func? TryGetInstanceProperty(string name, Type type)
45 | {
46 | try
47 | {
48 | var prop = type.GetProperty(name, BindingFlags.Public | BindingFlags.Instance);
49 | if (prop is null || !prop.CanRead) return null;
50 | if (prop.PropertyType != typeof(T)) return null;
51 |
52 | var p = Expression.Parameter(typeof(DbException), "exception");
53 | var body = Expression.Property(Expression.Convert(p, type), prop);
54 | var lambda = Expression.Lambda>(body, p);
55 | return lambda.Compile();
56 | }
57 | catch
58 | {
59 | return null;
60 | }
61 | }
62 | }
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/Dapper.ProviderTools/Internal/DynamicBulkCopy.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Data;
3 | using System.Data.Common;
4 | using System.Threading;
5 | using System.Threading.Tasks;
6 | #nullable enable
7 | namespace Dapper.ProviderTools.Internal
8 | {
9 | internal sealed class DynamicBulkCopy : BulkCopy
10 | {
11 | internal static BulkCopy? Create(object? wrapped)
12 | => wrapped is null ? null : new DynamicBulkCopy(wrapped);
13 |
14 | private DynamicBulkCopy(object wrapped)
15 | => _wrapped = wrapped;
16 |
17 | private readonly dynamic _wrapped;
18 |
19 | public override string DestinationTableName
20 | {
21 | get => _wrapped.DestinationTableName;
22 | set => _wrapped.DestinationTableName = value;
23 | }
24 |
25 | public override object Wrapped => _wrapped;
26 |
27 | public override void AddColumnMapping(string sourceColumn, string destinationColumn)
28 | => _wrapped.ColumnMappings.Add(sourceColumn, destinationColumn);
29 |
30 | public override void AddColumnMapping(int sourceColumn, int destinationColumn)
31 | => _wrapped.ColumnMappings.Add(sourceColumn, destinationColumn);
32 |
33 | public override void WriteToServer(DataTable source)
34 | => _wrapped.WriteToServer(source);
35 | public override void WriteToServer(DataRow[] source)
36 | => _wrapped.WriteToServer(source);
37 |
38 | public override void WriteToServer(IDataReader source)
39 | => _wrapped.WriteToServer(source);
40 |
41 | public override Task WriteToServerAsync(DbDataReader source, CancellationToken cancellationToken)
42 | => _wrapped.WriteToServer(source, cancellationToken);
43 |
44 | public override Task WriteToServerAsync(DataTable source, CancellationToken cancellationToken)
45 | => _wrapped.WriteToServer(source, cancellationToken);
46 | public override Task WriteToServerAsync(DataRow[] source, CancellationToken cancellationToken)
47 | => _wrapped.WriteToServer(source, cancellationToken);
48 |
49 | protected override void Dispose(bool disposing)
50 | {
51 | if (disposing)
52 | {
53 | if (_wrapped is IDisposable d)
54 | {
55 | try { d.Dispose(); } catch { }
56 | }
57 | }
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/Dapper.ProviderTools/PublicAPI.Shipped.txt:
--------------------------------------------------------------------------------
1 | #nullable enable
2 | abstract Dapper.ProviderTools.BulkCopy.AddColumnMapping(int sourceColumn, int destinationColumn) -> void
3 | abstract Dapper.ProviderTools.BulkCopy.AddColumnMapping(string! sourceColumn, string! destinationColumn) -> void
4 | abstract Dapper.ProviderTools.BulkCopy.DestinationTableName.get -> string!
5 | abstract Dapper.ProviderTools.BulkCopy.DestinationTableName.set -> void
6 | abstract Dapper.ProviderTools.BulkCopy.Dispose(bool disposing) -> void
7 | abstract Dapper.ProviderTools.BulkCopy.Wrapped.get -> object!
8 | abstract Dapper.ProviderTools.BulkCopy.WriteToServer(System.Data.DataRow![]! source) -> void
9 | abstract Dapper.ProviderTools.BulkCopy.WriteToServer(System.Data.DataTable! source) -> void
10 | abstract Dapper.ProviderTools.BulkCopy.WriteToServer(System.Data.IDataReader! source) -> void
11 | abstract Dapper.ProviderTools.BulkCopy.WriteToServerAsync(System.Data.Common.DbDataReader! source, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task!
12 | abstract Dapper.ProviderTools.BulkCopy.WriteToServerAsync(System.Data.DataRow![]! source, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task!
13 | abstract Dapper.ProviderTools.BulkCopy.WriteToServerAsync(System.Data.DataTable! source, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task!
14 | Dapper.ProviderTools.BulkCopy
15 | Dapper.ProviderTools.BulkCopy.BatchSize.get -> int
16 | Dapper.ProviderTools.BulkCopy.BatchSize.set -> void
17 | Dapper.ProviderTools.BulkCopy.BulkCopy() -> void
18 | Dapper.ProviderTools.BulkCopy.BulkCopyTimeout.get -> int
19 | Dapper.ProviderTools.BulkCopy.BulkCopyTimeout.set -> void
20 | Dapper.ProviderTools.BulkCopy.Dispose() -> void
21 | Dapper.ProviderTools.BulkCopy.EnableStreaming.get -> bool
22 | Dapper.ProviderTools.BulkCopy.EnableStreaming.set -> void
23 | Dapper.ProviderTools.DbConnectionExtensions
24 | Dapper.ProviderTools.DbExceptionExtensions
25 | static Dapper.ProviderTools.BulkCopy.Create(System.Data.Common.DbConnection! connection) -> Dapper.ProviderTools.BulkCopy!
26 | static Dapper.ProviderTools.BulkCopy.TryCreate(System.Data.Common.DbConnection! connection) -> Dapper.ProviderTools.BulkCopy?
27 | static Dapper.ProviderTools.DbConnectionExtensions.TryClearAllPools(this System.Data.Common.DbConnection! connection) -> bool
28 | static Dapper.ProviderTools.DbConnectionExtensions.TryClearPool(this System.Data.Common.DbConnection! connection) -> bool
29 | static Dapper.ProviderTools.DbConnectionExtensions.TryGetClientConnectionId(this System.Data.Common.DbConnection! connection, out System.Guid clientConnectionId) -> bool
30 | static Dapper.ProviderTools.DbExceptionExtensions.IsNumber(this System.Data.Common.DbException! exception, int number) -> bool
--------------------------------------------------------------------------------
/Dapper.ProviderTools/PublicAPI.Unshipped.txt:
--------------------------------------------------------------------------------
1 | #nullable enable
--------------------------------------------------------------------------------
/Dapper.Rainbow/Dapper.Rainbow.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | Dapper.Rainbow
4 | orm;sql;micro-orm
5 | Dapper.Rainbow
6 | Trivial micro-orm implemented on Dapper, provides with CRUD helpers.
7 | Sam Saffron
8 | 2017 Sam Saffron
9 | net461;netstandard2.0;net5.0
10 |
11 | false
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Dapper.Rainbow/IgnorePropertyAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Dapper
4 | {
5 | ///
6 | /// Specifies whether a property should be ignored for database operations.
7 | ///
8 | [AttributeUsage(AttributeTargets.Property, AllowMultiple = true)]
9 | public class IgnorePropertyAttribute : Attribute
10 | {
11 | ///
12 | /// Specifies whether a property should be ignored for database operations.
13 | ///
14 | /// Whether to ignore this property.
15 | public IgnorePropertyAttribute(bool ignore)
16 | {
17 | Value = ignore;
18 | }
19 |
20 | ///
21 | /// Whether to ignore this property.
22 | ///
23 | public bool Value { get; set; }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/Dapper.Rainbow/SqlCompactDatabase.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Data.Common;
4 | using System.Linq;
5 |
6 | namespace Dapper
7 | {
8 | ///
9 | /// A SQL Compact specific implementation.
10 | ///
11 | /// The type of database.
12 | public abstract class SqlCompactDatabase : Database where TDatabase : Database, new()
13 | {
14 | ///
15 | /// A SQL Compact specific table, which handles the syntax correctly across operations.
16 | ///
17 | /// The type in the table.
18 | public class SqlCompactTable : Table
19 | {
20 | ///
21 | /// Creates a table for a SQL Compact database.
22 | ///
23 | ///
24 | ///
25 | public SqlCompactTable(Database database, string likelyTableName)
26 | : base(database, likelyTableName)
27 | {
28 | }
29 |
30 | ///
31 | /// Insert a row into the db
32 | ///
33 | /// Either DynamicParameters or an anonymous type or concrete type
34 | ///
35 | public override int? Insert(dynamic data)
36 | {
37 | var o = (object)data;
38 | List paramNames = GetParamNames(o);
39 | paramNames.Remove("Id");
40 |
41 | string cols = string.Join(",", paramNames);
42 | string colsParams = string.Join(",", paramNames.Select(p => "@" + p));
43 |
44 | var sql = "insert " + TableName + " (" + cols + ") values (" + colsParams + ")";
45 | if (database.Execute(sql, o) != 1)
46 | {
47 | return null;
48 | }
49 |
50 | return (int)database.Query("SELECT @@IDENTITY AS LastInsertedId").Single();
51 | }
52 | }
53 |
54 | ///
55 | /// Initializes the databases.
56 | ///
57 | /// The connection to use.
58 | /// The newly created database.
59 | public static TDatabase Init(DbConnection connection)
60 | {
61 | var db = new TDatabase();
62 | db.InitDatabase(connection, 0);
63 | return db;
64 | }
65 |
66 | internal override Action CreateTableConstructorForTable()
67 | {
68 | return CreateTableConstructor(typeof(SqlCompactTable<>));
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/Dapper.Rainbow/readme.md:
--------------------------------------------------------------------------------
1 | # Using Dapper.Rainbow in C# for CRUD Operations
2 |
3 | This guide outlines how to use `Dapper.Rainbow` in C# for CRUD operations.
4 |
5 | ## 1. Setting Up
6 |
7 | Add Dapper and Dapper.Rainbow to your project via NuGet:
8 |
9 | ```powershell
10 | Install-Package Dapper -Version x.x.x
11 | Install-Package Dapper.Rainbow -Version x.x.x
12 | ```
13 |
14 | *Replace `x.x.x` with the latest version numbers.*
15 |
16 | ## 2. Database Setup and Requirements
17 |
18 | For `Dapper.Rainbow` to function correctly, ensure each table has a primary key column named `Id`.
19 |
20 | Example `Users` table schema:
21 |
22 | ```sql
23 | CREATE TABLE Users (
24 | Id INT IDENTITY(1,1) PRIMARY KEY,
25 | Name VARCHAR(100),
26 | Email VARCHAR(100)
27 | );
28 | ```
29 |
30 | ## 3. Establishing Database Connection
31 |
32 | Open a connection to your database:
33 |
34 | ```csharp
35 | using System.Data.SqlClient;
36 |
37 | var connectionString = "your_connection_string_here";
38 | using var connection = new SqlConnection(connectionString);
39 | connection.Open(); // Open the connection
40 | ```
41 |
42 | ## 4. Defining Your Database Context
43 |
44 | Define a class for your database context:
45 |
46 | ```csharp
47 | using Dapper;
48 | using System.Data;
49 |
50 | public class MyDatabase : Database
51 | {
52 | public Table Users { get; set; }
53 | }
54 |
55 | public class User
56 | {
57 | public int Id { get; set; }
58 | public string Name { get; set; }
59 | public string Email { get; set; }
60 | }
61 | ```
62 |
63 | ## 5. Performing CRUD Operations
64 |
65 | ### Insert
66 |
67 | ```csharp
68 | var db = new MyDatabase { Connection = connection };
69 | var newUser = new User { Name = "John Doe", Email = "john.doe@example.com" };
70 | var insertedUser = db.Users.Insert(newUser);
71 | ```
72 |
73 | ### Select
74 |
75 | Fetch users by ID or all users:
76 |
77 | ```csharp
78 | var user = db.Users.Get(id); // Single user by ID
79 | var users = connection.Query("SELECT * FROM Users"); // All users
80 | ```
81 |
82 | ### Update
83 |
84 | ```csharp
85 | var userToUpdate = db.Users.Get(id);
86 | userToUpdate.Email = "new.email@example.com";
87 | db.Users.Update(userToUpdate);
88 | ```
89 |
90 | ### Delete
91 |
92 | ```csharp
93 | db.Users.Delete(id);
94 | ```
95 |
96 | ## 6. Working with Foreign Keys
97 |
98 | Example schema for a `Posts` table with a foreign key to `Users`:
99 |
100 | ```sql
101 | CREATE TABLE Posts (
102 | Id INT IDENTITY(1,1) PRIMARY KEY,
103 | UserId INT,
104 | Content VARCHAR(255),
105 | FOREIGN KEY (UserId) REFERENCES Users(Id)
106 | );
107 | ```
108 |
109 | Inserting a parent (`User`) and a child (`Post`) row:
110 |
111 | ```csharp
112 | var newUser = new User { Name = "Jane Doe", Email = "jane.doe@example.com" };
113 | var userId = db.Users.Insert(newUser);
114 |
115 | var newPost = new Post { UserId = userId, Content = "Hello, World!" };
116 | db.Connection.Insert(newPost); // Using Dapper for the child table
117 | ```
118 |
119 |
--------------------------------------------------------------------------------
/Dapper.SqlBuilder/Dapper.SqlBuilder.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | Dapper.SqlBuilder
4 | orm;sql;micro-orm;query;sql-builder
5 | Dapper SqlBuilder component
6 | The Dapper SqlBuilder component, for building SQL queries dynamically.
7 | Sam Saffron, Johan Danforth
8 | net461;netstandard2.0;net8.0
9 | false
10 | false
11 | enable
12 |
13 |
14 |
15 |
16 |
17 | all
18 | runtime; build; native; contentfiles; analyzers
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/Dapper.SqlBuilder/PublicAPI.Shipped.txt:
--------------------------------------------------------------------------------
1 | #nullable enable
2 | Dapper.SqlBuilder
3 | Dapper.SqlBuilder.AddClause(string! name, string! sql, object? parameters, string! joiner, string! prefix = "", string! postfix = "", bool isInclusive = false) -> Dapper.SqlBuilder!
4 | Dapper.SqlBuilder.AddParameters(dynamic! parameters) -> Dapper.SqlBuilder!
5 | Dapper.SqlBuilder.AddTemplate(string! sql, dynamic? parameters = null) -> Dapper.SqlBuilder.Template!
6 | Dapper.SqlBuilder.GroupBy(string! sql, dynamic? parameters = null) -> Dapper.SqlBuilder!
7 | Dapper.SqlBuilder.Having(string! sql, dynamic? parameters = null) -> Dapper.SqlBuilder!
8 | Dapper.SqlBuilder.InnerJoin(string! sql, dynamic? parameters = null) -> Dapper.SqlBuilder!
9 | Dapper.SqlBuilder.Intersect(string! sql, dynamic? parameters = null) -> Dapper.SqlBuilder!
10 | Dapper.SqlBuilder.Join(string! sql, dynamic? parameters = null) -> Dapper.SqlBuilder!
11 | Dapper.SqlBuilder.LeftJoin(string! sql, dynamic? parameters = null) -> Dapper.SqlBuilder!
12 | Dapper.SqlBuilder.OrderBy(string! sql, dynamic? parameters = null) -> Dapper.SqlBuilder!
13 | Dapper.SqlBuilder.OrWhere(string! sql, dynamic? parameters = null) -> Dapper.SqlBuilder!
14 | Dapper.SqlBuilder.RightJoin(string! sql, dynamic? parameters = null) -> Dapper.SqlBuilder!
15 | Dapper.SqlBuilder.Select(string! sql, dynamic? parameters = null) -> Dapper.SqlBuilder!
16 | Dapper.SqlBuilder.Set(string! sql, dynamic? parameters = null) -> Dapper.SqlBuilder!
17 | Dapper.SqlBuilder.SqlBuilder() -> void
18 | Dapper.SqlBuilder.Template
19 | Dapper.SqlBuilder.Template.Parameters.get -> object?
20 | Dapper.SqlBuilder.Template.RawSql.get -> string!
21 | Dapper.SqlBuilder.Template.Template(Dapper.SqlBuilder! builder, string! sql, dynamic? parameters) -> void
22 | Dapper.SqlBuilder.Where(string! sql, dynamic? parameters = null) -> Dapper.SqlBuilder!
--------------------------------------------------------------------------------
/Dapper.SqlBuilder/PublicAPI.Unshipped.txt:
--------------------------------------------------------------------------------
1 | #nullable enable
--------------------------------------------------------------------------------
/Dapper.StrongName/Dapper.StrongName.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | Dapper.StrongName
4 | orm;sql;micro-orm
5 | Dapper (Strong Named)
6 | A high performance Micro-ORM supporting SQL Server, MySQL, Sqlite, SqlCE, Firebird etc. Major Sponsor: Dapper Plus from ZZZ Projects.
7 | Sam Saffron;Marc Gravell;Nick Craver
8 | net461;netstandard2.0;net8.0
9 | true
10 | true
11 | enable
12 | true
13 | $(DefineConstants);STRONG_NAME
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/Dapper.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DapperLib/Dapper/00b1023f292c436eb9830b3383fde68e177a13bf/Dapper.png
--------------------------------------------------------------------------------
/Dapper.sln.DotSettings:
--------------------------------------------------------------------------------
1 |
2 | CE
3 | SQ
4 | SQL
5 | TVP
--------------------------------------------------------------------------------
/Dapper.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DapperLib/Dapper/00b1023f292c436eb9830b3383fde68e177a13bf/Dapper.snk
--------------------------------------------------------------------------------
/Dapper/CommandFlags.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Dapper
4 | {
5 | ///
6 | /// Additional state flags that control command behaviour
7 | ///
8 | [Flags]
9 | public enum CommandFlags
10 | {
11 | ///
12 | /// No additional flags
13 | ///
14 | None = 0,
15 | ///
16 | /// Should data be buffered before returning?
17 | ///
18 | Buffered = 1,
19 | ///
20 | /// Can async queries be pipelined?
21 | ///
22 | Pipelined = 2,
23 | ///
24 | /// Should the plan cache be bypassed?
25 | ///
26 | NoCache = 4,
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/Dapper/CompiledRegex.cs:
--------------------------------------------------------------------------------
1 | using System.Diagnostics.CodeAnalysis;
2 | using System.Text.RegularExpressions;
3 |
4 | namespace Dapper;
5 |
6 | internal static partial class CompiledRegex
7 | {
8 | #if DEBUG && NET7_0_OR_GREATER // enables colorization in IDE
9 | [StringSyntax("Regex")]
10 | #endif
11 | private const string
12 | WhitespaceOrReservedPattern = @"[\s;/\-+*]|^vacuum$|^commit$|^rollback$|^revert$",
13 | LegacyParameterPattern = @"(? LegacyParameterGen();
32 | internal static Regex LiteralTokens => LiteralTokensGen();
33 | internal static Regex PseudoPositional => PseudoPositionalGen();
34 | internal static Regex WhitespaceOrReserved => WhitespaceOrReservedGen();
35 | #else
36 | internal static Regex LegacyParameter { get; }
37 | = new(LegacyParameterPattern, RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.CultureInvariant | RegexOptions.Compiled);
38 | internal static Regex LiteralTokens { get; }
39 | = new(LiteralTokensPattern, RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.CultureInvariant | RegexOptions.Compiled);
40 | internal static Regex PseudoPositional { get; }
41 | = new(PseudoPositionalPattern, RegexOptions.IgnoreCase | RegexOptions.CultureInvariant | RegexOptions.Compiled);
42 | internal static Regex WhitespaceOrReserved { get; }
43 | = new(WhitespaceOrReservedPattern, RegexOptions.Compiled | RegexOptions.IgnoreCase);
44 | #endif
45 | }
46 |
--------------------------------------------------------------------------------
/Dapper/CustomPropertyTypeMap.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection;
3 |
4 | namespace Dapper
5 | {
6 | ///
7 | /// Implements custom property mapping by user provided criteria (usually presence of some custom attribute with column to member mapping)
8 | ///
9 | public sealed class CustomPropertyTypeMap : SqlMapper.ITypeMap
10 | {
11 | private readonly Type _type;
12 | private readonly Func _propertySelector;
13 |
14 | ///
15 | /// Creates custom property mapping
16 | ///
17 | /// Target entity type
18 | /// Property selector based on target type and DataReader column name
19 | public CustomPropertyTypeMap(Type type, Func propertySelector)
20 | {
21 | _type = type ?? throw new ArgumentNullException(nameof(type));
22 | _propertySelector = propertySelector ?? throw new ArgumentNullException(nameof(propertySelector));
23 | }
24 |
25 | ///
26 | /// Always returns default constructor
27 | ///
28 | /// DataReader column names
29 | /// DataReader column types
30 | /// Default constructor
31 | public ConstructorInfo? FindConstructor(string[] names, Type[] types) =>
32 | _type.GetConstructor(Array.Empty())!;
33 |
34 | ///
35 | /// Always returns null
36 | ///
37 | ///
38 | public ConstructorInfo? FindExplicitConstructor() => null;
39 |
40 | ///
41 | /// Not implemented as far as default constructor used for all cases
42 | ///
43 | ///
44 | ///
45 | ///
46 | public SqlMapper.IMemberMap GetConstructorParameter(ConstructorInfo constructor, string columnName)
47 | {
48 | throw new NotSupportedException();
49 | }
50 |
51 | ///
52 | /// Returns property based on selector strategy
53 | ///
54 | /// DataReader column name
55 | /// Property member map
56 | public SqlMapper.IMemberMap? GetMember(string columnName)
57 | {
58 | var prop = _propertySelector(_type, columnName);
59 | return prop is not null ? new SimpleMemberMap(columnName, prop) : null;
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/Dapper/Dapper.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | Dapper
4 | Dapper
5 | orm;sql;micro-orm
6 | A high performance Micro-ORM supporting SQL Server, MySQL, Sqlite, SqlCE, Firebird etc. Major Sponsor: Dapper Plus from ZZZ Projects.
7 | Sam Saffron;Marc Gravell;Nick Craver
8 | net461;netstandard2.0;net8.0
9 | enable
10 | true
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 | all
23 | runtime; build; native; contentfiles; analyzers
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/Dapper/DataTableHandler.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Data;
3 | namespace Dapper
4 | {
5 | internal sealed class DataTableHandler : SqlMapper.ITypeHandler
6 | {
7 | public object Parse(Type destinationType, object value)
8 | {
9 | throw new NotImplementedException();
10 | }
11 |
12 | public void SetValue(IDbDataParameter parameter, object value)
13 | {
14 | TableValuedParameter.Set(parameter, value as DataTable, null);
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Dapper/DynamicParameters.CachedOutputSetters.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 |
3 | namespace Dapper
4 | {
5 | public partial class DynamicParameters
6 | {
7 | // The type here is used to differentiate the cache by type via generics
8 | // ReSharper disable once UnusedTypeParameter
9 | internal static class CachedOutputSetters
10 | {
11 | // Intentional, abusing generics to get our cache splits
12 | // ReSharper disable once StaticMemberInGenericType
13 | public static readonly Hashtable Cache = new Hashtable();
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/Dapper/DynamicParameters.ParamInfo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Data;
3 |
4 | namespace Dapper
5 | {
6 | public partial class DynamicParameters
7 | {
8 | private sealed class ParamInfo
9 | {
10 | public string Name { get; set; } = null!;
11 | public object? Value { get; set; }
12 | public ParameterDirection ParameterDirection { get; set; }
13 | public DbType? DbType { get; set; }
14 | public int? Size { get; set; }
15 | public IDbDataParameter AttachedParam { get; set; } = null!;
16 | internal Action