├── .gitattributes
├── .gitignore
├── .nuget
├── NuGet.Config
├── NuGet.exe
└── NuGet.targets
├── DapperRepository.Demo
├── App.config
├── DapperRepository.Demo.csproj
├── Program.cs
├── Properties
│ └── AssemblyInfo.cs
├── RepositoryConfig.xml
├── TempModel.cs
└── TempModelMapper.cs
├── DapperRepository.MSSQL
├── DapperRepository.MSSQL.csproj
├── Properties
│ └── AssemblyInfo.cs
├── SqlServerDialect.cs
├── SqlServerGenerator.cs
└── SqlServerManager.cs
├── DapperRepository.MySQL
├── DapperRepository.MySQL.csproj
├── MySqlDialect.cs
├── MySqlGenerator.cs
├── MySqlManager.cs
├── Properties
│ └── AssemblyInfo.cs
└── packages.config
├── DapperRepository.PostgreSQL
├── DapperRepository.PostgreSQL.csproj
├── PostgreSqlDialect.cs
├── PostgreSqlGenerator.cs
├── PostgreSqlManager.cs
├── Properties
│ └── AssemblyInfo.cs
└── packages.config
├── DapperRepository.SQLite
├── DapperRepository.SQLite.csproj
├── Properties
│ └── AssemblyInfo.cs
├── SqliteDialect.cs
├── SqliteGenerator.cs
├── SqliteManager.cs
├── packages.config
├── x64
│ └── SQLite.Interop.dll
└── x86
│ └── SQLite.Interop.dll
├── DapperRepository.sln
├── DapperRepository
├── Attributes
│ └── MigrationAttribute.cs
├── DapperRepository.csproj
├── Drapper
│ ├── DapperExtensions.cs
│ ├── DapperExtensionsConfiguration.cs
│ ├── DapperImplementor.cs
│ ├── Database.cs
│ ├── GetMultiplePredicate.cs
│ ├── GetMultipleResult.cs
│ ├── IDapperExtensionsConfiguration.cs
│ ├── IDapperImplementor.cs
│ ├── IDatabase.cs
│ ├── IMultipleResultReader.cs
│ ├── Mapper
│ │ ├── AutoClassMapper.cs
│ │ ├── ClassMapper.cs
│ │ ├── IClassMapper.cs
│ │ ├── IPropertyMap.cs
│ │ └── PropertyMap.cs
│ ├── Predicates.cs
│ ├── ReflectionHelper.cs
│ ├── Resources
│ │ └── Readme.txt
│ ├── Sql
│ │ ├── ISqlDialect.cs
│ │ ├── ISqlGenerator.cs
│ │ ├── SqlDialectBase.cs
│ │ └── SqlGenerator.cs
│ └── SqlMapper.cs
├── DrapperDbManager.cs
├── Enums
│ └── DriverType.cs
├── Extensions
│ ├── UtilExtension.cs
│ └── XMLExtension.cs
├── Helpers
│ ├── MigrationHelper.cs
│ └── XLinqHelper.cs
├── IDrapperManager.cs
├── Models
│ └── RepositoryModel.cs
├── Properties
│ └── AssemblyInfo.cs
├── RepositoryFactory.cs
├── RepositorySettings.cs
└── packages.config
├── HEAD
├── README.md
├── config
├── description
├── hooks
├── applypatch-msg.sample
├── commit-msg.sample
├── post-update.sample
├── pre-applypatch.sample
├── pre-commit.sample
├── pre-push.sample
├── pre-rebase.sample
├── prepare-commit-msg.sample
└── update.sample
├── info
└── exclude
└── packages
├── MySql.Data.6.8.3
├── MySql.Data.6.8.3.nupkg
└── lib
│ ├── net20-cf
│ └── MySql.Data.cf.dll
│ ├── net20
│ └── MySql.Data.dll
│ ├── net40
│ └── MySql.Data.dll
│ ├── net45
│ └── MySql.Data.dll
│ └── netcore45
│ └── MySql.Data.RT.dll
├── Npgsql.2.1.3
├── Npgsql.2.1.3.nupkg
└── lib
│ ├── net20
│ ├── Mono.Security.dll
│ ├── Npgsql.dll
│ ├── Npgsql.xml
│ ├── de
│ │ └── Npgsql.resources.dll
│ ├── es
│ │ └── Npgsql.resources.dll
│ ├── fi
│ │ └── Npgsql.resources.dll
│ ├── fr
│ │ └── Npgsql.resources.dll
│ ├── ja
│ │ └── Npgsql.resources.dll
│ └── zh-CN
│ │ └── Npgsql.resources.dll
│ ├── net35
│ ├── Mono.Security.dll
│ ├── Npgsql.dll
│ ├── Npgsql.xml
│ ├── de
│ │ └── Npgsql.resources.dll
│ ├── es
│ │ └── Npgsql.resources.dll
│ ├── fi
│ │ └── Npgsql.resources.dll
│ ├── fr
│ │ └── Npgsql.resources.dll
│ ├── ja
│ │ └── Npgsql.resources.dll
│ └── zh-CN
│ │ └── Npgsql.resources.dll
│ ├── net40
│ ├── Mono.Security.dll
│ ├── Npgsql.dll
│ ├── Npgsql.xml
│ ├── de
│ │ └── Npgsql.resources.dll
│ ├── es
│ │ └── Npgsql.resources.dll
│ ├── fi
│ │ └── Npgsql.resources.dll
│ ├── fr
│ │ └── Npgsql.resources.dll
│ ├── ja
│ │ └── Npgsql.resources.dll
│ └── zh-CN
│ │ └── Npgsql.resources.dll
│ └── net45
│ ├── Mono.Security.dll
│ ├── Npgsql.dll
│ ├── Npgsql.xml
│ ├── de
│ └── Npgsql.resources.dll
│ ├── es
│ └── Npgsql.resources.dll
│ ├── fi
│ └── Npgsql.resources.dll
│ ├── fr
│ └── Npgsql.resources.dll
│ ├── ja
│ └── Npgsql.resources.dll
│ └── zh-CN
│ └── Npgsql.resources.dll
├── System.Data.SQLite.Core.1.0.93.0
├── System.Data.SQLite.Core.1.0.93.0.nupkg
├── content
│ ├── net20
│ │ └── x86
│ │ │ └── SQLite.Interop.dll
│ ├── net40
│ │ └── x86
│ │ │ └── SQLite.Interop.dll
│ ├── net45
│ │ └── x86
│ │ │ └── SQLite.Interop.dll
│ └── net451
│ │ └── x86
│ │ └── SQLite.Interop.dll
├── lib
│ ├── net20
│ │ ├── System.Data.SQLite.dll
│ │ └── System.Data.SQLite.xml
│ ├── net40
│ │ ├── System.Data.SQLite.dll
│ │ └── System.Data.SQLite.xml
│ ├── net45
│ │ ├── System.Data.SQLite.dll
│ │ └── System.Data.SQLite.xml
│ └── net451
│ │ ├── System.Data.SQLite.dll
│ │ └── System.Data.SQLite.xml
└── tools
│ ├── net20
│ └── install.ps1
│ ├── net40
│ └── install.ps1
│ ├── net45
│ └── install.ps1
│ └── net451
│ └── install.ps1
└── repositories.config
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | #################
2 | ## Eclipse
3 | #################
4 |
5 | *.pydevproject
6 | .project
7 | .metadata
8 | bin/
9 | tmp/
10 | *.tmp
11 | *.bak
12 | *.swp
13 | *~.nib
14 | local.properties
15 | .classpath
16 | .settings/
17 | .loadpath
18 |
19 | # External tool builders
20 | .externalToolBuilders/
21 |
22 | # Locally stored "Eclipse launch configurations"
23 | *.launch
24 |
25 | # CDT-specific
26 | .cproject
27 |
28 | # PDT-specific
29 | .buildpath
30 |
31 |
32 | #################
33 | ## Visual Studio
34 | #################
35 |
36 | ## Ignore Visual Studio temporary files, build results, and
37 | ## files generated by popular Visual Studio add-ons.
38 |
39 | # User-specific files
40 | *.suo
41 | *.user
42 | *.sln.docstates
43 |
44 | # Build results
45 |
46 | [Dd]ebug/
47 | [Rr]elease/
48 | x64/
49 | build/
50 | [Bb]in/
51 | [Oo]bj/
52 |
53 | # MSTest test Results
54 | [Tt]est[Rr]esult*/
55 | [Bb]uild[Ll]og.*
56 |
57 | *_i.c
58 | *_p.c
59 | *.ilk
60 | *.meta
61 | *.obj
62 | *.pch
63 | *.pdb
64 | *.pgc
65 | *.pgd
66 | *.rsp
67 | *.sbr
68 | *.tlb
69 | *.tli
70 | *.tlh
71 | *.tmp
72 | *.tmp_proj
73 | *.log
74 | *.vspscc
75 | *.vssscc
76 | .builds
77 | *.pidb
78 | *.log
79 | *.scc
80 |
81 | # Visual C++ cache files
82 | ipch/
83 | *.aps
84 | *.ncb
85 | *.opensdf
86 | *.sdf
87 | *.cachefile
88 |
89 | # Visual Studio profiler
90 | *.psess
91 | *.vsp
92 | *.vspx
93 |
94 | # Guidance Automation Toolkit
95 | *.gpState
96 |
97 | # ReSharper is a .NET coding add-in
98 | _ReSharper*/
99 | *.[Rr]e[Ss]harper
100 |
101 | # TeamCity is a build add-in
102 | _TeamCity*
103 |
104 | # DotCover is a Code Coverage Tool
105 | *.dotCover
106 |
107 | # NCrunch
108 | *.ncrunch*
109 | .*crunch*.local.xml
110 |
111 | # Installshield output folder
112 | [Ee]xpress/
113 |
114 | # DocProject is a documentation generator add-in
115 | DocProject/buildhelp/
116 | DocProject/Help/*.HxT
117 | DocProject/Help/*.HxC
118 | DocProject/Help/*.hhc
119 | DocProject/Help/*.hhk
120 | DocProject/Help/*.hhp
121 | DocProject/Help/Html2
122 | DocProject/Help/html
123 |
124 | # Click-Once directory
125 | publish/
126 |
127 | # Publish Web Output
128 | *.Publish.xml
129 | *.pubxml
130 |
131 | # NuGet Packages Directory
132 | ## TODO: If you have NuGet Package Restore enabled, uncomment the next line
133 | #packages/
134 |
135 | # Windows Azure Build Output
136 | csx
137 | *.build.csdef
138 |
139 | # Windows Store app package directory
140 | AppPackages/
141 |
142 | # Others
143 | sql/
144 | *.Cache
145 | ClientBin/
146 | [Ss]tyle[Cc]op.*
147 | ~$*
148 | *~
149 | *.dbmdl
150 | *.[Pp]ublish.xml
151 | *.pfx
152 | *.publishsettings
153 |
154 | # RIA/Silverlight projects
155 | Generated_Code/
156 |
157 | # Backup & report files from converting an old project file to a newer
158 | # Visual Studio version. Backup files are not needed, because we have git ;-)
159 | _UpgradeReport_Files/
160 | Backup*/
161 | UpgradeLog*.XML
162 | UpgradeLog*.htm
163 |
164 | # SQL Server files
165 | App_Data/*.mdf
166 | App_Data/*.ldf
167 |
168 | #############
169 | ## Windows detritus
170 | #############
171 |
172 | # Windows image file caches
173 | Thumbs.db
174 | ehthumbs.db
175 |
176 | # Folder config file
177 | Desktop.ini
178 |
179 | # Recycle Bin used on file shares
180 | $RECYCLE.BIN/
181 |
182 | # Mac crap
183 | .DS_Store
184 |
185 |
186 | #############
187 | ## Python
188 | #############
189 |
190 | *.py[co]
191 |
192 | # Packages
193 | *.egg
194 | *.egg-info
195 | dist/
196 | build/
197 | eggs/
198 | parts/
199 | var/
200 | sdist/
201 | develop-eggs/
202 | .installed.cfg
203 |
204 | # Installer logs
205 | pip-log.txt
206 |
207 | # Unit test / coverage reports
208 | .coverage
209 | .tox
210 |
211 | #Translations
212 | *.mo
213 |
214 | #Mr Developer
215 | .mr.developer.cfg
216 |
--------------------------------------------------------------------------------
/.nuget/NuGet.Config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.nuget/NuGet.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/uzbekdev1/DapperRepository/c871ea58a4a61f717594bd2242e99409ea0d3cb7/.nuget/NuGet.exe
--------------------------------------------------------------------------------
/.nuget/NuGet.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(MSBuildProjectDirectory)\..\
5 |
6 |
7 | false
8 |
9 |
10 | false
11 |
12 |
13 | true
14 |
15 |
16 | false
17 |
18 |
19 |
20 |
21 |
22 |
26 |
27 |
28 |
29 |
30 | $([System.IO.Path]::Combine($(SolutionDir), ".nuget"))
31 |
32 |
33 |
34 |
35 | $(SolutionDir).nuget
36 |
37 |
38 |
39 | $(MSBuildProjectDirectory)\packages.$(MSBuildProjectName.Replace(' ', '_')).config
40 | $(MSBuildProjectDirectory)\packages.$(MSBuildProjectName).config
41 |
42 |
43 |
44 | $(MSBuildProjectDirectory)\packages.config
45 | $(PackagesProjectConfig)
46 |
47 |
48 |
49 |
50 | $(NuGetToolsPath)\NuGet.exe
51 | @(PackageSource)
52 |
53 | "$(NuGetExePath)"
54 | mono --runtime=v4.0.30319 "$(NuGetExePath)"
55 |
56 | $(TargetDir.Trim('\\'))
57 |
58 | -RequireConsent
59 | -NonInteractive
60 |
61 | "$(SolutionDir) "
62 | "$(SolutionDir)"
63 |
64 |
65 | $(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir $(PaddedSolutionDir)
66 | $(NuGetCommand) pack "$(ProjectPath)" -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols
67 |
68 |
69 |
70 | RestorePackages;
71 | $(BuildDependsOn);
72 |
73 |
74 |
75 |
76 | $(BuildDependsOn);
77 | BuildPackage;
78 |
79 |
80 |
81 |
82 |
83 |
84 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
99 |
100 |
103 |
104 |
105 |
106 |
108 |
109 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
141 |
142 |
143 |
144 |
145 |
--------------------------------------------------------------------------------
/DapperRepository.Demo/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/DapperRepository.Demo/DapperRepository.Demo.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {0ACBF4A9-53A4-4B95-9369-8E4965B42903}
8 | Exe
9 | Properties
10 | DapperRepository.Demo
11 | DapperRepository.Demo
12 | v4.5
13 | 512
14 | ..\
15 | true
16 |
17 |
18 | AnyCPU
19 | true
20 | full
21 | false
22 | ..\Build\
23 | DEBUG;TRACE
24 | prompt
25 | 4
26 |
27 |
28 | AnyCPU
29 | pdbonly
30 | true
31 | bin\Release\
32 | TRACE
33 | prompt
34 | 4
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 | {a3de7767-954a-4f71-b796-918dfaaf5291}
58 | DapperRepository.MSSQL
59 |
60 |
61 | {94C2D338-5C1F-427C-8B6F-1BE5FE498F3D}
62 | DapperRepository.MySQL
63 |
64 |
65 | {DD2C6178-CFA7-410D-B125-85C3FAE6EB5A}
66 | DapperRepository.PostgreSQL
67 |
68 |
69 | {6B27BDC9-49DE-4111-A288-36E18AF55CF5}
70 | DapperRepository
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
81 |
82 |
83 |
84 |
91 |
--------------------------------------------------------------------------------
/DapperRepository.Demo/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Configuration;
3 | using DapperRepository.Attributes;
4 | using DapperRepository.Demo.Helpers;
5 | using DapperRepository.Drapper;
6 | using DapperRepository.MSSQL;
7 |
8 | namespace DapperRepository.Demo
9 | {
10 | internal class Program
11 | {
12 | private static IDrapperManager _manager;
13 |
14 | static Program()
15 | {
16 | _manager = RepositoryFactory.GetManager();
17 |
18 | RepositoryFactory.SetManager(_manager);
19 | }
20 |
21 | [Migration(typeof(TempModel))]
22 |
23 | private static void Main(string[] args)
24 | {
25 | using (_manager)
26 | {
27 | _manager.Database.Open();
28 |
29 | //insert
30 | var bv = new TempModel
31 | {
32 | Name = "BV"
33 | };
34 | var bvId = _manager.Database.Insert(bv);
35 |
36 | //get
37 | bv = _manager.Database.Get(bvId);
38 |
39 | //update
40 | bv.Name = "Workfile1";
41 | bv.CreatedDate = DateTime.Now;
42 | bv.LastModifiedDate = DateTime.Now;
43 | _manager.Database.Update(bv);
44 |
45 | //delete
46 | _manager.Database.Delete(bv);
47 |
48 | //all
49 | var bvs = _manager.Database.GetList();
50 | Console.WriteLine("All:");
51 | foreach (var item in bvs)
52 | Console.WriteLine(item.Name);
53 |
54 | //filter
55 | var predicate = Predicates.Field(a => a.Name, Operator.Like, "%a%");
56 | bvs = _manager.Database.GetList(predicate);
57 | Console.WriteLine("Filter(By 'like' operator):");
58 | foreach (var item in bvs)
59 | Console.WriteLine(item.Name);
60 |
61 | _manager.Database.Close();
62 | }
63 | }
64 | }
65 | }
--------------------------------------------------------------------------------
/DapperRepository.Demo/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 |
4 | // General Information about an assembly is controlled through the following
5 | // set of attributes. Change these attribute values to modify the information
6 | // associated with an assembly.
7 |
8 | [assembly: AssemblyTitle("DapperRepository.Demo")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("DapperRepository.Demo")]
13 | [assembly: AssemblyCopyright("Copyright © 2014")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 |
21 | [assembly: ComVisible(false)]
22 |
23 | // The following GUID is for the ID of the typelib if this project is exposed to COM
24 |
25 | [assembly: Guid("c562d654-b2e7-42ae-a63c-9971cdd7133b")]
26 |
27 | // Version information for an assembly consists of the following four values:
28 | //
29 | // Major Version
30 | // Minor Version
31 | // Build Number
32 | // Revision
33 | //
34 | // You can specify all the values or you can default the Build and Revision Numbers
35 | // by using the '*' as shown below:
36 | // [assembly: AssemblyVersion("1.0.*")]
37 |
38 | [assembly: AssemblyVersion("1.0.0.0")]
39 | [assembly: AssemblyFileVersion("1.0.0.0")]
--------------------------------------------------------------------------------
/DapperRepository.Demo/RepositoryConfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SQLite
6 | Data Source=QueryProcessorStorage.sqlite;Version=3;
7 |
8 | 0
9 |
10 | True
11 | False
12 | True
13 |
14 |
15 |
16 |
17 |
28 |
29 |
30 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/DapperRepository.Demo/TempModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace DapperRepository.Demo
4 | {
5 | public class TempModel
6 | {
7 | public TempModel()
8 | {
9 | LastModifiedDate = DateTime.Now;
10 | CreatedDate = DateTime.Now;
11 | }
12 |
13 | public long ID { get; set; }
14 |
15 | public string Name { get; set; }
16 |
17 | public DateTime CreatedDate { get; set; }
18 |
19 | public DateTime LastModifiedDate { get; set; }
20 | }
21 | }
--------------------------------------------------------------------------------
/DapperRepository.Demo/TempModelMapper.cs:
--------------------------------------------------------------------------------
1 | using DapperRepository.Drapper.Mapper;
2 |
3 | namespace DapperRepository.Demo
4 | {
5 | public class TempModelMapper : ClassMapper
6 | {
7 | public TempModelMapper()
8 | {
9 | Table("BusinessView");
10 |
11 | Map(f => f.ID).Column("Id").Key(KeyType.Identity);
12 | Map(f => f.Name).Column("Name");
13 | Map(f => f.CreatedDate).Column("CreatedDate");
14 | Map(f => f.LastModifiedDate).Column("LastModifiedDate");
15 |
16 | Schema("");
17 | }
18 | }
19 | }
--------------------------------------------------------------------------------
/DapperRepository.MSSQL/DapperRepository.MSSQL.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {A3DE7767-954A-4F71-B796-918DFAAF5291}
8 | Library
9 | Properties
10 | DapperRepository.MSSQL
11 | DapperRepository.MSSQL
12 | v4.5
13 | 512
14 |
15 |
16 | true
17 | full
18 | false
19 | ..\Build\
20 | DEBUG;TRACE
21 | prompt
22 | 4
23 |
24 |
25 | pdbonly
26 | true
27 | bin\Release\
28 | TRACE
29 | prompt
30 | 4
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 | {6B27BDC9-49DE-4111-A288-36E18AF55CF5}
50 | DapperRepository
51 |
52 |
53 |
54 |
61 |
--------------------------------------------------------------------------------
/DapperRepository.MSSQL/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 |
4 | // General Information about an assembly is controlled through the following
5 | // set of attributes. Change these attribute values to modify the information
6 | // associated with an assembly.
7 |
8 | [assembly: AssemblyTitle("DapperRepository.MSSQL")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("DapperRepository.MSSQL")]
13 | [assembly: AssemblyCopyright("Copyright © 2014")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 |
21 | [assembly: ComVisible(false)]
22 |
23 | // The following GUID is for the ID of the typelib if this project is exposed to COM
24 |
25 | [assembly: Guid("df8e1185-5729-41c4-bd01-3dd973086c9e")]
26 |
27 | // Version information for an assembly consists of the following four values:
28 | //
29 | // Major Version
30 | // Minor Version
31 | // Build Number
32 | // Revision
33 | //
34 | // You can specify all the values or you can default the Build and Revision Numbers
35 | // by using the '*' as shown below:
36 | // [assembly: AssemblyVersion("1.0.*")]
37 |
38 | [assembly: AssemblyVersion("1.0.0.0")]
39 | [assembly: AssemblyFileVersion("1.0.0.0")]
--------------------------------------------------------------------------------
/DapperRepository.MSSQL/SqlServerDialect.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using DapperRepository.Drapper.Sql;
6 |
7 | namespace DapperRepository.MSSQL
8 | {
9 | internal sealed class SqlServerDialect : SqlDialectBase
10 | {
11 | public override char OpenQuote
12 | {
13 | get { return '['; }
14 | }
15 |
16 | public override char CloseQuote
17 | {
18 | get { return ']'; }
19 | }
20 |
21 | public override string GetIdentitySql(string tableName)
22 | {
23 | return string.Format("SELECT CAST(SCOPE_IDENTITY() AS BIGINT) AS [Id]");
24 | }
25 |
26 | public override string GetPagingSql(string sql, int page, int resultsPerPage, IDictionary parameters)
27 | {
28 | int startValue = (page * resultsPerPage) + 1;
29 | return GetSetSql(sql, startValue, resultsPerPage, parameters);
30 | }
31 |
32 | public override string GetSetSql(string sql, int firstResult, int maxResults, IDictionary parameters)
33 | {
34 | if (string.IsNullOrEmpty(sql))
35 | {
36 | throw new ArgumentNullException("SQL");
37 | }
38 |
39 | if (parameters == null)
40 | {
41 | throw new ArgumentNullException("Parameters");
42 | }
43 |
44 | int selectIndex = GetSelectEnd(sql) + 1;
45 | string orderByClause = GetOrderByClause(sql);
46 | if (orderByClause == null)
47 | {
48 | orderByClause = "ORDER BY CURRENT_TIMESTAMP";
49 | }
50 |
51 |
52 | string projectedColumns = GetColumnNames(sql).Aggregate(new StringBuilder(), (sb, s) => (sb.Length == 0 ? sb : sb.Append(", ")).Append(GetColumnName("_proj", s, null)), sb => sb.ToString());
53 | string newSql = sql
54 | .Replace(" " + orderByClause, string.Empty)
55 | .Insert(selectIndex, string.Format("ROW_NUMBER() OVER(ORDER BY {0}) AS {1}, ", orderByClause.Substring(9), GetColumnName(null, "_row_number", null)));
56 |
57 | string result = string.Format("SELECT TOP({0}) {1} FROM ({2}) [_proj] WHERE {3} >= @_pageStartRow ORDER BY {3}",
58 | maxResults, projectedColumns.Trim(), newSql, GetColumnName("_proj", "_row_number", null));
59 |
60 | parameters.Add("@_pageStartRow", firstResult);
61 | return result;
62 | }
63 |
64 | private string GetOrderByClause(string sql)
65 | {
66 | int orderByIndex = sql.LastIndexOf(" ORDER BY ", StringComparison.InvariantCultureIgnoreCase);
67 | if (orderByIndex == -1)
68 | {
69 | return null;
70 | }
71 |
72 | string result = sql.Substring(orderByIndex).Trim();
73 |
74 | int whereIndex = result.IndexOf(" WHERE ", StringComparison.InvariantCultureIgnoreCase);
75 | if (whereIndex == -1)
76 | {
77 | return result;
78 | }
79 |
80 | return result.Substring(0, whereIndex).Trim();
81 | }
82 |
83 | private int GetFromStart(string sql)
84 | {
85 | int selectCount = 0;
86 | string[] words = sql.Split(' ');
87 | int fromIndex = 0;
88 | foreach (var word in words)
89 | {
90 | if (word.Equals("SELECT", StringComparison.InvariantCultureIgnoreCase))
91 | {
92 | selectCount++;
93 | }
94 |
95 | if (word.Equals("FROM", StringComparison.InvariantCultureIgnoreCase))
96 | {
97 | selectCount--;
98 | if (selectCount == 0)
99 | {
100 | break;
101 | }
102 | }
103 |
104 | fromIndex += word.Length + 1;
105 | }
106 |
107 | return fromIndex;
108 | }
109 |
110 | private int GetSelectEnd(string sql)
111 | {
112 | if (sql.StartsWith("SELECT DISTINCT", StringComparison.InvariantCultureIgnoreCase))
113 | {
114 | return 15;
115 | }
116 |
117 | if (sql.StartsWith("SELECT", StringComparison.InvariantCultureIgnoreCase))
118 | {
119 | return 6;
120 | }
121 |
122 | throw new ArgumentException("SQL must be a SELECT statement.", "sql");
123 | }
124 |
125 | private IList GetColumnNames(string sql)
126 | {
127 | int start = GetSelectEnd(sql);
128 | int stop = GetFromStart(sql);
129 | string[] columnSql = sql.Substring(start, stop - start).Split(',');
130 | List result = new List();
131 | foreach (string c in columnSql)
132 | {
133 | int index = c.IndexOf(" AS ", StringComparison.InvariantCultureIgnoreCase);
134 | if (index > 0)
135 | {
136 | result.Add(c.Substring(index + 4).Trim());
137 | continue;
138 | }
139 |
140 | string[] colParts = c.Split('.');
141 | result.Add(colParts[colParts.Length - 1].Trim());
142 | }
143 |
144 | return result;
145 | }
146 |
147 | public override string GetTableName(string schemaName, string tableName, string alias)
148 | {
149 | if (String.IsNullOrWhiteSpace(schemaName))
150 | schemaName = "dbo";
151 |
152 | return base.GetTableName(schemaName, tableName, alias);
153 | }
154 |
155 | public override string GetColumnName(string prefix, string columnName, string alias)
156 | {
157 | return base.GetColumnName(null, columnName, alias);
158 | }
159 | }
160 | }
--------------------------------------------------------------------------------
/DapperRepository.MSSQL/SqlServerGenerator.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Data.SqlClient;
4 | using System.Linq;
5 | using System.Text;
6 | using DapperRepository.Drapper;
7 | using DapperRepository.Drapper.Mapper;
8 | using DapperRepository.Drapper.Sql;
9 | using DapperRepository.Extensions;
10 | using DapperRepository.Models;
11 |
12 | namespace DapperRepository.MSSQL
13 | {
14 | internal class SqlServerGenerator : SqlGenerator
15 | {
16 | private static RepositoryModel _model;
17 | private const string DATABASE_KEY = @"Initial Catalog";
18 | private const string DATABASE_VALUE = "master";
19 |
20 | private object ExecuteScalar(string query)
21 | {
22 | object result = null;
23 |
24 | using (var conn = new SqlConnection(ConnectionString()))
25 | {
26 | conn.Open();
27 |
28 | using (var com = new SqlCommand(query, conn))
29 | result = com.ExecuteScalar();
30 |
31 | conn.Close();
32 | }
33 |
34 | return result;
35 | }
36 |
37 | public SqlServerGenerator(IDapperExtensionsConfiguration configuration)
38 | : base(configuration)
39 | {
40 | _model = RepositoryFactory.GetModel();
41 | }
42 |
43 | public override string Schema(IClassMapper classMapper)
44 | {
45 | return String.Format(@"IF (NOT EXISTS (SELECT * FROM sys.schemas WHERE name = '{0}'))
46 | EXEC ('CREATE SCHEMA [{0}] AUTHORIZATION [dbo]');", classMapper.SchemaName);
47 | }
48 |
49 | public override string Database()
50 | {
51 | var connectionKeys = _model.ConnectionString.AsSplit(";");
52 | var dbKeys = connectionKeys.Select(item => item.AsSplit("="))
53 | .FirstOrDefault(f => f.Length == 2 && f[0].IsString(DATABASE_KEY));
54 | var dbName = dbKeys[1];
55 | var dataPath = ExecuteScalar(String.Format(@"SELECT REPLACE(physical_name,name,N'{0}') FROM sys.master_files WHERE database_id = DB_ID(N'master') AND physical_name like '%.mdf';", dbName)).AsString();
56 | var logPath = ExecuteScalar(String.Format(@"SELECT REPLACE(physical_name,name,N'{0}_log') FROM sys.master_files WHERE database_id = DB_ID(N'master') AND physical_name like '%.ldf';", dbName)).AsString();
57 |
58 | return String.Format(@"IF NOT EXISTS (SELECT * FROM sys.databases WHERE name = '{0}')
59 | BEGIN
60 | CREATE DATABASE [{0}] ON PRIMARY
61 | (
62 | NAME = N'{0}',
63 | FILENAME =N'{1}',
64 | SIZE = 31744KB ,
65 | MAXSIZE = UNLIMITED,
66 | FILEGROWTH = 1024KB
67 | )
68 | LOG ON
69 | (
70 | NAME = N'{0}_log',
71 | FILENAME =N'{2}' ,
72 | SIZE = 3840KB ,
73 | MAXSIZE = 2048GB ,
74 | FILEGROWTH = 10%
75 | )
76 | END", dbName, dataPath, logPath);
77 | }
78 |
79 | public override string ConnectionString()
80 | {
81 | var connectionKeys = _model.ConnectionString.AsSplit(";");
82 | var dbKeys = connectionKeys.Select(item => item.AsSplit("="))
83 | .Where(f => f.Length == 2);
84 |
85 | return String.Join("", dbKeys.Select(s => String.Format("{0}={1};", s[0], s[0].IsString(DATABASE_KEY) ? DATABASE_VALUE : s[1])));
86 | }
87 |
88 | public override string Create(IClassMapper classMap)
89 | {
90 | var columns = classMap.Properties.Where(p => !(p.Ignored || p.IsReadOnly)).ToArray();
91 |
92 | if (!columns.Any())
93 | {
94 | throw new ArgumentException("No columns were mapped.");
95 | }
96 |
97 | var columnKeys = columns.Select(p => new KeyValuePair(p.PropertyInfo.PropertyType, GetColumnName(classMap, p, false)))
98 | .ToList();
99 | var sql = new StringBuilder();
100 |
101 | sql.AppendFormat(@"IF (OBJECT_ID('{0}', 'U') IS NULL)", GetTableName(classMap))
102 | .AppendLine();
103 | sql.AppendFormat("CREATE TABLE {0}", GetTableName(classMap)).AppendLine();
104 | sql.AppendLine("(");
105 |
106 | var index = 0;
107 | foreach (var columnKey in columnKeys)
108 | {
109 | var column = columns.FirstOrDefault(f => columnKey.Key == f.PropertyInfo.PropertyType &&
110 | columnKey.Value.IndexOf(f.Name, StringComparison.InvariantCultureIgnoreCase) >= 0);
111 |
112 | if (column == null)
113 | continue;
114 |
115 | if (index > 0)
116 | sql.Append(",");
117 |
118 | switch (column.KeyType)
119 | {
120 | case KeyType.Identity:
121 | sql.AppendFormat("{0} {1} NOT NULL IDENTITY(1,1) PRIMARY KEY",
122 | columnKey.Value,
123 | Configuration.DataMapper[columnKey.Key]);
124 | break;
125 | default:
126 | sql.AppendFormat("{0} {1} NULL",
127 | columnKey.Value,
128 | Configuration.DataMapper[columnKey.Key]);
129 | break;
130 | }
131 |
132 | sql.AppendLine();
133 | index++;
134 | }
135 |
136 | sql.AppendLine(")");
137 |
138 | return sql.ToString();
139 | }
140 |
141 | }
142 | }
143 |
--------------------------------------------------------------------------------
/DapperRepository.MSSQL/SqlServerManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Data.SqlClient;
4 | using DapperRepository.Models;
5 | using DapperRepository.Drapper;
6 |
7 | namespace DapperRepository.MSSQL
8 | {
9 | internal class SqlServerManager : DrapperManager
10 | {
11 | private static readonly IDictionary _dataMapper;
12 | private readonly RepositoryModel _model;
13 |
14 | static SqlServerManager()
15 | {
16 | _dataMapper = new Dictionary()
17 | {
18 | {typeof (long), "BIGINT"},
19 | {typeof (int), "INT"},
20 | {typeof (byte), "SMALLINT"},
21 | {typeof (string), "NVARCHAR(MAX)"},
22 | {typeof (bool), "BIT"},
23 | {typeof (DateTime), "DATETIME"},
24 | {typeof (float), "FLOAT"},
25 | {typeof (double), "FLOAT"},
26 | {typeof (decimal), "NUMERIC"},
27 | {typeof (byte[]), "VARBINARY"},
28 | };
29 | }
30 |
31 | public SqlServerManager(RepositoryModel model)
32 | : base(new SqlServerGenerator(new DapperExtensionsConfiguration(_dataMapper, null, null, new SqlServerDialect())),
33 | new SqlConnection(model.ConnectionString),
34 | new SqlServerDialect())
35 | {
36 | _model = model;
37 | }
38 |
39 | public override void Init()
40 | {
41 |
42 | }
43 |
44 | ///
45 | /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
46 | ///
47 | public override void Dispose()
48 | {
49 |
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/DapperRepository.MySQL/DapperRepository.MySQL.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {94C2D338-5C1F-427C-8B6F-1BE5FE498F3D}
8 | Library
9 | Properties
10 | DapperRepository.MySQL
11 | DapperRepository.MySQL
12 | v4.5
13 | 512
14 | ..\
15 | true
16 |
17 |
18 | true
19 | full
20 | false
21 | ..\Build\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 |
26 |
27 | pdbonly
28 | true
29 | bin\Release\
30 | TRACE
31 | prompt
32 | 4
33 |
34 |
35 |
36 | True
37 | ..\packages\MySql.Data.6.8.3\lib\net45\MySql.Data.dll
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | {6B27BDC9-49DE-4111-A288-36E18AF55CF5}
59 | DapperRepository
60 |
61 |
62 |
63 |
64 |
65 |
66 | This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
67 |
68 |
69 |
70 |
77 |
--------------------------------------------------------------------------------
/DapperRepository.MySQL/MySqlDialect.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using DapperRepository.Drapper.Sql;
3 |
4 | namespace DapperRepository.MySQL
5 | {
6 | internal class MySqlDialect : SqlDialectBase
7 | {
8 | public override char OpenQuote
9 | {
10 | get { return '`'; }
11 | }
12 |
13 | public override char CloseQuote
14 | {
15 | get { return '`'; }
16 | }
17 |
18 | public override string GetIdentitySql(string tableName)
19 | {
20 | return "SELECT LAST_INSERT_ID() AS Id";
21 | }
22 |
23 | public override string GetPagingSql(string sql, int page, int resultsPerPage, IDictionary parameters)
24 | {
25 | int startValue = page * resultsPerPage;
26 | return GetSetSql(sql, startValue, resultsPerPage, parameters);
27 | }
28 |
29 | public override string GetSetSql(string sql, int firstResult, int maxResults, IDictionary parameters)
30 | {
31 | string result = string.Format("{0} LIMIT @firstResult, @maxResults", sql);
32 | parameters.Add("@firstResult", firstResult);
33 | parameters.Add("@maxResults", maxResults);
34 | return result;
35 | }
36 |
37 | public override string GetColumnName(string prefix, string columnName, string alias)
38 | {
39 | return base.GetColumnName(null, columnName, alias);
40 | }
41 |
42 | public override string GetTableName(string schemaName, string tableName, string alias)
43 | {
44 | return base.GetTableName(null, tableName, alias);
45 | }
46 | }
47 | }
--------------------------------------------------------------------------------
/DapperRepository.MySQL/MySqlGenerator.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using DapperRepository.Drapper;
6 | using DapperRepository.Drapper.Mapper;
7 | using DapperRepository.Drapper.Sql;
8 | using DapperRepository.Extensions;
9 | using DapperRepository.Models;
10 |
11 | namespace DapperRepository.MySQL
12 | {
13 | internal class MySqlGenerator : SqlGenerator
14 | {
15 |
16 | private static RepositoryModel _model;
17 | private const string DATABASE_KEY = @"database";
18 |
19 | public MySqlGenerator(IDapperExtensionsConfiguration configuration)
20 | : base(configuration)
21 | {
22 | _model = RepositoryFactory.GetModel();
23 | }
24 |
25 | public override string Database()
26 | {
27 | var connectionKeys = _model.ConnectionString.AsSplit(";");
28 | var dbKeys = connectionKeys.Select(item => item.AsSplit("="))
29 | .FirstOrDefault(f => f.Length == 2 && f[0].IsString(DATABASE_KEY));
30 | var dbName = dbKeys[1];
31 |
32 | return String.Format("CREATE DATABASE IF NOT EXISTS `{0}`", dbName);
33 | }
34 |
35 | public override string ConnectionString()
36 | {
37 | var connectionKeys = _model.ConnectionString.AsSplit(";");
38 | var dbKeys = connectionKeys.Select(item => item.AsSplit("="))
39 | .Where(f => f.Length == 2 && !f[0].IsString(DATABASE_KEY));
40 |
41 | return String.Join("", dbKeys.Select(s => String.Format("{0}={1};", s[0], s[1])));
42 | }
43 |
44 | public override string Create(IClassMapper classMap)
45 | {
46 | var columns = classMap.Properties.Where(p => !(p.Ignored || p.IsReadOnly)).ToArray();
47 |
48 | if (!columns.Any())
49 | {
50 | throw new ArgumentException("No columns were mapped.");
51 | }
52 |
53 | var columnKeys = columns.Select(p => new KeyValuePair(p.PropertyInfo.PropertyType, GetColumnName(classMap, p, false)))
54 | .ToList();
55 | var sql = new StringBuilder();
56 |
57 | sql.AppendFormat("CREATE TABLE IF NOT EXISTS {0}", GetTableName(classMap)).AppendLine();
58 | sql.AppendLine("(");
59 |
60 | var index = 0;
61 | var pk = String.Empty;
62 |
63 | foreach (var columnKey in columnKeys)
64 | {
65 | var column = columns.FirstOrDefault(f => columnKey.Key == f.PropertyInfo.PropertyType &&
66 | columnKey.Value.IndexOf(f.Name, StringComparison.InvariantCultureIgnoreCase) >= 0);
67 |
68 | if (column == null)
69 | continue;
70 |
71 | switch (column.KeyType)
72 | {
73 | case KeyType.Identity:
74 | pk = columnKey.Value;
75 | sql.AppendFormat("{0} {1} NOT NULL AUTO_INCREMENT",
76 | pk, Configuration.DataMapper[columnKey.Key]);
77 |
78 | break;
79 | default:
80 | sql.AppendFormat("{0} {1} NULL",
81 | columnKey.Value, Configuration.DataMapper[columnKey.Key]);
82 | break;
83 | }
84 |
85 | sql.Append(",")
86 | .AppendLine();
87 |
88 | index++;
89 | }
90 |
91 | if (!String.IsNullOrWhiteSpace(pk))
92 | {
93 | sql.AppendFormat(" PRIMARY KEY ({0})", pk)
94 | .AppendLine();
95 | }
96 |
97 | sql.AppendLine(")");
98 |
99 | return sql.ToString();
100 | }
101 |
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/DapperRepository.MySQL/MySqlManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using DapperRepository.Drapper;
4 | using MySql.Data.MySqlClient;
5 | using DapperRepository.Models;
6 |
7 | namespace DapperRepository.MySQL
8 | {
9 | internal class MySqlManager : DrapperManager
10 | {
11 | private static readonly IDictionary _dataMapper;
12 | private RepositoryModel _model;
13 | static MySqlManager()
14 | {
15 | _dataMapper = new Dictionary
16 | {
17 | {typeof (long), "bigint"},
18 | {typeof (int), "integer"},
19 | {typeof (byte), "smallint"},
20 | {typeof (string), "text"},
21 | {typeof (char), "varchar"},
22 | {typeof (bool), "bit(1)"},
23 | {typeof (DateTime), "datetime"},
24 | {typeof (float), "float"},
25 | {typeof (double), "double"},
26 | {typeof (decimal), "decimal"},
27 | {typeof (byte[]), "binary"},
28 | };
29 | }
30 |
31 | public MySqlManager(RepositoryModel model)
32 | : base(new MySqlGenerator(new DapperExtensionsConfiguration(_dataMapper, null, null, new MySqlDialect())),
33 | new MySqlConnection(model.ConnectionString),
34 | new MySqlDialect())
35 | {
36 | _model = model;
37 | }
38 |
39 | public override void Init()
40 | {
41 | }
42 |
43 | ///
44 | /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
45 | ///
46 | public override void Dispose()
47 | {
48 |
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/DapperRepository.MySQL/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 |
4 | // General Information about an assembly is controlled through the following
5 | // set of attributes. Change these attribute values to modify the information
6 | // associated with an assembly.
7 |
8 | [assembly: AssemblyTitle("DapperRepository.MySQL")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("DapperRepository.MySQL")]
13 | [assembly: AssemblyCopyright("Copyright © 2014")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 |
21 | [assembly: ComVisible(false)]
22 |
23 | // The following GUID is for the ID of the typelib if this project is exposed to COM
24 |
25 | [assembly: Guid("7be66e0e-7060-45d6-96c9-002d07344fc2")]
26 |
27 | // Version information for an assembly consists of the following four values:
28 | //
29 | // Major Version
30 | // Minor Version
31 | // Build Number
32 | // Revision
33 | //
34 | // You can specify all the values or you can default the Build and Revision Numbers
35 | // by using the '*' as shown below:
36 | // [assembly: AssemblyVersion("1.0.*")]
37 |
38 | [assembly: AssemblyVersion("1.0.0.0")]
39 | [assembly: AssemblyFileVersion("1.0.0.0")]
--------------------------------------------------------------------------------
/DapperRepository.MySQL/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/DapperRepository.PostgreSQL/DapperRepository.PostgreSQL.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {DD2C6178-CFA7-410D-B125-85C3FAE6EB5A}
8 | Library
9 | Properties
10 | DapperRepository.PostgreSQL
11 | DapperRepository.PostgreSQL
12 | v4.5
13 | 512
14 | ..\
15 | true
16 |
17 |
18 | true
19 | full
20 | false
21 | ..\Build\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 |
26 |
27 | pdbonly
28 | true
29 | bin\Release\
30 | TRACE
31 | prompt
32 | 4
33 |
34 |
35 |
36 | ..\packages\Npgsql.2.1.3\lib\net45\Mono.Security.dll
37 |
38 |
39 | ..\packages\Npgsql.2.1.3\lib\net45\Npgsql.dll
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 | {6B27BDC9-49DE-4111-A288-36E18AF55CF5}
61 | DapperRepository
62 |
63 |
64 |
65 |
66 |
67 |
68 | This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
69 |
70 |
71 |
72 |
79 |
--------------------------------------------------------------------------------
/DapperRepository.PostgreSQL/PostgreSqlDialect.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using DapperRepository.Drapper.Sql;
3 |
4 | namespace DapperRepository.PostgreSQL
5 | {
6 | internal class PostgreSqlDialect : SqlDialectBase
7 | {
8 | public override string GetIdentitySql(string tableName)
9 | {
10 | return "SELECT LASTVAL() AS Id";
11 | }
12 |
13 | public override string GetPagingSql(string sql, int page, int resultsPerPage, IDictionary parameters)
14 | {
15 | int startValue = page * resultsPerPage;
16 | return GetSetSql(sql, startValue, resultsPerPage, parameters);
17 | }
18 |
19 | public override string GetSetSql(string sql, int firstResult, int maxResults, IDictionary parameters)
20 | {
21 | string result = string.Format("{0} LIMIT @firstResult OFFSET @pageStartRowNbr", sql);
22 | parameters.Add("@firstResult", firstResult);
23 | parameters.Add("@maxResults", maxResults);
24 | return result;
25 | }
26 |
27 | public override string GetColumnName(string prefix, string columnName, string alias)
28 | {
29 | return base.GetColumnName(null, columnName, alias);
30 | }
31 |
32 | public override string GetTableName(string schemaName, string tableName, string alias)
33 | {
34 | if (string.IsNullOrWhiteSpace(schemaName))
35 | schemaName = "public";
36 |
37 | return base.GetTableName(schemaName, tableName, alias);
38 | }
39 | }
40 |
41 | }
--------------------------------------------------------------------------------
/DapperRepository.PostgreSQL/PostgreSqlGenerator.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using DapperRepository.Drapper;
6 | using DapperRepository.Drapper.Mapper;
7 | using DapperRepository.Drapper.Sql;
8 | using DapperRepository.Extensions;
9 | using DapperRepository.Models;
10 |
11 | namespace DapperRepository.PostgreSQL
12 | {
13 | internal class PostgreSqlGenerator : SqlGenerator
14 | {
15 | private static RepositoryModel _model;
16 | private const string DATABASE_KEY = @"Database";
17 | private const string DATABASE_VALUE = "postgres";
18 |
19 | public PostgreSqlGenerator(IDapperExtensionsConfiguration configuration)
20 | : base(configuration)
21 | {
22 | _model = RepositoryFactory.GetModel();
23 | }
24 |
25 | public override string Schema(IClassMapper classMapper)
26 | {
27 | return String.Format("CREATE SCHEMA IF NOT EXISTS \"{0}\"", classMapper.SchemaName);
28 | }
29 |
30 |
31 | public override string Database()
32 | {
33 | var connectionKeys = _model.ConnectionString.AsSplit(";");
34 | var dbKeys = connectionKeys.Select(item => item.AsSplit("="))
35 | .FirstOrDefault(f => f.Length == 2 && f[0].IsString(DATABASE_KEY));
36 | var dbName = dbKeys[1];
37 |
38 | return String.Format("CREATE DATABASE \"{0}\"" +
39 | @"WITH OWNER = postgres
40 | ENCODING = 'UTF8'
41 | TABLESPACE = pg_default;", dbName);
42 | }
43 |
44 | public override string ConnectionString()
45 | {
46 | var connectionKeys = _model.ConnectionString.AsSplit(";");
47 | var dbKeys = connectionKeys.Select(item => item.AsSplit("="))
48 | .Where(f => f.Length == 2);
49 |
50 | return String.Join("", dbKeys.Select(s => String.Format("{0}={1};", s[0], s[0].IsString(DATABASE_KEY) ? DATABASE_VALUE : s[1])));
51 | }
52 |
53 | public override string Create(IClassMapper classMap)
54 | {
55 | var columns = classMap.Properties.Where(p => !(p.Ignored || p.IsReadOnly)).ToArray();
56 |
57 | if (!columns.Any())
58 | {
59 | throw new ArgumentException("No columns were mapped.");
60 | }
61 |
62 | var columnKeys = columns.Select(p => new KeyValuePair(p.PropertyInfo.PropertyType, GetColumnName(classMap, p, false)))
63 | .ToList();
64 | var sql = new StringBuilder();
65 |
66 | sql.AppendFormat("CREATE TABLE IF NOT EXISTS {0}", GetTableName(classMap)).AppendLine();
67 | sql.AppendLine("(");
68 |
69 | var index = 0;
70 | foreach (var columnKey in columnKeys)
71 | {
72 | var column = columns.FirstOrDefault(f => columnKey.Key == f.PropertyInfo.PropertyType &&
73 | columnKey.Value.IndexOf(f.Name, StringComparison.InvariantCultureIgnoreCase) >= 0);
74 |
75 | if (column == null)
76 | continue;
77 |
78 | if (index > 0)
79 | sql.AppendLine(",");
80 |
81 | switch (column.KeyType)
82 | {
83 | case KeyType.Identity:
84 | sql.AppendFormat("{0} SERIAL NOT NULL PRIMARY KEY",
85 | columnKey.Value);
86 | break;
87 | default:
88 | sql.AppendFormat("{0} {1} NULL",
89 | columnKey.Value,
90 | Configuration.DataMapper[columnKey.Key]);
91 | break;
92 | }
93 |
94 | sql.AppendLine();
95 | index++;
96 | }
97 |
98 | sql.AppendLine(")");
99 |
100 | return sql.ToString();
101 | }
102 |
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/DapperRepository.PostgreSQL/PostgreSqlManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using DapperRepository.Drapper;
4 | using DapperRepository.Models;
5 | using Npgsql;
6 |
7 | namespace DapperRepository.PostgreSQL
8 | {
9 | internal class PostgreSqlManager : DrapperManager
10 | {
11 | private static readonly IDictionary _dataMapper;
12 | private readonly RepositoryModel _model;
13 |
14 | static PostgreSqlManager()
15 | {
16 | _dataMapper = new Dictionary
17 | {
18 | {typeof (long), "bigint"},
19 | {typeof (int), "integer"},
20 | {typeof (byte), "smallint"},
21 | {typeof (string), "text"},
22 | {typeof (char), "character varying"},
23 | {typeof (bool), "boolean"},
24 | {typeof (DateTime), "timestamp without time zone"},
25 | {typeof (float), "real"},
26 | {typeof (double), "double precision"},
27 | {typeof (decimal), "numeric"},
28 | {typeof (byte[]), "bytea"},
29 | };
30 | }
31 |
32 | public PostgreSqlManager(RepositoryModel model)
33 | : base(new PostgreSqlGenerator(new DapperExtensionsConfiguration(_dataMapper, null, null, new PostgreSqlDialect())),
34 | new NpgsqlConnection(model.ConnectionString),
35 | new PostgreSqlDialect())
36 | {
37 | _model = model;
38 | }
39 |
40 | public override void Init()
41 | {
42 | }
43 |
44 | ///
45 | /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
46 | ///
47 | public override void Dispose()
48 | {
49 |
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/DapperRepository.PostgreSQL/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 |
4 | // General Information about an assembly is controlled through the following
5 | // set of attributes. Change these attribute values to modify the information
6 | // associated with an assembly.
7 |
8 | [assembly: AssemblyTitle("PostgreSQL")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("PostgreSQL")]
13 | [assembly: AssemblyCopyright("Copyright © 2014")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 |
21 | [assembly: ComVisible(false)]
22 |
23 | // The following GUID is for the ID of the typelib if this project is exposed to COM
24 |
25 | [assembly: Guid("5b6e89a0-555b-4796-acef-32cc718cb071")]
26 |
27 | // Version information for an assembly consists of the following four values:
28 | //
29 | // Major Version
30 | // Minor Version
31 | // Build Number
32 | // Revision
33 | //
34 | // You can specify all the values or you can default the Build and Revision Numbers
35 | // by using the '*' as shown below:
36 | // [assembly: AssemblyVersion("1.0.*")]
37 |
38 | [assembly: AssemblyVersion("1.0.0.0")]
39 | [assembly: AssemblyFileVersion("1.0.0.0")]
--------------------------------------------------------------------------------
/DapperRepository.PostgreSQL/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/DapperRepository.SQLite/DapperRepository.SQLite.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {96D35BD9-F59E-49CF-8292-B06680D4850A}
8 | Library
9 | Properties
10 | DapperRepository.SQLite
11 | DapperRepository.SQLite
12 | v4.5
13 | 512
14 | ..\
15 | true
16 |
17 |
18 | true
19 | full
20 | false
21 | ..\Build\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 |
26 |
27 | pdbonly
28 | true
29 | bin\Release\
30 | TRACE
31 | prompt
32 | 4
33 |
34 |
35 |
36 |
37 |
38 | ..\packages\System.Data.SQLite.Core.1.0.93.0\lib\net45\System.Data.SQLite.dll
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 | Always
55 |
56 |
57 | Always
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 | {6B27BDC9-49DE-4111-A288-36E18AF55CF5}
66 | DapperRepository
67 |
68 |
69 |
70 |
71 |
72 |
73 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
74 |
75 |
76 |
77 |
84 |
--------------------------------------------------------------------------------
/DapperRepository.SQLite/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("DapperRepository.SQLite")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("DapperRepository.SQLite")]
13 | [assembly: AssemblyCopyright("Copyright © 2014")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("6d933b6a-e8a9-439f-8c0b-ea624b959212")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/DapperRepository.SQLite/SqliteDialect.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using DapperRepository.Drapper.Sql;
3 |
4 | namespace DapperRepository.SQLite
5 | {
6 | internal class SqliteDialect : SqlDialectBase
7 | {
8 | public override char OpenQuote
9 | {
10 | get { return '`'; }
11 | }
12 |
13 | public override char CloseQuote
14 | {
15 | get { return '`'; }
16 | }
17 |
18 | public override string GetIdentitySql(string tableName)
19 | {
20 | return "SELECT LAST_INSERT_ROWID()";
21 | }
22 |
23 | public override string GetPagingSql(string sql, int page, int resultsPerPage, IDictionary parameters)
24 | {
25 | int startValue = page * resultsPerPage;
26 | return GetSetSql(sql, startValue, resultsPerPage, parameters);
27 | }
28 |
29 | public override string GetSetSql(string sql, int firstResult, int maxResults, IDictionary parameters)
30 | {
31 | string result = string.Format("{0} LIMIT @firstResult, @maxResults", sql);
32 | parameters.Add("@firstResult", firstResult);
33 | parameters.Add("@maxResults", maxResults);
34 | return result;
35 | }
36 |
37 | public override string GetColumnName(string prefix, string columnName, string alias)
38 | {
39 | return base.GetColumnName(null, columnName, alias);
40 | }
41 |
42 | public override string GetTableName(string schemaName, string tableName, string alias)
43 | {
44 | return base.GetTableName(null, tableName, alias);
45 | }
46 | }
47 | }
--------------------------------------------------------------------------------
/DapperRepository.SQLite/SqliteGenerator.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Data.SQLite;
4 | using System.IO;
5 | using System.Linq;
6 | using System.Text;
7 | using DapperRepository.Drapper;
8 | using DapperRepository.Drapper.Sql;
9 | using DapperRepository.Extensions;
10 | using DapperRepository.Models;
11 | using DapperRepository.Drapper.Mapper;
12 |
13 | namespace DapperRepository.SQLite
14 | {
15 | internal class SqliteGenerator : SqlGenerator
16 | {
17 |
18 | private static RepositoryModel _model;
19 | private const string DATABASE_KEY = @"Data Source";
20 |
21 | public SqliteGenerator(IDapperExtensionsConfiguration configuration)
22 | : base(configuration)
23 | {
24 | _model = RepositoryFactory.GetModel();
25 | }
26 |
27 | public override string Database()
28 | {
29 | var connectionKeys = _model.ConnectionString.AsSplit(";");
30 | var dbKeys = connectionKeys.Select(item => item.AsSplit("="))
31 | .FirstOrDefault(f => f.Length == 2 && f[0].IsString(DATABASE_KEY));
32 | var dbName = dbKeys[1];
33 | var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, dbName);
34 |
35 | //create database if not exists
36 | if (!File.Exists(path))
37 | {
38 | SQLiteConnection.CreateFile(dbName);
39 | }
40 |
41 | return String.Empty;
42 | }
43 |
44 | public override string Exists(IClassMapper classMap)
45 | {
46 | return String.Format("SELECT COUNT(*) FROM sqlite_master WHERE name ='{0}' and type='table'", classMap.TableName);
47 | }
48 |
49 | public override string ConnectionString()
50 | {
51 | var connectionKeys = _model.ConnectionString.AsSplit(";");
52 | var dbKeys = connectionKeys.Select(item => item.AsSplit("="))
53 | .Where(f => f.Length == 2 && !f[0].IsString(DATABASE_KEY));
54 |
55 | return String.Join("", dbKeys.Select(s => String.Format("{0}={1};", s[0], s[1])));
56 | }
57 |
58 | public override string Create(IClassMapper classMap)
59 | {
60 | var columns = classMap.Properties.Where(p => !(p.Ignored || p.IsReadOnly)).ToArray();
61 |
62 | if (!columns.Any())
63 | {
64 | throw new ArgumentException("No columns were mapped.");
65 | }
66 |
67 | var columnKeys = columns.Select(p => new KeyValuePair(p.PropertyInfo.PropertyType, GetColumnName(classMap, p, false)))
68 | .ToList();
69 | var sql = new StringBuilder();
70 |
71 | sql.AppendFormat("CREATE TABLE IF NOT EXISTS {0}", GetTableName(classMap)).AppendLine();
72 | sql.AppendLine("(");
73 |
74 | var index = 0;
75 |
76 | foreach (var columnKey in columnKeys)
77 | {
78 | var column = columns.FirstOrDefault(f => columnKey.Key == f.PropertyInfo.PropertyType &&
79 | columnKey.Value.IndexOf(f.Name, StringComparison.InvariantCultureIgnoreCase) >= 0);
80 |
81 | if (column == null)
82 | continue;
83 |
84 | if (index > 0)
85 | sql.Append(",");
86 |
87 | switch (column.KeyType)
88 | {
89 | case KeyType.Identity:
90 | sql.AppendFormat("{0} {1} NOT NULL PRIMARY KEY AUTOINCREMENT",
91 | columnKey.Value, Configuration.DataMapper[columnKey.Key]);
92 |
93 | break;
94 | default:
95 | sql.AppendFormat("{0} {1} NULL",
96 | columnKey.Value, Configuration.DataMapper[columnKey.Key]);
97 | break;
98 | }
99 |
100 | sql.AppendLine();
101 |
102 | index++;
103 | }
104 |
105 | sql.AppendLine(")");
106 |
107 | return sql.ToString();
108 | }
109 |
110 | }
111 | }
112 |
--------------------------------------------------------------------------------
/DapperRepository.SQLite/SqliteManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Data.SQLite;
4 | using DapperRepository.Drapper;
5 | using DapperRepository.Models;
6 |
7 | namespace DapperRepository.SQLite
8 | {
9 | internal class SqliteManager : DrapperManager
10 | {
11 | private static readonly IDictionary _dataMapper;
12 | private RepositoryModel _model;
13 | static SqliteManager()
14 | {
15 | _dataMapper = new Dictionary
16 | {
17 | {typeof (long), "INTEGER"},
18 | {typeof (int), "INTEGER"},
19 | {typeof (byte), "INTEGER"},
20 | {typeof (string), "TEXT"},
21 | {typeof (char), "TEXT"},
22 | {typeof (bool), "BIT"},
23 | {typeof (DateTime), "DATETIME"},
24 | {typeof (float), "REAL"},
25 | {typeof (double), "DOUBLE"},
26 | {typeof (decimal), "NUMERIC"},
27 | {typeof (byte[]), "BLOB"},
28 | };
29 | }
30 |
31 | public SqliteManager(RepositoryModel model)
32 | : base(new SqliteGenerator(new DapperExtensionsConfiguration(_dataMapper, null, null, new SqliteDialect())),
33 | new SQLiteConnection(model.ConnectionString),
34 | new SqliteDialect())
35 | {
36 | _model = model;
37 | }
38 |
39 | public override void Init()
40 | {
41 | }
42 |
43 | ///
44 | /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
45 | ///
46 | public override void Dispose()
47 | {
48 |
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/DapperRepository.SQLite/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/DapperRepository.SQLite/x64/SQLite.Interop.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/uzbekdev1/DapperRepository/c871ea58a4a61f717594bd2242e99409ea0d3cb7/DapperRepository.SQLite/x64/SQLite.Interop.dll
--------------------------------------------------------------------------------
/DapperRepository.SQLite/x86/SQLite.Interop.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/uzbekdev1/DapperRepository/c871ea58a4a61f717594bd2242e99409ea0d3cb7/DapperRepository.SQLite/x86/SQLite.Interop.dll
--------------------------------------------------------------------------------
/DapperRepository.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2013
4 | VisualStudioVersion = 12.0.30723.0
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DapperRepository", "DapperRepository\DapperRepository.csproj", "{6B27BDC9-49DE-4111-A288-36E18AF55CF5}"
7 | EndProject
8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{08AD06A9-EDA7-4CE9-B98E-6B0F7BCAFE8E}"
9 | ProjectSection(SolutionItems) = preProject
10 | .nuget\NuGet.Config = .nuget\NuGet.Config
11 | .nuget\NuGet.exe = .nuget\NuGet.exe
12 | .nuget\NuGet.targets = .nuget\NuGet.targets
13 | EndProjectSection
14 | EndProject
15 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DapperRepository.MSSQL", "DapperRepository.MSSQL\DapperRepository.MSSQL.csproj", "{A3DE7767-954A-4F71-B796-918DFAAF5291}"
16 | EndProject
17 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DapperRepository.MySQL", "DapperRepository.MySQL\DapperRepository.MySQL.csproj", "{94C2D338-5C1F-427C-8B6F-1BE5FE498F3D}"
18 | EndProject
19 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DapperRepository.Demo", "DapperRepository.Demo\DapperRepository.Demo.csproj", "{0ACBF4A9-53A4-4B95-9369-8E4965B42903}"
20 | EndProject
21 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DapperRepository.PostgreSQL", "DapperRepository.PostgreSQL\DapperRepository.PostgreSQL.csproj", "{DD2C6178-CFA7-410D-B125-85C3FAE6EB5A}"
22 | EndProject
23 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DapperRepository.SQLite", "DapperRepository.SQLite\DapperRepository.SQLite.csproj", "{96D35BD9-F59E-49CF-8292-B06680D4850A}"
24 | EndProject
25 | Global
26 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
27 | Debug|Any CPU = Debug|Any CPU
28 | Release|Any CPU = Release|Any CPU
29 | EndGlobalSection
30 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
31 | {6B27BDC9-49DE-4111-A288-36E18AF55CF5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
32 | {6B27BDC9-49DE-4111-A288-36E18AF55CF5}.Debug|Any CPU.Build.0 = Debug|Any CPU
33 | {6B27BDC9-49DE-4111-A288-36E18AF55CF5}.Release|Any CPU.ActiveCfg = Release|Any CPU
34 | {6B27BDC9-49DE-4111-A288-36E18AF55CF5}.Release|Any CPU.Build.0 = Release|Any CPU
35 | {A3DE7767-954A-4F71-B796-918DFAAF5291}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
36 | {A3DE7767-954A-4F71-B796-918DFAAF5291}.Debug|Any CPU.Build.0 = Debug|Any CPU
37 | {A3DE7767-954A-4F71-B796-918DFAAF5291}.Release|Any CPU.ActiveCfg = Release|Any CPU
38 | {A3DE7767-954A-4F71-B796-918DFAAF5291}.Release|Any CPU.Build.0 = Release|Any CPU
39 | {94C2D338-5C1F-427C-8B6F-1BE5FE498F3D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
40 | {94C2D338-5C1F-427C-8B6F-1BE5FE498F3D}.Debug|Any CPU.Build.0 = Debug|Any CPU
41 | {94C2D338-5C1F-427C-8B6F-1BE5FE498F3D}.Release|Any CPU.ActiveCfg = Release|Any CPU
42 | {94C2D338-5C1F-427C-8B6F-1BE5FE498F3D}.Release|Any CPU.Build.0 = Release|Any CPU
43 | {0ACBF4A9-53A4-4B95-9369-8E4965B42903}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
44 | {0ACBF4A9-53A4-4B95-9369-8E4965B42903}.Debug|Any CPU.Build.0 = Debug|Any CPU
45 | {0ACBF4A9-53A4-4B95-9369-8E4965B42903}.Release|Any CPU.ActiveCfg = Release|Any CPU
46 | {0ACBF4A9-53A4-4B95-9369-8E4965B42903}.Release|Any CPU.Build.0 = Release|Any CPU
47 | {DD2C6178-CFA7-410D-B125-85C3FAE6EB5A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
48 | {DD2C6178-CFA7-410D-B125-85C3FAE6EB5A}.Debug|Any CPU.Build.0 = Debug|Any CPU
49 | {DD2C6178-CFA7-410D-B125-85C3FAE6EB5A}.Release|Any CPU.ActiveCfg = Release|Any CPU
50 | {DD2C6178-CFA7-410D-B125-85C3FAE6EB5A}.Release|Any CPU.Build.0 = Release|Any CPU
51 | {96D35BD9-F59E-49CF-8292-B06680D4850A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
52 | {96D35BD9-F59E-49CF-8292-B06680D4850A}.Debug|Any CPU.Build.0 = Debug|Any CPU
53 | {96D35BD9-F59E-49CF-8292-B06680D4850A}.Release|Any CPU.ActiveCfg = Release|Any CPU
54 | {96D35BD9-F59E-49CF-8292-B06680D4850A}.Release|Any CPU.Build.0 = Release|Any CPU
55 | EndGlobalSection
56 | GlobalSection(SolutionProperties) = preSolution
57 | HideSolutionNode = FALSE
58 | EndGlobalSection
59 | EndGlobal
60 |
--------------------------------------------------------------------------------
/DapperRepository/Attributes/MigrationAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection;
3 | using DapperRepository.Demo.Helpers;
4 | using DapperRepository.Helpers;
5 |
6 | namespace DapperRepository.Attributes
7 | {
8 | [AttributeUsage(AttributeTargets.All, AllowMultiple = false, Inherited = true)]
9 | [Serializable]
10 | public class MigrationAttribute : Attribute
11 | {
12 | private static Type _migrationType;
13 |
14 | private static void DoMigrate()
15 | {
16 | var migrationHelperType = typeof(MigrationHelper);
17 | var configureMethodInfo = migrationHelperType.GetMethod("Configure", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static);
18 | var configureWithType = configureMethodInfo.MakeGenericMethod(new[] { _migrationType });
19 |
20 | configureWithType.Invoke(migrationHelperType, new object[] { });
21 | }
22 |
23 | public MigrationAttribute(Type migrationType)
24 | {
25 | _migrationType = migrationType;
26 |
27 | DoMigrate();
28 | }
29 |
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/DapperRepository/DapperRepository.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {6B27BDC9-49DE-4111-A288-36E18AF55CF5}
8 | Library
9 | Properties
10 | DapperRepository
11 | DapperRepository
12 | v4.5
13 | 512
14 | ..\
15 | true
16 |
17 |
18 | true
19 | full
20 | false
21 | ..\Build\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 |
26 |
27 | pdbonly
28 | true
29 | bin\Release\
30 | TRACE
31 | prompt
32 | 4
33 |
34 |
35 |
36 | ..\packages\Npgsql.2.1.3\lib\net45\Mono.Security.dll
37 |
38 |
39 | ..\packages\Npgsql.2.1.3\lib\net45\Npgsql.dll
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 | This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
97 |
98 |
99 |
100 |
107 |
--------------------------------------------------------------------------------
/DapperRepository/Drapper/DapperExtensionsConfiguration.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Concurrent;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Reflection;
6 | using DapperRepository.Drapper.Mapper;
7 | using DapperRepository.Drapper.Sql;
8 |
9 | namespace DapperRepository.Drapper
10 | {
11 | public sealed class DapperExtensionsConfiguration : IDapperExtensionsConfiguration
12 | {
13 | private readonly ConcurrentDictionary _classMaps = new ConcurrentDictionary();
14 |
15 | public DapperExtensionsConfiguration(Type defaultMapper, IList mappingAssemblies, ISqlDialect sqlDialect)
16 | : this(new Dictionary(), defaultMapper, mappingAssemblies, sqlDialect)
17 | {
18 |
19 | }
20 |
21 | public DapperExtensionsConfiguration(IDictionary dataMapper, Type defaultMapper, IList mappingAssemblies, ISqlDialect sqlDialect)
22 | {
23 | DefaultMapper = defaultMapper;
24 | MappingAssemblies = mappingAssemblies ?? new List();
25 | Dialect = sqlDialect;
26 | DataMapper = dataMapper;
27 | }
28 |
29 | public IDictionary DataMapper { get; private set; }
30 | public Type DefaultMapper { get; private set; }
31 | public string ConnectionString { get; set; }
32 | public IList MappingAssemblies { get; private set; }
33 | public ISqlDialect Dialect { get; private set; }
34 |
35 | public IClassMapper GetMap(Type entityType)
36 | {
37 | IClassMapper map;
38 | if (!_classMaps.TryGetValue(entityType, out map))
39 | {
40 | Type mapType = GetMapType(entityType);
41 | if (mapType == null)
42 | {
43 | mapType = DefaultMapper.MakeGenericType(entityType);
44 | }
45 |
46 | map = Activator.CreateInstance(mapType) as IClassMapper;
47 | _classMaps[entityType] = map;
48 | }
49 |
50 | return map;
51 | }
52 |
53 | public IClassMapper GetMap() where T : class
54 | {
55 | return GetMap(typeof(T));
56 | }
57 |
58 | public void ClearCache()
59 | {
60 | _classMaps.Clear();
61 | }
62 |
63 | public Guid GetNextGuid()
64 | {
65 | byte[] b = Guid.NewGuid().ToByteArray();
66 | DateTime dateTime = new DateTime(1900, 1, 1);
67 | DateTime now = DateTime.Now;
68 | TimeSpan timeSpan = new TimeSpan(now.Ticks - dateTime.Ticks);
69 | TimeSpan timeOfDay = now.TimeOfDay;
70 | byte[] bytes1 = BitConverter.GetBytes(timeSpan.Days);
71 | byte[] bytes2 = BitConverter.GetBytes((long)(timeOfDay.TotalMilliseconds / 3.333333));
72 | Array.Reverse(bytes1);
73 | Array.Reverse(bytes2);
74 | Array.Copy(bytes1, bytes1.Length - 2, b, b.Length - 6, 2);
75 | Array.Copy(bytes2, bytes2.Length - 4, b, b.Length - 4, 4);
76 | return new Guid(b);
77 | }
78 |
79 | private Type GetMapType(Type entityType)
80 | {
81 | Func getType = a =>
82 | {
83 | Type[] types = a.GetTypes();
84 | return (from type in types
85 | let interfaceType = type.GetInterface(typeof(IClassMapper<>).FullName)
86 | where
87 | interfaceType != null &&
88 | interfaceType.GetGenericArguments()[0] == entityType
89 | select type).SingleOrDefault();
90 | };
91 |
92 | Type result = getType(entityType.Assembly);
93 | if (result != null)
94 | {
95 | return result;
96 | }
97 |
98 | foreach (var mappingAssembly in MappingAssemblies)
99 | {
100 | result = getType(mappingAssembly);
101 | if (result != null)
102 | {
103 | return result;
104 | }
105 | }
106 |
107 | return getType(entityType.Assembly);
108 | }
109 | }
110 | }
--------------------------------------------------------------------------------
/DapperRepository/Drapper/Database.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Data;
4 | using DapperRepository.Drapper.Mapper;
5 | using DapperRepository.Drapper.Sql;
6 |
7 | namespace DapperRepository.Drapper
8 | {
9 | public class Database : IDatabase
10 | {
11 | private readonly IDapperImplementor _dapper;
12 | private IDbTransaction _transaction;
13 |
14 | public Database(IDbConnection connection, ISqlGenerator sqlGenerator)
15 | {
16 | _dapper = new DapperImplementor(sqlGenerator);
17 | Connection = connection;
18 | }
19 |
20 | public bool HasActiveTransaction
21 | {
22 | get
23 | {
24 | return _transaction != null;
25 | }
26 | }
27 |
28 | public IDbConnection Connection { get; private set; }
29 |
30 | public void Dispose()
31 | {
32 | if (Connection.State != ConnectionState.Closed)
33 | {
34 | if (_transaction != null)
35 | {
36 | _transaction.Rollback();
37 | }
38 |
39 | Connection.Close();
40 | }
41 | }
42 |
43 | public void BeginTransaction(IsolationLevel isolationLevel = IsolationLevel.ReadCommitted)
44 | {
45 | _transaction = Connection.BeginTransaction(isolationLevel);
46 | }
47 |
48 | public void Commit()
49 | {
50 | _transaction.Commit();
51 | _transaction = null;
52 | }
53 |
54 | public void Rollback()
55 | {
56 | _transaction.Rollback();
57 | _transaction = null;
58 | }
59 |
60 | public void Open()
61 | {
62 | if (Connection.State != ConnectionState.Open)
63 | {
64 | Connection.Open();
65 | }
66 | }
67 |
68 | public void Close()
69 | {
70 | if (Connection.State != ConnectionState.Closed)
71 | {
72 | Connection.Close();
73 | }
74 | }
75 |
76 | public void RunInTransaction(Action action)
77 | {
78 | BeginTransaction();
79 | try
80 | {
81 | action();
82 | Commit();
83 | }
84 | catch (Exception ex)
85 | {
86 | if (HasActiveTransaction)
87 | {
88 | Rollback();
89 | }
90 |
91 | throw ex;
92 | }
93 | }
94 |
95 | public T RunInTransaction(Func func)
96 | {
97 | BeginTransaction();
98 | try
99 | {
100 | T result = func();
101 | Commit();
102 | return result;
103 | }
104 | catch (Exception ex)
105 | {
106 | if (HasActiveTransaction)
107 | {
108 | Rollback();
109 | }
110 |
111 | throw ex;
112 | }
113 | }
114 |
115 | public T Get(dynamic id, IDbTransaction transaction, int? commandTimeout) where T : class
116 | {
117 | return (T)_dapper.Get(Connection, id, transaction, commandTimeout);
118 | }
119 |
120 | public T Get(dynamic id, int? commandTimeout) where T : class
121 | {
122 | return (T)_dapper.Get(Connection, id, _transaction, commandTimeout);
123 | }
124 |
125 | public bool Exists(int? commandTimeout = null) where T : class
126 | {
127 | return _dapper.Exists(Connection, commandTimeout);
128 | }
129 |
130 | public void CreateDatabaseIfNotExists(string connectionString, int? commandTimeout = null)
131 | {
132 | _dapper.CreateDatabaseIfNotExists(Connection,connectionString, commandTimeout);
133 | }
134 |
135 | public void CreateSchemaIfNotExists(int? commandTimeout = null) where T : class
136 | {
137 | _dapper.CreateSchemaIfNotExists(Connection, commandTimeout);
138 | }
139 |
140 | public void Drop(int? commandTimeout = null) where T : class
141 | {
142 | _dapper.Drop(Connection, commandTimeout);
143 | }
144 |
145 | public void Create(int? commandTimeout = null) where T : class
146 | {
147 | _dapper.Create(Connection, commandTimeout);
148 | }
149 |
150 | public void Insert(IEnumerable entities, IDbTransaction transaction, int? commandTimeout) where T : class
151 | {
152 | _dapper.Insert(Connection, entities, transaction, commandTimeout);
153 | }
154 |
155 | public void Insert(IEnumerable entities, int? commandTimeout) where T : class
156 | {
157 | _dapper.Insert(Connection, entities, _transaction, commandTimeout);
158 | }
159 |
160 | public dynamic Insert(T entity, IDbTransaction transaction, int? commandTimeout) where T : class
161 | {
162 | return _dapper.Insert(Connection, entity, transaction, commandTimeout);
163 | }
164 |
165 | public dynamic Insert(T entity, int? commandTimeout) where T : class
166 | {
167 | return _dapper.Insert(Connection, entity, _transaction, commandTimeout);
168 | }
169 |
170 | public bool Update(T entity, IDbTransaction transaction, int? commandTimeout) where T : class
171 | {
172 | return _dapper.Update(Connection, entity, transaction, commandTimeout);
173 | }
174 |
175 | public bool Update(T entity, int? commandTimeout) where T : class
176 | {
177 | return _dapper.Update(Connection, entity, _transaction, commandTimeout);
178 | }
179 |
180 | public bool Delete(T entity, IDbTransaction transaction, int? commandTimeout) where T : class
181 | {
182 | return _dapper.Delete(Connection, entity, transaction, commandTimeout);
183 | }
184 |
185 | public bool Delete(T entity, int? commandTimeout) where T : class
186 | {
187 | return _dapper.Delete(Connection, entity, _transaction, commandTimeout);
188 | }
189 |
190 | public bool Delete(object predicate, IDbTransaction transaction, int? commandTimeout) where T : class
191 | {
192 | return _dapper.Delete(Connection, predicate, transaction, commandTimeout);
193 | }
194 |
195 | public bool Delete(object predicate, int? commandTimeout) where T : class
196 | {
197 | return _dapper.Delete(Connection, predicate, _transaction, commandTimeout);
198 | }
199 |
200 | public IEnumerable GetList(object predicate, IList sort, IDbTransaction transaction, int? commandTimeout, bool buffered) where T : class
201 | {
202 | return _dapper.GetList(Connection, predicate, sort, transaction, commandTimeout, buffered);
203 | }
204 |
205 | public IEnumerable GetList(object predicate, IList sort, int? commandTimeout, bool buffered) where T : class
206 | {
207 | return _dapper.GetList(Connection, predicate, sort, _transaction, commandTimeout, buffered);
208 | }
209 |
210 | public IEnumerable GetPage(object predicate, IList sort, int page, int resultsPerPage, IDbTransaction transaction, int? commandTimeout, bool buffered) where T : class
211 | {
212 | return _dapper.GetPage(Connection, predicate, sort, page, resultsPerPage, transaction, commandTimeout, buffered);
213 | }
214 |
215 | public IEnumerable GetPage(object predicate, IList sort, int page, int resultsPerPage, int? commandTimeout, bool buffered) where T : class
216 | {
217 | return _dapper.GetPage(Connection, predicate, sort, page, resultsPerPage, _transaction, commandTimeout, buffered);
218 | }
219 |
220 | public IEnumerable GetSet(object predicate, IList sort, int firstResult, int maxResults, IDbTransaction transaction, int? commandTimeout, bool buffered) where T : class
221 | {
222 | return _dapper.GetSet(Connection, predicate, sort, firstResult, maxResults, transaction, commandTimeout, buffered);
223 | }
224 |
225 | public IEnumerable GetSet(object predicate, IList sort, int firstResult, int maxResults, int? commandTimeout, bool buffered) where T : class
226 | {
227 | return _dapper.GetSet(Connection, predicate, sort, firstResult, maxResults, _transaction, commandTimeout, buffered);
228 | }
229 |
230 | public int Count(object predicate, IDbTransaction transaction, int? commandTimeout) where T : class
231 | {
232 | return _dapper.Count(Connection, predicate, transaction, commandTimeout);
233 | }
234 |
235 | public int Count(object predicate, int? commandTimeout) where T : class
236 | {
237 | return _dapper.Count(Connection, predicate, _transaction, commandTimeout);
238 | }
239 |
240 | public IMultipleResultReader GetMultiple(GetMultiplePredicate predicate, IDbTransaction transaction, int? commandTimeout)
241 | {
242 | return _dapper.GetMultiple(Connection, predicate, transaction, commandTimeout);
243 | }
244 |
245 | public IMultipleResultReader GetMultiple(GetMultiplePredicate predicate, int? commandTimeout)
246 | {
247 | return _dapper.GetMultiple(Connection, predicate, _transaction, commandTimeout);
248 | }
249 |
250 | public void ClearCache()
251 | {
252 | _dapper.SqlGenerator.Configuration.ClearCache();
253 | }
254 |
255 | public Guid GetNextGuid()
256 | {
257 | return _dapper.SqlGenerator.Configuration.GetNextGuid();
258 | }
259 |
260 | public IClassMapper GetMap() where T : class
261 | {
262 | return _dapper.SqlGenerator.Configuration.GetMap();
263 | }
264 | }
265 | }
--------------------------------------------------------------------------------
/DapperRepository/Drapper/GetMultiplePredicate.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace DapperRepository.Drapper
5 | {
6 | public class GetMultiplePredicate
7 | {
8 | private readonly List _items;
9 |
10 | public GetMultiplePredicate()
11 | {
12 | _items = new List();
13 | }
14 |
15 | public IEnumerable Items
16 | {
17 | get { return _items.AsReadOnly(); }
18 | }
19 |
20 | public void Add(IPredicate predicate, IList sort = null) where T : class
21 | {
22 | _items.Add(new GetMultiplePredicateItem
23 | {
24 | Value = predicate,
25 | Type = typeof(T),
26 | Sort = sort
27 | });
28 | }
29 |
30 | public void Add(object id) where T : class
31 | {
32 | _items.Add(new GetMultiplePredicateItem
33 | {
34 | Value = id,
35 | Type = typeof (T)
36 | });
37 | }
38 |
39 | public class GetMultiplePredicateItem
40 | {
41 | public object Value { get; set; }
42 | public Type Type { get; set; }
43 | public IList Sort { get; set; }
44 | }
45 | }
46 | }
--------------------------------------------------------------------------------
/DapperRepository/Drapper/GetMultipleResult.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace DapperRepository.Drapper
4 | {
5 | public class GridReaderResultReader : IMultipleResultReader
6 | {
7 | private readonly SqlMapper.GridReader _reader;
8 |
9 | public GridReaderResultReader(SqlMapper.GridReader reader)
10 | {
11 | _reader = reader;
12 | }
13 |
14 | public IEnumerable Read()
15 | {
16 | return _reader.Read();
17 | }
18 | }
19 |
20 | public class SequenceReaderResultReader : IMultipleResultReader
21 | {
22 | private readonly Queue _items;
23 |
24 | public SequenceReaderResultReader(IEnumerable items)
25 | {
26 | _items = new Queue(items);
27 | }
28 |
29 | public IEnumerable Read()
30 | {
31 | SqlMapper.GridReader reader = _items.Dequeue();
32 | return reader.Read();
33 | }
34 | }
35 | }
--------------------------------------------------------------------------------
/DapperRepository/Drapper/IDapperExtensionsConfiguration.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Reflection;
4 | using DapperRepository.Drapper.Mapper;
5 | using DapperRepository.Drapper.Sql;
6 |
7 | namespace DapperRepository.Drapper
8 | {
9 | public interface IDapperExtensionsConfiguration
10 | {
11 | IDictionary DataMapper { get; }
12 | Type DefaultMapper { get; }
13 | String ConnectionString { get; set; }
14 | IList MappingAssemblies { get; }
15 | ISqlDialect Dialect { get; }
16 | IClassMapper GetMap(Type entityType);
17 | IClassMapper GetMap() where T : class;
18 | void ClearCache();
19 | Guid GetNextGuid();
20 | }
21 | }
--------------------------------------------------------------------------------
/DapperRepository/Drapper/IDapperImplementor.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Data;
3 | using DapperRepository.Drapper.Sql;
4 |
5 | namespace DapperRepository.Drapper
6 | {
7 | public interface IDapperImplementor
8 | {
9 | ISqlGenerator SqlGenerator { get; }
10 | T Get(IDbConnection connection, dynamic id, IDbTransaction transaction, int? commandTimeout) where T : class;
11 | bool Exists(IDbConnection connection, int? commandTimeout) where T : class;
12 | void Create(IDbConnection connection, int? commandTimeout) where T : class;
13 | void CreateSchemaIfNotExists(IDbConnection connection, int? commandTimeout) where T : class;
14 | void CreateDatabaseIfNotExists(IDbConnection connection,string connectionString, int? commandTimeout);
15 | void Drop(IDbConnection connection, int? commandTimeout) where T : class;
16 | void Insert(IDbConnection connection, IEnumerable entities, IDbTransaction transaction, int? commandTimeout) where T : class;
17 | dynamic Insert(IDbConnection connection, T entity, IDbTransaction transaction, int? commandTimeout) where T : class;
18 | bool Update(IDbConnection connection, T entity, IDbTransaction transaction, int? commandTimeout) where T : class;
19 | bool Delete(IDbConnection connection, T entity, IDbTransaction transaction, int? commandTimeout) where T : class;
20 | bool Delete(IDbConnection connection, object predicate, IDbTransaction transaction, int? commandTimeout) where T : class;
21 | IEnumerable GetList(IDbConnection connection, object predicate, IList sort, IDbTransaction transaction, int? commandTimeout, bool buffered) where T : class;
22 | IEnumerable GetPage(IDbConnection connection, object predicate, IList sort, int page, int resultsPerPage, IDbTransaction transaction, int? commandTimeout, bool buffered) where T : class;
23 | IEnumerable GetSet(IDbConnection connection, object predicate, IList sort, int firstResult, int maxResults, IDbTransaction transaction, int? commandTimeout, bool buffered) where T : class;
24 | int Count(IDbConnection connection, object predicate, IDbTransaction transaction, int? commandTimeout) where T : class;
25 | IMultipleResultReader GetMultiple(IDbConnection connection, GetMultiplePredicate predicate, IDbTransaction transaction, int? commandTimeout);
26 | }
27 | }
--------------------------------------------------------------------------------
/DapperRepository/Drapper/IDatabase.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Data;
4 | using DapperRepository.Drapper.Mapper;
5 |
6 | namespace DapperRepository.Drapper
7 | {
8 | public interface IDatabase : IDisposable
9 | {
10 | bool HasActiveTransaction { get; }
11 | IDbConnection Connection { get; }
12 | void BeginTransaction(IsolationLevel isolationLevel = IsolationLevel.ReadCommitted);
13 | void Commit();
14 | void Rollback();
15 | void Open();
16 | void Close();
17 | void RunInTransaction(Action action);
18 | T RunInTransaction(Func func);
19 | T Get(dynamic id, IDbTransaction transaction, int? commandTimeout = null) where T : class;
20 | T Get(dynamic id, int? commandTimeout = null) where T : class;
21 | bool Exists(int? commandTimeout = null) where T : class;
22 | void CreateDatabaseIfNotExists(string connectionString,int? commandTimeout = null);
23 | void CreateSchemaIfNotExists(int? commandTimeout = null) where T : class;
24 | void Drop(int? commandTimeout = null) where T : class;
25 | void Create(int? commandTimeout = null) where T : class;
26 | void Insert(IEnumerable entities, IDbTransaction transaction, int? commandTimeout = null) where T : class;
27 | void Insert(IEnumerable entities, int? commandTimeout = null) where T : class;
28 | dynamic Insert(T entity, IDbTransaction transaction, int? commandTimeout = null) where T : class;
29 | dynamic Insert(T entity, int? commandTimeout = null) where T : class;
30 | bool Update(T entity, IDbTransaction transaction, int? commandTimeout = null) where T : class;
31 | bool Update(T entity, int? commandTimeout = null) where T : class;
32 | bool Delete(T entity, IDbTransaction transaction, int? commandTimeout = null) where T : class;
33 | bool Delete(T entity, int? commandTimeout = null) where T : class;
34 | bool Delete(object predicate, IDbTransaction transaction, int? commandTimeout = null) where T : class;
35 | bool Delete(object predicate, int? commandTimeout = null) where T : class;
36 | IEnumerable GetList(object predicate, IList sort, IDbTransaction transaction, int? commandTimeout = null, bool buffered = true) where T : class;
37 | IEnumerable GetList(object predicate = null, IList sort = null, int? commandTimeout = null, bool buffered = true) where T : class;
38 | IEnumerable GetPage(object predicate, IList sort, int page, int resultsPerPage, IDbTransaction transaction, int? commandTimeout = null, bool buffered = true) where T : class;
39 | IEnumerable GetPage(object predicate, IList sort, int page, int resultsPerPage, int? commandTimeout = null, bool buffered = true) where T : class;
40 | IEnumerable GetSet(object predicate, IList sort, int firstResult, int maxResults, IDbTransaction transaction, int? commandTimeout, bool buffered) where T : class;
41 | IEnumerable GetSet(object predicate, IList sort, int firstResult, int maxResults, int? commandTimeout, bool buffered) where T : class;
42 | int Count(object predicate, IDbTransaction transaction, int? commandTimeout = null) where T : class;
43 | int Count(object predicate, int? commandTimeout = null) where T : class;
44 | IMultipleResultReader GetMultiple(GetMultiplePredicate predicate, IDbTransaction transaction, int? commandTimeout = null);
45 | IMultipleResultReader GetMultiple(GetMultiplePredicate predicate, int? commandTimeout = null);
46 | void ClearCache();
47 | Guid GetNextGuid();
48 | IClassMapper GetMap() where T : class;
49 | }
50 | }
--------------------------------------------------------------------------------
/DapperRepository/Drapper/IMultipleResultReader.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace DapperRepository.Drapper
4 | {
5 | public interface IMultipleResultReader
6 | {
7 | IEnumerable Read();
8 | }
9 | }
--------------------------------------------------------------------------------
/DapperRepository/Drapper/Mapper/AutoClassMapper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace DapperRepository.Drapper.Mapper
4 | {
5 | ///
6 | /// Automatically maps an entity to a table using a combination of reflection and naming conventions for keys.
7 | ///
8 | public class AutoClassMapper : ClassMapper where T : class
9 | {
10 | public AutoClassMapper()
11 | {
12 | Type type = typeof(T);
13 | Table(type.Name);
14 | AutoMap();
15 | }
16 | }
17 | }
--------------------------------------------------------------------------------
/DapperRepository/Drapper/Mapper/ClassMapper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Globalization;
4 | using System.Linq;
5 | using System.Linq.Expressions;
6 | using System.Numerics;
7 | using System.Reflection;
8 |
9 | namespace DapperRepository.Drapper.Mapper
10 | {
11 | ///
12 | /// Maps an entity to a table through a collection of property maps.
13 | ///
14 | public class ClassMapper : IClassMapper where T : class
15 | {
16 | public IDictionary DataMapper { get; private set; }
17 |
18 | ///
19 | /// Gets or sets the schema to use when referring to the corresponding table name in the database.
20 | ///
21 | public string SchemaName { get; protected set; }
22 |
23 | ///
24 | /// Gets or sets the table to use in the database.
25 | ///
26 | public string TableName { get; protected set; }
27 |
28 | ///
29 | /// A collection of properties that will map to columns in the database table.
30 | ///
31 | public IList Properties { get; private set; }
32 |
33 | public Type EntityType
34 | {
35 | get { return typeof(T); }
36 | }
37 |
38 | public ClassMapper()
39 | {
40 | PropertyTypeKeyTypeMapping = new Dictionary
41 | {
42 | {typeof (byte), KeyType.Identity},
43 | {typeof (byte?), KeyType.Identity},
44 | {typeof (sbyte), KeyType.Identity},
45 | {typeof (sbyte?), KeyType.Identity},
46 | {typeof (short), KeyType.Identity},
47 | {typeof (short?), KeyType.Identity},
48 | {typeof (ushort), KeyType.Identity},
49 | {typeof (ushort?), KeyType.Identity},
50 | {typeof (int), KeyType.Identity},
51 | {typeof (int?), KeyType.Identity},
52 | {typeof (uint), KeyType.Identity},
53 | {typeof (uint?), KeyType.Identity},
54 | {typeof (long), KeyType.Identity},
55 | {typeof (long?), KeyType.Identity},
56 | {typeof (ulong), KeyType.Identity},
57 | {typeof (ulong?), KeyType.Identity},
58 | {typeof (BigInteger), KeyType.Identity},
59 | {typeof (BigInteger?), KeyType.Identity},
60 | {typeof (Guid), KeyType.Guid},
61 | {typeof (Guid?), KeyType.Guid},
62 | };
63 |
64 | Properties = new List();
65 | Table(typeof(T).Name);
66 | }
67 |
68 | protected Dictionary PropertyTypeKeyTypeMapping { get; private set; }
69 |
70 | public virtual void Schema(string schemaName)
71 | {
72 | SchemaName = schemaName;
73 | }
74 |
75 | public virtual void Table(string tableName)
76 | {
77 | TableName = tableName;
78 | }
79 |
80 | protected virtual void AutoMap()
81 | {
82 | AutoMap(null);
83 | }
84 |
85 | protected virtual void AutoMap(Func canMap)
86 | {
87 | Type type = typeof(T);
88 | bool hasDefinedKey = Properties.Any(p => p.KeyType != KeyType.NotAKey);
89 | PropertyMap keyMap = null;
90 | foreach (PropertyInfo propertyInfo in type.GetProperties())
91 | {
92 | if (!Properties.Any(p => p.Name.Equals(propertyInfo.Name, StringComparison.InvariantCultureIgnoreCase)))
93 | {
94 | if ((canMap == null || canMap(type, propertyInfo)))
95 | {
96 | PropertyMap map = Map(propertyInfo);
97 | if (!hasDefinedKey)
98 | {
99 | if (string.Equals(map.PropertyInfo.Name, "id", StringComparison.InvariantCultureIgnoreCase))
100 | {
101 | keyMap = map;
102 | }
103 |
104 | if (keyMap == null && map.PropertyInfo.Name.EndsWith("id", true, CultureInfo.InvariantCulture))
105 | {
106 | keyMap = map;
107 | }
108 | }
109 | }
110 | }
111 | }
112 |
113 | if (keyMap == null)
114 | return;
115 |
116 | KeyType value;
117 |
118 | keyMap.Key(PropertyTypeKeyTypeMapping.TryGetValue(keyMap.PropertyInfo.PropertyType, out value)
119 | ? value
120 | : KeyType.Assigned);
121 | }
122 |
123 | ///
124 | /// Fluently, maps an entity property to a column
125 | ///
126 | protected PropertyMap Map(Expression> expression)
127 | {
128 | PropertyInfo propertyInfo = ReflectionHelper.GetProperty(expression) as PropertyInfo;
129 | return Map(propertyInfo);
130 | }
131 |
132 | ///
133 | /// Fluently, maps an entity property to a column
134 | ///
135 | protected PropertyMap Map(PropertyInfo propertyInfo)
136 | {
137 | PropertyMap result = new PropertyMap(propertyInfo);
138 | this.GuardForDuplicatePropertyMap(result);
139 | Properties.Add(result);
140 | return result;
141 | }
142 |
143 | private void GuardForDuplicatePropertyMap(PropertyMap result)
144 | {
145 | if (Properties.Any(p => p.Name.Equals(result.Name)))
146 | {
147 | throw new ArgumentException(string.Format("Duplicate mapping for property {0} detected.", result.Name));
148 | }
149 | }
150 | }
151 | }
--------------------------------------------------------------------------------
/DapperRepository/Drapper/Mapper/IClassMapper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace DapperRepository.Drapper.Mapper
5 | {
6 | public interface IClassMapper : IClassMapper where T : class
7 | {
8 | }
9 |
10 | public interface IClassMapper
11 | {
12 | string SchemaName { get; }
13 | string TableName { get; }
14 | IList Properties { get; }
15 | Type EntityType { get; }
16 | }
17 | }
--------------------------------------------------------------------------------
/DapperRepository/Drapper/Mapper/IPropertyMap.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 |
3 | namespace DapperRepository.Drapper.Mapper
4 | {
5 | ///
6 | /// Maps an entity property to its corresponding column in the database.
7 | ///
8 | public interface IPropertyMap
9 | {
10 | string Name { get; }
11 | string ColumnName { get; }
12 | bool Ignored { get; }
13 | bool IsReadOnly { get; }
14 | KeyType KeyType { get; }
15 | PropertyInfo PropertyInfo { get; }
16 | }
17 | }
--------------------------------------------------------------------------------
/DapperRepository/Drapper/Mapper/PropertyMap.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection;
3 |
4 | namespace DapperRepository.Drapper.Mapper
5 | {
6 | ///
7 | /// Maps an entity property to its corresponding column in the database.
8 | ///
9 | public class PropertyMap : IPropertyMap
10 | {
11 | public PropertyMap(PropertyInfo propertyInfo)
12 | {
13 | PropertyInfo = propertyInfo;
14 | ColumnName = PropertyInfo.Name;
15 | }
16 |
17 | ///
18 | /// Gets the name of the property by using the specified propertyInfo.
19 | ///
20 | public string Name
21 | {
22 | get { return PropertyInfo.Name; }
23 | }
24 |
25 | ///
26 | /// Gets the column name for the current property.
27 | ///
28 | public string ColumnName { get; private set; }
29 |
30 | ///
31 | /// Gets the key type for the current property.
32 | ///
33 | public KeyType KeyType { get; private set; }
34 |
35 | ///
36 | /// Gets the ignore status of the current property. If ignored, the current property will not be included in queries.
37 | ///
38 | public bool Ignored { get; private set; }
39 |
40 | ///
41 | /// Gets the read-only status of the current property. If read-only, the current property will not be included in INSERT and UPDATE queries.
42 | ///
43 | public bool IsReadOnly { get; private set; }
44 |
45 | ///
46 | /// Gets the property info for the current property.
47 | ///
48 | public PropertyInfo PropertyInfo { get; private set; }
49 |
50 | ///
51 | /// Fluently sets the column name for the property.
52 | ///
53 | /// The column name as it exists in the database.
54 | public PropertyMap Column(string columnName)
55 | {
56 | ColumnName = columnName;
57 | return this;
58 | }
59 |
60 | ///
61 | /// Fluently sets the key type of the property.
62 | ///
63 | /// The column name as it exists in the database.
64 | public PropertyMap Key(KeyType keyType)
65 | {
66 | if (Ignored)
67 | {
68 | throw new ArgumentException(string.Format("'{0}' is ignored and cannot be made a key field. ", Name));
69 | }
70 |
71 | if (Ignored)
72 | {
73 | throw new ArgumentException(string.Format("'{0}' is readonly and cannot be made a key field. ", Name));
74 | }
75 |
76 | KeyType = keyType;
77 | return this;
78 | }
79 |
80 | ///
81 | /// Fluently sets the ignore status of the property.
82 | ///
83 | public PropertyMap Ignore()
84 | {
85 | if (KeyType != KeyType.NotAKey)
86 | {
87 | throw new ArgumentException(string.Format("'{0}' is a key field and cannot be ignored.", Name));
88 | }
89 |
90 | Ignored = true;
91 | return this;
92 | }
93 |
94 | ///
95 | /// Fluently sets the read-only status of the property.
96 | ///
97 | public PropertyMap ReadOnly()
98 | {
99 | if (KeyType != KeyType.NotAKey)
100 | {
101 | throw new ArgumentException(string.Format("'{0}' is a key field and cannot be marked readonly.", Name));
102 | }
103 |
104 | IsReadOnly = true;
105 | return this;
106 | }
107 | }
108 |
109 | ///
110 | /// Used by ClassMapper to determine which entity property represents the key.
111 | ///
112 | public enum KeyType
113 | {
114 | ///
115 | /// The property is not a key and is not automatically managed.
116 | ///
117 | NotAKey,
118 |
119 | ///
120 | /// The property is an integery-based identity generated from the database.
121 | ///
122 | Identity,
123 |
124 | ///
125 | /// The property is a Guid identity which is automatically managed.
126 | ///
127 | Guid,
128 |
129 | ///
130 | /// The property is a key that is not automatically managed.
131 | ///
132 | Assigned
133 | }
134 | }
--------------------------------------------------------------------------------
/DapperRepository/Drapper/ReflectionHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Linq.Expressions;
5 | using System.Reflection;
6 | using System.Text;
7 |
8 | namespace DapperRepository.Drapper
9 | {
10 | public static class ReflectionHelper
11 | {
12 | private static readonly List _simpleTypes = new List
13 | {
14 | typeof(byte),
15 | typeof(sbyte),
16 | typeof(short),
17 | typeof(ushort),
18 | typeof(int),
19 | typeof(uint),
20 | typeof(long),
21 | typeof(ulong),
22 | typeof(float),
23 | typeof(double),
24 | typeof(decimal),
25 | typeof(bool),
26 | typeof(string),
27 | typeof(char),
28 | typeof(Guid),
29 | typeof(DateTime),
30 | typeof(DateTimeOffset),
31 | typeof(byte[])
32 | };
33 |
34 | public static MemberInfo GetProperty(LambdaExpression lambda)
35 | {
36 | Expression expr = lambda;
37 | for (; ; )
38 | {
39 | switch (expr.NodeType)
40 | {
41 | case ExpressionType.Lambda:
42 | expr = ((LambdaExpression)expr).Body;
43 | break;
44 | case ExpressionType.Convert:
45 | expr = ((UnaryExpression)expr).Operand;
46 | break;
47 | case ExpressionType.MemberAccess:
48 | MemberExpression memberExpression = (MemberExpression)expr;
49 | MemberInfo mi = memberExpression.Member;
50 | return mi;
51 | default:
52 | return null;
53 | }
54 | }
55 | }
56 |
57 | public static IDictionary GetObjectValues(object obj)
58 | {
59 | IDictionary result = new Dictionary();
60 | if (obj == null)
61 | {
62 | return result;
63 | }
64 |
65 |
66 | foreach (var propertyInfo in obj.GetType().GetProperties())
67 | {
68 | string name = propertyInfo.Name;
69 | object value = propertyInfo.GetValue(obj, null);
70 | result[name] = value;
71 | }
72 |
73 | return result;
74 | }
75 |
76 | public static string AppendStrings(this IEnumerable list, string seperator = ", ")
77 | {
78 | return list.Aggregate(
79 | new StringBuilder(),
80 | (sb, s) => (sb.Length == 0 ? sb : sb.Append(seperator)).Append(s),
81 | sb => sb.ToString());
82 | }
83 |
84 | public static bool IsSimpleType(Type type)
85 | {
86 | Type actualType = type;
87 | if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>))
88 | {
89 | actualType = type.GetGenericArguments()[0];
90 | }
91 |
92 | return _simpleTypes.Contains(actualType);
93 | }
94 |
95 | public static string GetParameterName(this IDictionary parameters, string parameterName, char parameterPrefix)
96 | {
97 | return string.Format("{0}{1}_{2}", parameterPrefix, parameterName, parameters.Count);
98 | }
99 |
100 | public static string SetParameterName(this IDictionary parameters, string parameterName, object value, char parameterPrefix)
101 | {
102 | string name = parameters.GetParameterName(parameterName, parameterPrefix);
103 | parameters.Add(name, value);
104 | return name;
105 | }
106 | }
107 | }
--------------------------------------------------------------------------------
/DapperRepository/Drapper/Resources/Readme.txt:
--------------------------------------------------------------------------------
1 | ----------------------------------------------------------------------
2 | Simple SQL object mapper for ADO.NET - https://code.google.com/p/dapper-dot-net/
3 |
4 | Latest modified by Elyor Latipov - mailto:elyor@outlook.com
5 |
6 | I fix to this issue list:
7 |
8 | - Type Mapping
9 | - Drop table
10 | - Exists table
11 | - Create table
12 | - Create Schema
13 | - Create Database
14 | - PK , UQ , NN impleted to every dialects
15 |
16 | ---------------------------------------------------------------
17 | License - http://www.apache.org/licenses/LICENSE-2.0
--------------------------------------------------------------------------------
/DapperRepository/Drapper/Sql/ISqlDialect.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace DapperRepository.Drapper.Sql
4 | {
5 | public interface ISqlDialect
6 | {
7 | char OpenQuote { get; }
8 | char CloseQuote { get; }
9 | string BatchSeperator { get; }
10 | bool SupportsMultipleStatements { get; }
11 | char ParameterPrefix { get; }
12 | string EmptyExpression { get; }
13 | string GetTableName(string schemaName, string tableName, string alias);
14 | string GetColumnName(string prefix, string columnName, string alias);
15 | string GetIdentitySql(string tableName);
16 | string GetPagingSql(string sql, int page, int resultsPerPage, IDictionary parameters);
17 | string GetSetSql(string sql, int firstResult, int maxResults, IDictionary parameters);
18 | bool IsQuoted(string value);
19 | string QuoteString(string value);
20 | string UnQuoteString(string value);
21 | }
22 | }
--------------------------------------------------------------------------------
/DapperRepository/Drapper/Sql/ISqlGenerator.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using DapperRepository.Drapper.Mapper;
3 |
4 | namespace DapperRepository.Drapper.Sql
5 | {
6 | public interface ISqlGenerator
7 | {
8 | IDapperExtensionsConfiguration Configuration { get; }
9 | string Select(IClassMapper classMap, IPredicate predicate, IList sort, IDictionary parameters);
10 | string SelectPaged(IClassMapper classMap, IPredicate predicate, IList sort, int page, int resultsPerPage, IDictionary parameters);
11 | string SelectSet(IClassMapper classMap, IPredicate predicate, IList sort, int firstResult, int maxResults, IDictionary parameters);
12 | string Count(IClassMapper classMap, IPredicate predicate, IDictionary parameters);
13 | string ConnectionString();
14 | string Database();
15 | string Schema(IClassMapper classMapper);
16 | string Create(IClassMapper classMap);
17 | string Exists(IClassMapper classMap);
18 | string Drop(IClassMapper classMap);
19 | string Insert(IClassMapper classMap);
20 | string Update(IClassMapper classMap, IPredicate predicate, IDictionary parameters);
21 | string Delete(IClassMapper classMap, IPredicate predicate, IDictionary parameters);
22 |
23 | string IdentitySql(IClassMapper classMap);
24 | string GetTableName(IClassMapper map);
25 | string GetColumnName(IClassMapper map, IPropertyMap property, bool includeAlias);
26 | string GetColumnName(IClassMapper map, string propertyName, bool includeAlias);
27 | bool SupportsMultipleStatements();
28 | string BuildSelectColumns(IClassMapper classMap);
29 | }
30 | }
--------------------------------------------------------------------------------
/DapperRepository/Drapper/Sql/SqlDialectBase.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace DapperRepository.Drapper.Sql
7 | {
8 | public abstract class SqlDialectBase : ISqlDialect
9 | {
10 | public virtual char OpenQuote
11 | {
12 | get { return '"'; }
13 | }
14 |
15 | public virtual char CloseQuote
16 | {
17 | get { return '"'; }
18 | }
19 |
20 | public virtual string BatchSeperator
21 | {
22 | get { return ";" + Environment.NewLine; }
23 | }
24 |
25 | public virtual bool SupportsMultipleStatements
26 | {
27 | get { return true; }
28 | }
29 |
30 | public virtual char ParameterPrefix
31 | {
32 | get
33 | {
34 | return '@';
35 | }
36 | }
37 |
38 | public string EmptyExpression
39 | {
40 | get
41 | {
42 | return "1=1";
43 | }
44 | }
45 |
46 | public virtual string GetTableName(string schemaName, string tableName, string alias)
47 | {
48 | if (string.IsNullOrWhiteSpace(tableName))
49 | {
50 | throw new ArgumentNullException("TableName", "tableName cannot be null or empty.");
51 | }
52 |
53 | StringBuilder result = new StringBuilder();
54 | if (!string.IsNullOrWhiteSpace(schemaName))
55 | {
56 | result.AppendFormat(QuoteString(schemaName) + ".");
57 | }
58 |
59 | result.AppendFormat(QuoteString(tableName));
60 |
61 | if (!string.IsNullOrWhiteSpace(alias))
62 | {
63 | result.AppendFormat(" AS {0}", QuoteString(alias));
64 | }
65 | return result.ToString();
66 | }
67 |
68 | public virtual string GetColumnName(string prefix, string columnName, string alias)
69 | {
70 | if (string.IsNullOrWhiteSpace(columnName))
71 | {
72 | throw new ArgumentNullException("ColumnName", "columnName cannot be null or empty.");
73 | }
74 |
75 | StringBuilder result = new StringBuilder();
76 | if (!string.IsNullOrWhiteSpace(prefix))
77 | {
78 | result.AppendFormat(QuoteString(prefix) + ".");
79 | }
80 |
81 | result.AppendFormat(QuoteString(columnName));
82 |
83 | if (!string.IsNullOrWhiteSpace(alias))
84 | {
85 | result.AppendFormat(" AS {0}", QuoteString(alias));
86 | }
87 |
88 | return result.ToString();
89 | }
90 |
91 | public abstract string GetIdentitySql(string tableName);
92 | public abstract string GetPagingSql(string sql, int page, int resultsPerPage, IDictionary parameters);
93 | public abstract string GetSetSql(string sql, int firstResult, int maxResults, IDictionary parameters);
94 |
95 | public virtual bool IsQuoted(string value)
96 | {
97 | if (value.Trim()[0] == OpenQuote)
98 | {
99 | return value.Trim().Last() == CloseQuote;
100 | }
101 |
102 | return false;
103 | }
104 |
105 | public virtual string QuoteString(string value)
106 | {
107 | return IsQuoted(value) ? value : string.Format("{0}{1}{2}", OpenQuote, value.Trim(), CloseQuote);
108 | }
109 |
110 | public virtual string UnQuoteString(string value)
111 | {
112 | return IsQuoted(value) ? value.Substring(1, value.Length - 2) : value;
113 | }
114 | }
115 | }
--------------------------------------------------------------------------------
/DapperRepository/Drapper/Sql/SqlGenerator.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using DapperRepository.Drapper.Mapper;
6 |
7 | namespace DapperRepository.Drapper.Sql
8 | {
9 | public class SqlGenerator : ISqlGenerator
10 | {
11 | public SqlGenerator(IDapperExtensionsConfiguration configuration)
12 | {
13 | Configuration = configuration;
14 | }
15 |
16 | public IDapperExtensionsConfiguration Configuration { get; private set; }
17 |
18 | public virtual string Select(IClassMapper classMap, IPredicate predicate, IList sort, IDictionary parameters)
19 | {
20 | if (parameters == null)
21 | {
22 | throw new ArgumentNullException("Parameters");
23 | }
24 |
25 | var sql = new StringBuilder(string.Format("SELECT {0} FROM {1}",
26 | BuildSelectColumns(classMap),
27 | GetTableName(classMap)));
28 | if (predicate != null)
29 | {
30 | sql.Append(" WHERE ")
31 | .Append(predicate.GetSql(this, parameters));
32 | }
33 |
34 | if (sort != null && sort.Any())
35 | {
36 | sql.Append(" ORDER BY ")
37 | .Append(sort.Select(s => GetColumnName(classMap, s.PropertyName, false) + (s.Ascending ? " ASC" : " DESC")).AppendStrings());
38 | }
39 |
40 | return sql.ToString();
41 | }
42 |
43 | public virtual string SelectPaged(IClassMapper classMap, IPredicate predicate, IList sort, int page, int resultsPerPage, IDictionary parameters)
44 | {
45 | if (sort == null || !sort.Any())
46 | {
47 | throw new ArgumentNullException("Sort", "Sort cannot be null or empty.");
48 | }
49 |
50 | if (parameters == null)
51 | {
52 | throw new ArgumentNullException("Parameters");
53 | }
54 |
55 | var innerSql = new StringBuilder(string.Format("SELECT {0} FROM {1}",
56 | BuildSelectColumns(classMap),
57 | GetTableName(classMap)));
58 | if (predicate != null)
59 | {
60 | innerSql.Append(" WHERE ")
61 | .Append(predicate.GetSql(this, parameters));
62 | }
63 |
64 | string orderBy = sort.Select(s => GetColumnName(classMap, s.PropertyName, false) + (s.Ascending ? " ASC" : " DESC")).AppendStrings();
65 | innerSql.Append(" ORDER BY " + orderBy);
66 |
67 | string sql = Configuration.Dialect.GetPagingSql(innerSql.ToString(), page, resultsPerPage, parameters);
68 | return sql;
69 | }
70 |
71 | public virtual string SelectSet(IClassMapper classMap, IPredicate predicate, IList sort, int firstResult, int maxResults, IDictionary parameters)
72 | {
73 | if (sort == null || !sort.Any())
74 | {
75 | throw new ArgumentNullException("Sort", "Sort cannot be null or empty.");
76 | }
77 |
78 | if (parameters == null)
79 | {
80 | throw new ArgumentNullException("Parameters");
81 | }
82 |
83 | var innerSql = new StringBuilder(string.Format("SELECT {0} FROM {1}",
84 | BuildSelectColumns(classMap),
85 | GetTableName(classMap)));
86 | if (predicate != null)
87 | {
88 | innerSql.Append(" WHERE ")
89 | .Append(predicate.GetSql(this, parameters));
90 | }
91 |
92 | string orderBy = sort.Select(s => GetColumnName(classMap, s.PropertyName, false) + (s.Ascending ? " ASC" : " DESC")).AppendStrings();
93 | innerSql.Append(" ORDER BY " + orderBy);
94 |
95 | string sql = Configuration.Dialect.GetSetSql(innerSql.ToString(), firstResult, maxResults, parameters);
96 | return sql;
97 | }
98 |
99 | public virtual string Count(IClassMapper classMap, IPredicate predicate, IDictionary parameters)
100 | {
101 | if (parameters == null)
102 | {
103 | throw new ArgumentNullException("Parameters");
104 | }
105 |
106 | var sql = new StringBuilder(string.Format("SELECT COUNT(*) AS {0}Total{1} FROM {2}",
107 | Configuration.Dialect.OpenQuote,
108 | Configuration.Dialect.CloseQuote,
109 | GetTableName(classMap)));
110 | if (predicate != null)
111 | {
112 | sql.Append(" WHERE ")
113 | .Append(predicate.GetSql(this, parameters));
114 | }
115 |
116 | return sql.ToString();
117 | }
118 |
119 | public virtual string ConnectionString()
120 | {
121 | return String.Empty;
122 | }
123 |
124 | public virtual string Database()
125 | {
126 | return String.Empty;
127 | }
128 |
129 | public virtual string Schema(IClassMapper classMapper)
130 | {
131 | return String.Empty;
132 | }
133 |
134 | public virtual string Create(IClassMapper classMap)
135 | {
136 | return string.Empty;
137 | }
138 |
139 | public virtual string Exists(IClassMapper classMap)
140 | {
141 | if (classMap == null)
142 | throw new ArgumentException("No table were mapped.");
143 |
144 | return String.Format("SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = '{0}' AND TABLE_SCHEMA = '{1}'", classMap.TableName, classMap.SchemaName);
145 | }
146 |
147 | public virtual string Drop(IClassMapper classMap)
148 | {
149 | if (classMap == null)
150 | throw new ArgumentException("No table were mapped.");
151 |
152 | return String.Format("DROP TABLE {0}", GetTableName(classMap));
153 | }
154 |
155 | public virtual string Insert(IClassMapper classMap)
156 | {
157 | var columns = classMap.Properties.Where(p => !(p.Ignored || p.IsReadOnly || p.KeyType == KeyType.Identity))
158 | .ToArray();
159 | if (!columns.Any())
160 | {
161 | throw new ArgumentException("No columns were mapped.");
162 | }
163 |
164 | var columnNames = columns.Select(p => GetColumnName(classMap, p, false));
165 | var parameters = columns.Select(p => Configuration.Dialect.ParameterPrefix + p.Name);
166 |
167 | string sql = string.Format("INSERT INTO {0} ({1}) VALUES ({2})",
168 | GetTableName(classMap),
169 | columnNames.AppendStrings(),
170 | parameters.AppendStrings());
171 |
172 | return sql;
173 | }
174 |
175 | public virtual string Update(IClassMapper classMap, IPredicate predicate, IDictionary parameters)
176 | {
177 | if (predicate == null)
178 | {
179 | throw new ArgumentNullException("Predicate");
180 | }
181 |
182 | if (parameters == null)
183 | {
184 | throw new ArgumentNullException("Parameters");
185 | }
186 |
187 | var columns = classMap.Properties.Where(p => !(p.Ignored || p.IsReadOnly || p.KeyType == KeyType.Identity))
188 | .ToArray();
189 | if (!columns.Any())
190 | {
191 | throw new ArgumentException("No columns were mapped.");
192 | }
193 |
194 | var setSql = columns.Select(p => string.Format("{0} = {1}{2}", GetColumnName(classMap, p, false), Configuration.Dialect.ParameterPrefix, p.Name));
195 |
196 | return string.Format("UPDATE {0} SET {1} WHERE {2}",
197 | GetTableName(classMap),
198 | setSql.AppendStrings(),
199 | predicate.GetSql(this, parameters));
200 | }
201 |
202 | public virtual string Delete(IClassMapper classMap, IPredicate predicate, IDictionary parameters)
203 | {
204 | if (predicate == null)
205 | {
206 | throw new ArgumentNullException("Predicate");
207 | }
208 |
209 | if (parameters == null)
210 | {
211 | throw new ArgumentNullException("Parameters");
212 | }
213 |
214 | var sql = new StringBuilder(string.Format("DELETE FROM {0}", GetTableName(classMap)));
215 | sql.Append(" WHERE ").Append(predicate.GetSql(this, parameters));
216 | return sql.ToString();
217 | }
218 |
219 | public virtual string IdentitySql(IClassMapper classMap)
220 | {
221 | return Configuration.Dialect.GetIdentitySql(GetTableName(classMap));
222 | }
223 |
224 | public virtual string GetTableName(IClassMapper map)
225 | {
226 | return Configuration.Dialect.GetTableName(map.SchemaName, map.TableName, null);
227 | }
228 |
229 | public virtual string GetColumnName(IClassMapper map, IPropertyMap property, bool includeAlias)
230 | {
231 | string alias = null;
232 | if (property.ColumnName != property.Name && includeAlias)
233 | {
234 | alias = property.Name;
235 | }
236 |
237 | return Configuration.Dialect.GetColumnName(GetTableName(map), property.ColumnName, alias);
238 | }
239 |
240 | public virtual string GetColumnName(IClassMapper map, string propertyName, bool includeAlias)
241 | {
242 | IPropertyMap propertyMap = map.Properties.SingleOrDefault(p => p.Name.Equals(propertyName, StringComparison.InvariantCultureIgnoreCase));
243 | if (propertyMap == null)
244 | {
245 | throw new ArgumentException(string.Format("Could not find '{0}' in Mapping.", propertyName));
246 | }
247 |
248 | return GetColumnName(map, propertyMap, includeAlias);
249 | }
250 |
251 | public virtual bool SupportsMultipleStatements()
252 | {
253 | return Configuration.Dialect.SupportsMultipleStatements;
254 | }
255 |
256 | public virtual string BuildSelectColumns(IClassMapper classMap)
257 | {
258 | var columns = classMap.Properties
259 | .Where(p => !p.Ignored)
260 | .Select(p => GetColumnName(classMap, p, true));
261 | return columns.AppendStrings();
262 | }
263 | }
264 | }
--------------------------------------------------------------------------------
/DapperRepository/DrapperDbManager.cs:
--------------------------------------------------------------------------------
1 | using System.Data;
2 | using DapperRepository.Drapper;
3 | using DapperRepository.Drapper.Sql;
4 |
5 | namespace DapperRepository
6 | {
7 | public abstract class DrapperManager : IDrapperManager
8 | {
9 | protected DrapperManager()
10 | {
11 | //TODO:
12 |
13 | Init();
14 | }
15 |
16 | protected DrapperManager(ISqlGenerator generator, IDbConnection dbConnection, ISqlDialect dialect)
17 | {
18 | Dialect = dialect;
19 | Generator = generator;
20 | DbConnection = dbConnection;
21 | Database = new Database(dbConnection, generator);
22 |
23 | Init();
24 | }
25 |
26 | public ISqlGenerator Generator { get; private set; }
27 |
28 | public IDbConnection DbConnection { get; private set; }
29 |
30 | public IDatabase Database { get; private set; }
31 |
32 | public ISqlDialect Dialect { get; private set; }
33 |
34 | public abstract void Dispose();
35 | public abstract void Init();
36 | }
37 | }
--------------------------------------------------------------------------------
/DapperRepository/Enums/DriverType.cs:
--------------------------------------------------------------------------------
1 | namespace DapperRepository.Enums
2 | {
3 | public enum DriverType
4 | {
5 | MSSQL,
6 | MySQL,
7 | PostgreSQL,
8 | SQLite
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/DapperRepository/Extensions/UtilExtension.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using System.Linq;
4 |
5 | namespace DapperRepository.Extensions
6 | {
7 | public static class UtilExtension
8 | {
9 | public static string[] AsSplit(this string str, string sperator)
10 | {
11 | return !str.IsNotNullOrEmpty()
12 | ? new string[] { }
13 | : str.Split(new[] { sperator }, StringSplitOptions.RemoveEmptyEntries);
14 | }
15 | public static bool IsString(this string obj, string str)
16 | {
17 | return (obj.IsNotNullOrEmpty()) && obj.Equals(str, StringComparison.InvariantCultureIgnoreCase);
18 | }
19 |
20 | public static bool IsNotNullOrEmpty(this object str)
21 | {
22 | return !String.IsNullOrWhiteSpace(str.AsString());
23 | }
24 |
25 | public static string AsString(this object obj)
26 | {
27 | return obj != null
28 | ? obj.ToString()
29 | : String.Empty;
30 | }
31 |
32 | public static int AsInt(this object obj)
33 | {
34 | int result;
35 |
36 | return int.TryParse(obj.AsString(), NumberStyles.Integer, null, out result) ? result : 0;
37 | }
38 |
39 | public static bool AsBoolString(this object str)
40 | {
41 | var items = new string[]
42 | {
43 | "YES", //YES/NO
44 | "Y", //Y/N
45 | "TRUE",//TRUE/FALSE
46 | "T",//T/F
47 | "1",//1/0
48 | "ON", //ON/OFF
49 | };
50 |
51 | return str.IsNotNullOrEmpty() && items.Any(a => a.IsString(str.AsString()));
52 | }
53 |
54 | public static bool IsEnum(this string str) where T : struct
55 | {
56 | T t;
57 |
58 | return Enum.TryParse(str, true, out t);
59 | }
60 |
61 | public static T AsEnum(this string str, T defaultValue = default(T)) where T : struct
62 | {
63 | T t;
64 |
65 | return Enum.TryParse(str, true, out t)
66 | ? t
67 | : defaultValue;
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/DapperRepository/Extensions/XMLExtension.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Xml.Linq;
3 |
4 | namespace DapperRepository.Extensions
5 | {
6 | public static class XMLExtension
7 | {
8 | public static string GetElementValue(this XElement element, string key)
9 | {
10 | if (element == null)
11 | return String.Empty;
12 |
13 | var elem = element.Element(key);
14 |
15 | return elem == null ? String.Empty : elem.Value;
16 | }
17 |
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/DapperRepository/Helpers/MigrationHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using DapperRepository.Demo;
3 | using DapperRepository.Models;
4 |
5 | namespace DapperRepository.Helpers
6 | {
7 | public static class MigrationHelper
8 | {
9 | private static IDrapperManager _manager;
10 | private static RepositoryModel _model;
11 |
12 | private static void Init()
13 | {
14 | if (_manager == null)
15 | _manager = RepositoryFactory.GetManager();
16 |
17 | _model = RepositoryFactory.GetModel();
18 | }
19 |
20 | public static void Configure() where T : class
21 | {
22 | Init();
23 |
24 | if (!_model.Options.MigrationsEnabled)
25 | return;
26 |
27 | var commandTimeOut = _model.Options.CommandTimeOut;
28 |
29 | if (_model.Options.CreateDatabaseIfNotExists)
30 | _manager.Database.CreateDatabaseIfNotExists(_model.ConnectionString, commandTimeOut);
31 |
32 | _manager.Database.Open();
33 |
34 | if (_manager.Database.Exists(commandTimeOut))
35 | {
36 | if (_model.Options.MigrationDataLossAllowed)
37 | _manager.Database.Drop(commandTimeOut);
38 | }
39 |
40 | if (!String.IsNullOrWhiteSpace(_model.Options.DefaultSchema))
41 | _manager.Database.CreateSchemaIfNotExists(commandTimeOut);
42 |
43 | _manager.Database.Create(commandTimeOut);
44 |
45 | _manager.Database.Close();
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/DapperRepository/Helpers/XLinqHelper.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 | using System.Text;
3 | using System.Xml.Linq;
4 |
5 | namespace DapperRepository.Demo.Helpers
6 | {
7 | public static class XLinqHelper
8 | {
9 | public static XDocument GetConfigDocument(string path)
10 | {
11 | var content = File.ReadAllText(path, Encoding.UTF8);
12 |
13 | return XDocument.Parse(content, LoadOptions.None);
14 | }
15 |
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/DapperRepository/IDrapperManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Data;
3 | using DapperRepository.Drapper;
4 | using DapperRepository.Drapper.Sql;
5 |
6 | namespace DapperRepository
7 | {
8 | public interface IDrapperManager : IDisposable
9 | {
10 | ISqlGenerator Generator { get; }
11 |
12 | IDbConnection DbConnection { get; }
13 |
14 | IDatabase Database { get; }
15 |
16 | ISqlDialect Dialect { get; }
17 | }
18 | }
--------------------------------------------------------------------------------
/DapperRepository/Models/RepositoryModel.cs:
--------------------------------------------------------------------------------
1 | using DapperRepository.Enums;
2 |
3 | namespace DapperRepository.Models
4 | {
5 |
6 | public struct Options
7 | {
8 | public int CommandTimeOut { get; set; }
9 |
10 | public string DefaultSchema { get; set; }
11 |
12 | public bool MigrationsEnabled { get; set; }
13 |
14 | public bool CreateDatabaseIfNotExists { get; set; }
15 |
16 | public bool MigrationDataLossAllowed { get; set; }
17 |
18 | }
19 |
20 | public struct RepositoryModel
21 | {
22 |
23 | public DriverType DriverType { get; set; }
24 |
25 | public string ConnectionString { get; set; }
26 |
27 | public Options Options { get; set; }
28 |
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/DapperRepository/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 |
4 | // General Information about an assembly is controlled through the following
5 | // set of attributes. Change these attribute values to modify the information
6 | // associated with an assembly.
7 |
8 | [assembly: AssemblyTitle("DapperRepository")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("DapperRepository")]
13 | [assembly: AssemblyCopyright("Copyright © 2014")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 |
21 | [assembly: ComVisible(false)]
22 |
23 | // The following GUID is for the ID of the typelib if this project is exposed to COM
24 |
25 | [assembly: Guid("782812c0-827f-47db-8c63-c07c87e4b919")]
26 |
27 | // Version information for an assembly consists of the following four values:
28 | //
29 | // Major Version
30 | // Minor Version
31 | // Build Number
32 | // Revision
33 | //
34 | // You can specify all the values or you can default the Build and Revision Numbers
35 | // by using the '*' as shown below:
36 | // [assembly: AssemblyVersion("1.0.*")]
37 |
38 | [assembly: AssemblyVersion("1.0.0.0")]
39 | [assembly: AssemblyFileVersion("1.0.0.0")]
--------------------------------------------------------------------------------
/DapperRepository/RepositoryFactory.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using DapperRepository.Demo.Helpers;
4 | using DapperRepository.Enums;
5 | using DapperRepository.Extensions;
6 | using DapperRepository.Models;
7 |
8 | namespace DapperRepository
9 | {
10 | public static class RepositoryFactory
11 | {
12 | private static RepositoryModel _model;
13 | private static IDrapperManager _manager;
14 |
15 | private static void PreInit()
16 | {
17 | var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, RepositorySettings.CONFIG_FILE);
18 | var doc = XLinqHelper.GetConfigDocument(path);
19 | var root = doc.Element("Repository");
20 |
21 | //model
22 | if (root == null)
23 | {
24 | _model = new RepositoryModel
25 | {
26 | DriverType = RepositorySettings.DEFAULT_DRIVER.AsEnum(),
27 | ConnectionString = RepositorySettings.DEFAULT_CONNECTION_STRING,
28 | Options = new Options
29 | {
30 | CommandTimeOut = RepositorySettings.COMMAND_TIME_OUT,
31 | MigrationsEnabled = true,
32 | CreateDatabaseIfNotExists = true,
33 | MigrationDataLossAllowed = false
34 | }
35 | };
36 | }
37 | else
38 | {
39 | _model = new RepositoryModel
40 | {
41 | DriverType = root.GetElementValue("DriverType").AsEnum(),
42 | ConnectionString = root.GetElementValue("ConnectionString")
43 | };
44 |
45 | var options = root.Element("Options");
46 |
47 | if (options != null)
48 | {
49 | _model.Options = new Options
50 | {
51 | CommandTimeOut = options.GetElementValue("CommandTimeOut").AsInt(),
52 | DefaultSchema = options.GetElementValue("DefaultSchema"),
53 | MigrationsEnabled = options.GetElementValue("MigrationsEnabled").AsBoolString(),
54 | CreateDatabaseIfNotExists = options.GetElementValue("CreateDatabaseIfNotExists").AsBoolString(),
55 | MigrationDataLossAllowed = options.GetElementValue("MigrationDataLossAllowed").AsBoolString()
56 | };
57 | }
58 | }
59 | }
60 |
61 | static RepositoryFactory()
62 | {
63 | PreInit();
64 | }
65 |
66 |
67 | public static RepositoryModel GetModel()
68 | {
69 | return _model;
70 | }
71 |
72 | public static void SetManager(IDrapperManager manager)
73 | {
74 | _manager = manager;
75 | }
76 |
77 | public static IDrapperManager GetManager()
78 | {
79 | return _manager;
80 | }
81 |
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/DapperRepository/RepositorySettings.cs:
--------------------------------------------------------------------------------
1 | namespace DapperRepository
2 | {
3 | internal static class RepositorySettings
4 | {
5 | //RepositoryModel config file
6 | public const string CONFIG_FILE = @"RepositoryConfig.xml";
7 |
8 | //database
9 | public const string DEFAULT_DRIVER = @"SQLite";
10 | public const string DEFAULT_CONNECTION_STRING = @"Data Source=QueryProcessorStorage.sqlite;Version=3;";
11 | public const int COMMAND_TIME_OUT = 3600;
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/DapperRepository/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/HEAD:
--------------------------------------------------------------------------------
1 | ref: refs/heads/master
2 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Welcome to the DapperRepository wiki!
2 |
3 | Simple SQL object mapper for ADO.NET
4 |
5 | Dapper .NET source - https://github.com/elyor0529/dapper-dot-net
6 | Dapper Extensions - https://github.com/elyor0529/Dapper-Extensions
7 |
8 | Latest modified by Elyor Latipov - mailto:elyor@outlook.com
9 |
10 | I fix to this issue list:
11 |
12 | - Type Mapping
13 | - Drop table
14 | - Exists table
15 | - Create table
16 | - Create Schema
17 | - Create Database
18 | - PK , UQ , NN impleted to every dialects
19 |
20 |
21 | Model:
22 |
23 | public class TempModel
24 | {
25 | public TempModel()
26 | {
27 | LastModifiedDate = DateTime.Now;
28 | CreatedDate = DateTime.Now;
29 | }
30 | public long ID { get; set; }
31 | public string Name { get; set; }
32 | public DateTime CreatedDate { get; set; }
33 | public DateTime LastModifiedDate { get; set; }
34 | }
35 |
36 |
37 | Mapper:
38 |
39 | public class TempModelMapper : ClassMapper
40 | {
41 | public TempModelMapper()
42 | {
43 | Table("BusinessView");
44 | Map(f => f.ID).Column("Id").Key(KeyType.Identity);
45 | Map(f => f.Name).Column("Name");
46 | Map(f => f.CreatedDate).Column("CreatedDate");
47 | Map(f => f.LastModifiedDate).Column("LastModifiedDate");
48 | Schema("");
49 | }
50 | }
51 |
52 | Connection Strings:
53 |
54 |
55 |
56 | SQLite
57 | Data Source=QueryProcessorStorage.sqlite;Version=3;
58 |
59 | 0
60 |
61 | True
62 | False
63 | True
64 |
65 |
66 |
67 | Test:
68 |
69 | private static IDrapperManager _manager;
70 |
71 | static Program()
72 | {
73 | _manager = RepositoryFactory.GetManager();
74 |
75 | RepositoryFactory.SetManager(_manager);
76 | }
77 |
78 | [Migration(typeof(TempModel))]
79 |
80 | private static void Main(string[] args)
81 | {
82 | using (_manager)
83 | {
84 | _manager.Database.Open();
85 |
86 | //insert
87 | var bv = new TempModel
88 | {
89 | Name = "BV"
90 | };
91 | var bvId = _manager.Database.Insert(bv);
92 |
93 | //get
94 | bv = _manager.Database.Get(bvId);
95 |
96 | //update
97 | bv.Name = "Workfile1";
98 | bv.CreatedDate = DateTime.Now;
99 | bv.LastModifiedDate = DateTime.Now;
100 | _manager.Database.Update(bv);
101 |
102 | //delete
103 | _manager.Database.Delete(bv);
104 |
105 | //all
106 | var bvs = _manager.Database.GetList();
107 | Console.WriteLine("All:");
108 | foreach (var item in bvs)
109 | Console.WriteLine(item.Name);
110 |
111 | //filter
112 | var predicate = Predicates.Field(a => a.Name, Operator.Like, "%a%");
113 | bvs = _manager.Database.GetList(predicate);
114 | Console.WriteLine("Filter(By 'like' operator):");
115 | foreach (var item in bvs)
116 | Console.WriteLine(item.Name);
117 |
118 | _manager.Database.Close();
119 | }
120 | }
121 |
--------------------------------------------------------------------------------
/config:
--------------------------------------------------------------------------------
1 | [core]
2 | repositoryformatversion = 0
3 | filemode = false
4 | bare = true
5 | symlinks = false
6 | ignorecase = true
7 | hideDotFiles = dotGitOnly
8 |
--------------------------------------------------------------------------------
/description:
--------------------------------------------------------------------------------
1 | Unnamed repository; edit this file 'description' to name the repository.
2 |
--------------------------------------------------------------------------------
/hooks/applypatch-msg.sample:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # An example hook script to check the commit log message taken by
4 | # applypatch from an e-mail message.
5 | #
6 | # The hook should exit with non-zero status after issuing an
7 | # appropriate message if it wants to stop the commit. The hook is
8 | # allowed to edit the commit message file.
9 | #
10 | # To enable this hook, rename this file to "applypatch-msg".
11 |
12 | . git-sh-setup
13 | test -x "$GIT_DIR/hooks/commit-msg" &&
14 | exec "$GIT_DIR/hooks/commit-msg" ${1+"$@"}
15 | :
16 |
--------------------------------------------------------------------------------
/hooks/commit-msg.sample:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # An example hook script to check the commit log message.
4 | # Called by "git commit" with one argument, the name of the file
5 | # that has the commit message. The hook should exit with non-zero
6 | # status after issuing an appropriate message if it wants to stop the
7 | # commit. The hook is allowed to edit the commit message file.
8 | #
9 | # To enable this hook, rename this file to "commit-msg".
10 |
11 | # Uncomment the below to add a Signed-off-by line to the message.
12 | # Doing this in a hook is a bad idea in general, but the prepare-commit-msg
13 | # hook is more suited to it.
14 | #
15 | # SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
16 | # grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"
17 |
18 | # This example catches duplicate Signed-off-by lines.
19 |
20 | test "" = "$(grep '^Signed-off-by: ' "$1" |
21 | sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || {
22 | echo >&2 Duplicate Signed-off-by lines.
23 | exit 1
24 | }
25 |
--------------------------------------------------------------------------------
/hooks/post-update.sample:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # An example hook script to prepare a packed repository for use over
4 | # dumb transports.
5 | #
6 | # To enable this hook, rename this file to "post-update".
7 |
8 | exec git update-server-info
9 |
--------------------------------------------------------------------------------
/hooks/pre-applypatch.sample:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # An example hook script to verify what is about to be committed
4 | # by applypatch from an e-mail message.
5 | #
6 | # The hook should exit with non-zero status after issuing an
7 | # appropriate message if it wants to stop the commit.
8 | #
9 | # To enable this hook, rename this file to "pre-applypatch".
10 |
11 | . git-sh-setup
12 | test -x "$GIT_DIR/hooks/pre-commit" &&
13 | exec "$GIT_DIR/hooks/pre-commit" ${1+"$@"}
14 | :
15 |
--------------------------------------------------------------------------------
/hooks/pre-commit.sample:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # An example hook script to verify what is about to be committed.
4 | # Called by "git commit" with no arguments. The hook should
5 | # exit with non-zero status after issuing an appropriate message if
6 | # it wants to stop the commit.
7 | #
8 | # To enable this hook, rename this file to "pre-commit".
9 |
10 | if git rev-parse --verify HEAD >/dev/null 2>&1
11 | then
12 | against=HEAD
13 | else
14 | # Initial commit: diff against an empty tree object
15 | against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
16 | fi
17 |
18 | # If you want to allow non-ASCII filenames set this variable to true.
19 | allownonascii=$(git config hooks.allownonascii)
20 |
21 | # Redirect output to stderr.
22 | exec 1>&2
23 |
24 | # Cross platform projects tend to avoid non-ASCII filenames; prevent
25 | # them from being added to the repository. We exploit the fact that the
26 | # printable range starts at the space character and ends with tilde.
27 | if [ "$allownonascii" != "true" ] &&
28 | # Note that the use of brackets around a tr range is ok here, (it's
29 | # even required, for portability to Solaris 10's /usr/bin/tr), since
30 | # the square bracket bytes happen to fall in the designated range.
31 | test $(git diff --cached --name-only --diff-filter=A -z $against |
32 | LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0
33 | then
34 | cat <<\EOF
35 | Error: Attempt to add a non-ASCII file name.
36 |
37 | This can cause problems if you want to work with people on other platforms.
38 |
39 | To be portable it is advisable to rename the file.
40 |
41 | If you know what you are doing you can disable this check using:
42 |
43 | git config hooks.allownonascii true
44 | EOF
45 | exit 1
46 | fi
47 |
48 | # If there are whitespace errors, print the offending file names and fail.
49 | exec git diff-index --check --cached $against --
50 |
--------------------------------------------------------------------------------
/hooks/pre-push.sample:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # An example hook script to verify what is about to be pushed. Called by "git
4 | # push" after it has checked the remote status, but before anything has been
5 | # pushed. If this script exits with a non-zero status nothing will be pushed.
6 | #
7 | # This hook is called with the following parameters:
8 | #
9 | # $1 -- Name of the remote to which the push is being done
10 | # $2 -- URL to which the push is being done
11 | #
12 | # If pushing without using a named remote those arguments will be equal.
13 | #
14 | # Information about the commits which are being pushed is supplied as lines to
15 | # the standard input in the form:
16 | #
17 | #
18 | #
19 | # This sample shows how to prevent push of commits where the log message starts
20 | # with "WIP" (work in progress).
21 |
22 | remote="$1"
23 | url="$2"
24 |
25 | z40=0000000000000000000000000000000000000000
26 |
27 | IFS=' '
28 | while read local_ref local_sha remote_ref remote_sha
29 | do
30 | if [ "$local_sha" = $z40 ]
31 | then
32 | # Handle delete
33 | else
34 | if [ "$remote_sha" = $z40 ]
35 | then
36 | # New branch, examine all commits
37 | range="$local_sha"
38 | else
39 | # Update to existing branch, examine new commits
40 | range="$remote_sha..$local_sha"
41 | fi
42 |
43 | # Check for WIP commit
44 | commit=`git rev-list -n 1 --grep '^WIP' "$range"`
45 | if [ -n "$commit" ]
46 | then
47 | echo "Found WIP commit in $local_ref, not pushing"
48 | exit 1
49 | fi
50 | fi
51 | done
52 |
53 | exit 0
54 |
--------------------------------------------------------------------------------
/hooks/pre-rebase.sample:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Copyright (c) 2006, 2008 Junio C Hamano
4 | #
5 | # The "pre-rebase" hook is run just before "git rebase" starts doing
6 | # its job, and can prevent the command from running by exiting with
7 | # non-zero status.
8 | #
9 | # The hook is called with the following parameters:
10 | #
11 | # $1 -- the upstream the series was forked from.
12 | # $2 -- the branch being rebased (or empty when rebasing the current branch).
13 | #
14 | # This sample shows how to prevent topic branches that are already
15 | # merged to 'next' branch from getting rebased, because allowing it
16 | # would result in rebasing already published history.
17 |
18 | publish=next
19 | basebranch="$1"
20 | if test "$#" = 2
21 | then
22 | topic="refs/heads/$2"
23 | else
24 | topic=`git symbolic-ref HEAD` ||
25 | exit 0 ;# we do not interrupt rebasing detached HEAD
26 | fi
27 |
28 | case "$topic" in
29 | refs/heads/??/*)
30 | ;;
31 | *)
32 | exit 0 ;# we do not interrupt others.
33 | ;;
34 | esac
35 |
36 | # Now we are dealing with a topic branch being rebased
37 | # on top of master. Is it OK to rebase it?
38 |
39 | # Does the topic really exist?
40 | git show-ref -q "$topic" || {
41 | echo >&2 "No such branch $topic"
42 | exit 1
43 | }
44 |
45 | # Is topic fully merged to master?
46 | not_in_master=`git rev-list --pretty=oneline ^master "$topic"`
47 | if test -z "$not_in_master"
48 | then
49 | echo >&2 "$topic is fully merged to master; better remove it."
50 | exit 1 ;# we could allow it, but there is no point.
51 | fi
52 |
53 | # Is topic ever merged to next? If so you should not be rebasing it.
54 | only_next_1=`git rev-list ^master "^$topic" ${publish} | sort`
55 | only_next_2=`git rev-list ^master ${publish} | sort`
56 | if test "$only_next_1" = "$only_next_2"
57 | then
58 | not_in_topic=`git rev-list "^$topic" master`
59 | if test -z "$not_in_topic"
60 | then
61 | echo >&2 "$topic is already up-to-date with master"
62 | exit 1 ;# we could allow it, but there is no point.
63 | else
64 | exit 0
65 | fi
66 | else
67 | not_in_next=`git rev-list --pretty=oneline ^${publish} "$topic"`
68 | /usr/bin/perl -e '
69 | my $topic = $ARGV[0];
70 | my $msg = "* $topic has commits already merged to public branch:\n";
71 | my (%not_in_next) = map {
72 | /^([0-9a-f]+) /;
73 | ($1 => 1);
74 | } split(/\n/, $ARGV[1]);
75 | for my $elem (map {
76 | /^([0-9a-f]+) (.*)$/;
77 | [$1 => $2];
78 | } split(/\n/, $ARGV[2])) {
79 | if (!exists $not_in_next{$elem->[0]}) {
80 | if ($msg) {
81 | print STDERR $msg;
82 | undef $msg;
83 | }
84 | print STDERR " $elem->[1]\n";
85 | }
86 | }
87 | ' "$topic" "$not_in_next" "$not_in_master"
88 | exit 1
89 | fi
90 |
91 | exit 0
92 |
93 | ################################################################
94 |
95 | This sample hook safeguards topic branches that have been
96 | published from being rewound.
97 |
98 | The workflow assumed here is:
99 |
100 | * Once a topic branch forks from "master", "master" is never
101 | merged into it again (either directly or indirectly).
102 |
103 | * Once a topic branch is fully cooked and merged into "master",
104 | it is deleted. If you need to build on top of it to correct
105 | earlier mistakes, a new topic branch is created by forking at
106 | the tip of the "master". This is not strictly necessary, but
107 | it makes it easier to keep your history simple.
108 |
109 | * Whenever you need to test or publish your changes to topic
110 | branches, merge them into "next" branch.
111 |
112 | The script, being an example, hardcodes the publish branch name
113 | to be "next", but it is trivial to make it configurable via
114 | $GIT_DIR/config mechanism.
115 |
116 | With this workflow, you would want to know:
117 |
118 | (1) ... if a topic branch has ever been merged to "next". Young
119 | topic branches can have stupid mistakes you would rather
120 | clean up before publishing, and things that have not been
121 | merged into other branches can be easily rebased without
122 | affecting other people. But once it is published, you would
123 | not want to rewind it.
124 |
125 | (2) ... if a topic branch has been fully merged to "master".
126 | Then you can delete it. More importantly, you should not
127 | build on top of it -- other people may already want to
128 | change things related to the topic as patches against your
129 | "master", so if you need further changes, it is better to
130 | fork the topic (perhaps with the same name) afresh from the
131 | tip of "master".
132 |
133 | Let's look at this example:
134 |
135 | o---o---o---o---o---o---o---o---o---o "next"
136 | / / / /
137 | / a---a---b A / /
138 | / / / /
139 | / / c---c---c---c B /
140 | / / / \ /
141 | / / / b---b C \ /
142 | / / / / \ /
143 | ---o---o---o---o---o---o---o---o---o---o---o "master"
144 |
145 |
146 | A, B and C are topic branches.
147 |
148 | * A has one fix since it was merged up to "next".
149 |
150 | * B has finished. It has been fully merged up to "master" and "next",
151 | and is ready to be deleted.
152 |
153 | * C has not merged to "next" at all.
154 |
155 | We would want to allow C to be rebased, refuse A, and encourage
156 | B to be deleted.
157 |
158 | To compute (1):
159 |
160 | git rev-list ^master ^topic next
161 | git rev-list ^master next
162 |
163 | if these match, topic has not merged in next at all.
164 |
165 | To compute (2):
166 |
167 | git rev-list master..topic
168 |
169 | if this is empty, it is fully merged to "master".
170 |
--------------------------------------------------------------------------------
/hooks/prepare-commit-msg.sample:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # An example hook script to prepare the commit log message.
4 | # Called by "git commit" with the name of the file that has the
5 | # commit message, followed by the description of the commit
6 | # message's source. The hook's purpose is to edit the commit
7 | # message file. If the hook fails with a non-zero status,
8 | # the commit is aborted.
9 | #
10 | # To enable this hook, rename this file to "prepare-commit-msg".
11 |
12 | # This hook includes three examples. The first comments out the
13 | # "Conflicts:" part of a merge commit.
14 | #
15 | # The second includes the output of "git diff --name-status -r"
16 | # into the message, just before the "git status" output. It is
17 | # commented because it doesn't cope with --amend or with squashed
18 | # commits.
19 | #
20 | # The third example adds a Signed-off-by line to the message, that can
21 | # still be edited. This is rarely a good idea.
22 |
23 | case "$2,$3" in
24 | merge,)
25 | /usr/bin/perl -i.bak -ne 's/^/# /, s/^# #/#/ if /^Conflicts/ .. /#/; print' "$1" ;;
26 |
27 | # ,|template,)
28 | # /usr/bin/perl -i.bak -pe '
29 | # print "\n" . `git diff --cached --name-status -r`
30 | # if /^#/ && $first++ == 0' "$1" ;;
31 |
32 | *) ;;
33 | esac
34 |
35 | # SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
36 | # grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"
37 |
--------------------------------------------------------------------------------
/hooks/update.sample:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # An example hook script to blocks unannotated tags from entering.
4 | # Called by "git receive-pack" with arguments: refname sha1-old sha1-new
5 | #
6 | # To enable this hook, rename this file to "update".
7 | #
8 | # Config
9 | # ------
10 | # hooks.allowunannotated
11 | # This boolean sets whether unannotated tags will be allowed into the
12 | # repository. By default they won't be.
13 | # hooks.allowdeletetag
14 | # This boolean sets whether deleting tags will be allowed in the
15 | # repository. By default they won't be.
16 | # hooks.allowmodifytag
17 | # This boolean sets whether a tag may be modified after creation. By default
18 | # it won't be.
19 | # hooks.allowdeletebranch
20 | # This boolean sets whether deleting branches will be allowed in the
21 | # repository. By default they won't be.
22 | # hooks.denycreatebranch
23 | # This boolean sets whether remotely creating branches will be denied
24 | # in the repository. By default this is allowed.
25 | #
26 |
27 | # --- Command line
28 | refname="$1"
29 | oldrev="$2"
30 | newrev="$3"
31 |
32 | # --- Safety check
33 | if [ -z "$GIT_DIR" ]; then
34 | echo "Don't run this script from the command line." >&2
35 | echo " (if you want, you could supply GIT_DIR then run" >&2
36 | echo " $0 [ )" >&2
37 | exit 1
38 | fi
39 |
40 | if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then
41 | echo "usage: $0 ][ " >&2
42 | exit 1
43 | fi
44 |
45 | # --- Config
46 | allowunannotated=$(git config --bool hooks.allowunannotated)
47 | allowdeletebranch=$(git config --bool hooks.allowdeletebranch)
48 | denycreatebranch=$(git config --bool hooks.denycreatebranch)
49 | allowdeletetag=$(git config --bool hooks.allowdeletetag)
50 | allowmodifytag=$(git config --bool hooks.allowmodifytag)
51 |
52 | # check for no description
53 | projectdesc=$(sed -e '1q' "$GIT_DIR/description")
54 | case "$projectdesc" in
55 | "Unnamed repository"* | "")
56 | echo "*** Project description file hasn't been set" >&2
57 | exit 1
58 | ;;
59 | esac
60 |
61 | # --- Check types
62 | # if $newrev is 0000...0000, it's a commit to delete a ref.
63 | zero="0000000000000000000000000000000000000000"
64 | if [ "$newrev" = "$zero" ]; then
65 | newrev_type=delete
66 | else
67 | newrev_type=$(git cat-file -t $newrev)
68 | fi
69 |
70 | case "$refname","$newrev_type" in
71 | refs/tags/*,commit)
72 | # un-annotated tag
73 | short_refname=${refname##refs/tags/}
74 | if [ "$allowunannotated" != "true" ]; then
75 | echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&2
76 | echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2
77 | exit 1
78 | fi
79 | ;;
80 | refs/tags/*,delete)
81 | # delete tag
82 | if [ "$allowdeletetag" != "true" ]; then
83 | echo "*** Deleting a tag is not allowed in this repository" >&2
84 | exit 1
85 | fi
86 | ;;
87 | refs/tags/*,tag)
88 | # annotated tag
89 | if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1
90 | then
91 | echo "*** Tag '$refname' already exists." >&2
92 | echo "*** Modifying a tag is not allowed in this repository." >&2
93 | exit 1
94 | fi
95 | ;;
96 | refs/heads/*,commit)
97 | # branch
98 | if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then
99 | echo "*** Creating a branch is not allowed in this repository" >&2
100 | exit 1
101 | fi
102 | ;;
103 | refs/heads/*,delete)
104 | # delete branch
105 | if [ "$allowdeletebranch" != "true" ]; then
106 | echo "*** Deleting a branch is not allowed in this repository" >&2
107 | exit 1
108 | fi
109 | ;;
110 | refs/remotes/*,commit)
111 | # tracking branch
112 | ;;
113 | refs/remotes/*,delete)
114 | # delete tracking branch
115 | if [ "$allowdeletebranch" != "true" ]; then
116 | echo "*** Deleting a tracking branch is not allowed in this repository" >&2
117 | exit 1
118 | fi
119 | ;;
120 | *)
121 | # Anything else (is there anything else?)
122 | echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2
123 | exit 1
124 | ;;
125 | esac
126 |
127 | # --- Finished
128 | exit 0
129 |
--------------------------------------------------------------------------------
/info/exclude:
--------------------------------------------------------------------------------
1 | # git ls-files --others --exclude-from=.git/info/exclude
2 | # Lines that start with '#' are comments.
3 | # For a project mostly in C, the following would be a good set of
4 | # exclude patterns (uncomment them if you want to use them):
5 | # *.[oa]
6 | # *~
7 |
--------------------------------------------------------------------------------
/packages/MySql.Data.6.8.3/MySql.Data.6.8.3.nupkg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/uzbekdev1/DapperRepository/c871ea58a4a61f717594bd2242e99409ea0d3cb7/packages/MySql.Data.6.8.3/MySql.Data.6.8.3.nupkg
--------------------------------------------------------------------------------
/packages/MySql.Data.6.8.3/lib/net20-cf/MySql.Data.cf.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/uzbekdev1/DapperRepository/c871ea58a4a61f717594bd2242e99409ea0d3cb7/packages/MySql.Data.6.8.3/lib/net20-cf/MySql.Data.cf.dll
--------------------------------------------------------------------------------
/packages/MySql.Data.6.8.3/lib/net20/MySql.Data.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/uzbekdev1/DapperRepository/c871ea58a4a61f717594bd2242e99409ea0d3cb7/packages/MySql.Data.6.8.3/lib/net20/MySql.Data.dll
--------------------------------------------------------------------------------
/packages/MySql.Data.6.8.3/lib/net40/MySql.Data.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/uzbekdev1/DapperRepository/c871ea58a4a61f717594bd2242e99409ea0d3cb7/packages/MySql.Data.6.8.3/lib/net40/MySql.Data.dll
--------------------------------------------------------------------------------
/packages/MySql.Data.6.8.3/lib/net45/MySql.Data.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/uzbekdev1/DapperRepository/c871ea58a4a61f717594bd2242e99409ea0d3cb7/packages/MySql.Data.6.8.3/lib/net45/MySql.Data.dll
--------------------------------------------------------------------------------
/packages/MySql.Data.6.8.3/lib/netcore45/MySql.Data.RT.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/uzbekdev1/DapperRepository/c871ea58a4a61f717594bd2242e99409ea0d3cb7/packages/MySql.Data.6.8.3/lib/netcore45/MySql.Data.RT.dll
--------------------------------------------------------------------------------
/packages/Npgsql.2.1.3/Npgsql.2.1.3.nupkg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/uzbekdev1/DapperRepository/c871ea58a4a61f717594bd2242e99409ea0d3cb7/packages/Npgsql.2.1.3/Npgsql.2.1.3.nupkg
--------------------------------------------------------------------------------
/packages/Npgsql.2.1.3/lib/net20/Mono.Security.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/uzbekdev1/DapperRepository/c871ea58a4a61f717594bd2242e99409ea0d3cb7/packages/Npgsql.2.1.3/lib/net20/Mono.Security.dll
--------------------------------------------------------------------------------
/packages/Npgsql.2.1.3/lib/net20/Npgsql.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/uzbekdev1/DapperRepository/c871ea58a4a61f717594bd2242e99409ea0d3cb7/packages/Npgsql.2.1.3/lib/net20/Npgsql.dll
--------------------------------------------------------------------------------
/packages/Npgsql.2.1.3/lib/net20/de/Npgsql.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/uzbekdev1/DapperRepository/c871ea58a4a61f717594bd2242e99409ea0d3cb7/packages/Npgsql.2.1.3/lib/net20/de/Npgsql.resources.dll
--------------------------------------------------------------------------------
/packages/Npgsql.2.1.3/lib/net20/es/Npgsql.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/uzbekdev1/DapperRepository/c871ea58a4a61f717594bd2242e99409ea0d3cb7/packages/Npgsql.2.1.3/lib/net20/es/Npgsql.resources.dll
--------------------------------------------------------------------------------
/packages/Npgsql.2.1.3/lib/net20/fi/Npgsql.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/uzbekdev1/DapperRepository/c871ea58a4a61f717594bd2242e99409ea0d3cb7/packages/Npgsql.2.1.3/lib/net20/fi/Npgsql.resources.dll
--------------------------------------------------------------------------------
/packages/Npgsql.2.1.3/lib/net20/fr/Npgsql.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/uzbekdev1/DapperRepository/c871ea58a4a61f717594bd2242e99409ea0d3cb7/packages/Npgsql.2.1.3/lib/net20/fr/Npgsql.resources.dll
--------------------------------------------------------------------------------
/packages/Npgsql.2.1.3/lib/net20/ja/Npgsql.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/uzbekdev1/DapperRepository/c871ea58a4a61f717594bd2242e99409ea0d3cb7/packages/Npgsql.2.1.3/lib/net20/ja/Npgsql.resources.dll
--------------------------------------------------------------------------------
/packages/Npgsql.2.1.3/lib/net20/zh-CN/Npgsql.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/uzbekdev1/DapperRepository/c871ea58a4a61f717594bd2242e99409ea0d3cb7/packages/Npgsql.2.1.3/lib/net20/zh-CN/Npgsql.resources.dll
--------------------------------------------------------------------------------
/packages/Npgsql.2.1.3/lib/net35/Mono.Security.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/uzbekdev1/DapperRepository/c871ea58a4a61f717594bd2242e99409ea0d3cb7/packages/Npgsql.2.1.3/lib/net35/Mono.Security.dll
--------------------------------------------------------------------------------
/packages/Npgsql.2.1.3/lib/net35/Npgsql.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/uzbekdev1/DapperRepository/c871ea58a4a61f717594bd2242e99409ea0d3cb7/packages/Npgsql.2.1.3/lib/net35/Npgsql.dll
--------------------------------------------------------------------------------
/packages/Npgsql.2.1.3/lib/net35/de/Npgsql.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/uzbekdev1/DapperRepository/c871ea58a4a61f717594bd2242e99409ea0d3cb7/packages/Npgsql.2.1.3/lib/net35/de/Npgsql.resources.dll
--------------------------------------------------------------------------------
/packages/Npgsql.2.1.3/lib/net35/es/Npgsql.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/uzbekdev1/DapperRepository/c871ea58a4a61f717594bd2242e99409ea0d3cb7/packages/Npgsql.2.1.3/lib/net35/es/Npgsql.resources.dll
--------------------------------------------------------------------------------
/packages/Npgsql.2.1.3/lib/net35/fi/Npgsql.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/uzbekdev1/DapperRepository/c871ea58a4a61f717594bd2242e99409ea0d3cb7/packages/Npgsql.2.1.3/lib/net35/fi/Npgsql.resources.dll
--------------------------------------------------------------------------------
/packages/Npgsql.2.1.3/lib/net35/fr/Npgsql.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/uzbekdev1/DapperRepository/c871ea58a4a61f717594bd2242e99409ea0d3cb7/packages/Npgsql.2.1.3/lib/net35/fr/Npgsql.resources.dll
--------------------------------------------------------------------------------
/packages/Npgsql.2.1.3/lib/net35/ja/Npgsql.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/uzbekdev1/DapperRepository/c871ea58a4a61f717594bd2242e99409ea0d3cb7/packages/Npgsql.2.1.3/lib/net35/ja/Npgsql.resources.dll
--------------------------------------------------------------------------------
/packages/Npgsql.2.1.3/lib/net35/zh-CN/Npgsql.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/uzbekdev1/DapperRepository/c871ea58a4a61f717594bd2242e99409ea0d3cb7/packages/Npgsql.2.1.3/lib/net35/zh-CN/Npgsql.resources.dll
--------------------------------------------------------------------------------
/packages/Npgsql.2.1.3/lib/net40/Mono.Security.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/uzbekdev1/DapperRepository/c871ea58a4a61f717594bd2242e99409ea0d3cb7/packages/Npgsql.2.1.3/lib/net40/Mono.Security.dll
--------------------------------------------------------------------------------
/packages/Npgsql.2.1.3/lib/net40/Npgsql.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/uzbekdev1/DapperRepository/c871ea58a4a61f717594bd2242e99409ea0d3cb7/packages/Npgsql.2.1.3/lib/net40/Npgsql.dll
--------------------------------------------------------------------------------
/packages/Npgsql.2.1.3/lib/net40/de/Npgsql.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/uzbekdev1/DapperRepository/c871ea58a4a61f717594bd2242e99409ea0d3cb7/packages/Npgsql.2.1.3/lib/net40/de/Npgsql.resources.dll
--------------------------------------------------------------------------------
/packages/Npgsql.2.1.3/lib/net40/es/Npgsql.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/uzbekdev1/DapperRepository/c871ea58a4a61f717594bd2242e99409ea0d3cb7/packages/Npgsql.2.1.3/lib/net40/es/Npgsql.resources.dll
--------------------------------------------------------------------------------
/packages/Npgsql.2.1.3/lib/net40/fi/Npgsql.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/uzbekdev1/DapperRepository/c871ea58a4a61f717594bd2242e99409ea0d3cb7/packages/Npgsql.2.1.3/lib/net40/fi/Npgsql.resources.dll
--------------------------------------------------------------------------------
/packages/Npgsql.2.1.3/lib/net40/fr/Npgsql.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/uzbekdev1/DapperRepository/c871ea58a4a61f717594bd2242e99409ea0d3cb7/packages/Npgsql.2.1.3/lib/net40/fr/Npgsql.resources.dll
--------------------------------------------------------------------------------
/packages/Npgsql.2.1.3/lib/net40/ja/Npgsql.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/uzbekdev1/DapperRepository/c871ea58a4a61f717594bd2242e99409ea0d3cb7/packages/Npgsql.2.1.3/lib/net40/ja/Npgsql.resources.dll
--------------------------------------------------------------------------------
/packages/Npgsql.2.1.3/lib/net40/zh-CN/Npgsql.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/uzbekdev1/DapperRepository/c871ea58a4a61f717594bd2242e99409ea0d3cb7/packages/Npgsql.2.1.3/lib/net40/zh-CN/Npgsql.resources.dll
--------------------------------------------------------------------------------
/packages/Npgsql.2.1.3/lib/net45/Mono.Security.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/uzbekdev1/DapperRepository/c871ea58a4a61f717594bd2242e99409ea0d3cb7/packages/Npgsql.2.1.3/lib/net45/Mono.Security.dll
--------------------------------------------------------------------------------
/packages/Npgsql.2.1.3/lib/net45/Npgsql.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/uzbekdev1/DapperRepository/c871ea58a4a61f717594bd2242e99409ea0d3cb7/packages/Npgsql.2.1.3/lib/net45/Npgsql.dll
--------------------------------------------------------------------------------
/packages/Npgsql.2.1.3/lib/net45/de/Npgsql.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/uzbekdev1/DapperRepository/c871ea58a4a61f717594bd2242e99409ea0d3cb7/packages/Npgsql.2.1.3/lib/net45/de/Npgsql.resources.dll
--------------------------------------------------------------------------------
/packages/Npgsql.2.1.3/lib/net45/es/Npgsql.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/uzbekdev1/DapperRepository/c871ea58a4a61f717594bd2242e99409ea0d3cb7/packages/Npgsql.2.1.3/lib/net45/es/Npgsql.resources.dll
--------------------------------------------------------------------------------
/packages/Npgsql.2.1.3/lib/net45/fi/Npgsql.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/uzbekdev1/DapperRepository/c871ea58a4a61f717594bd2242e99409ea0d3cb7/packages/Npgsql.2.1.3/lib/net45/fi/Npgsql.resources.dll
--------------------------------------------------------------------------------
/packages/Npgsql.2.1.3/lib/net45/fr/Npgsql.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/uzbekdev1/DapperRepository/c871ea58a4a61f717594bd2242e99409ea0d3cb7/packages/Npgsql.2.1.3/lib/net45/fr/Npgsql.resources.dll
--------------------------------------------------------------------------------
/packages/Npgsql.2.1.3/lib/net45/ja/Npgsql.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/uzbekdev1/DapperRepository/c871ea58a4a61f717594bd2242e99409ea0d3cb7/packages/Npgsql.2.1.3/lib/net45/ja/Npgsql.resources.dll
--------------------------------------------------------------------------------
/packages/Npgsql.2.1.3/lib/net45/zh-CN/Npgsql.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/uzbekdev1/DapperRepository/c871ea58a4a61f717594bd2242e99409ea0d3cb7/packages/Npgsql.2.1.3/lib/net45/zh-CN/Npgsql.resources.dll
--------------------------------------------------------------------------------
/packages/System.Data.SQLite.Core.1.0.93.0/System.Data.SQLite.Core.1.0.93.0.nupkg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/uzbekdev1/DapperRepository/c871ea58a4a61f717594bd2242e99409ea0d3cb7/packages/System.Data.SQLite.Core.1.0.93.0/System.Data.SQLite.Core.1.0.93.0.nupkg
--------------------------------------------------------------------------------
/packages/System.Data.SQLite.Core.1.0.93.0/content/net20/x86/SQLite.Interop.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/uzbekdev1/DapperRepository/c871ea58a4a61f717594bd2242e99409ea0d3cb7/packages/System.Data.SQLite.Core.1.0.93.0/content/net20/x86/SQLite.Interop.dll
--------------------------------------------------------------------------------
/packages/System.Data.SQLite.Core.1.0.93.0/content/net40/x86/SQLite.Interop.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/uzbekdev1/DapperRepository/c871ea58a4a61f717594bd2242e99409ea0d3cb7/packages/System.Data.SQLite.Core.1.0.93.0/content/net40/x86/SQLite.Interop.dll
--------------------------------------------------------------------------------
/packages/System.Data.SQLite.Core.1.0.93.0/content/net45/x86/SQLite.Interop.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/uzbekdev1/DapperRepository/c871ea58a4a61f717594bd2242e99409ea0d3cb7/packages/System.Data.SQLite.Core.1.0.93.0/content/net45/x86/SQLite.Interop.dll
--------------------------------------------------------------------------------
/packages/System.Data.SQLite.Core.1.0.93.0/content/net451/x86/SQLite.Interop.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/uzbekdev1/DapperRepository/c871ea58a4a61f717594bd2242e99409ea0d3cb7/packages/System.Data.SQLite.Core.1.0.93.0/content/net451/x86/SQLite.Interop.dll
--------------------------------------------------------------------------------
/packages/System.Data.SQLite.Core.1.0.93.0/lib/net20/System.Data.SQLite.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/uzbekdev1/DapperRepository/c871ea58a4a61f717594bd2242e99409ea0d3cb7/packages/System.Data.SQLite.Core.1.0.93.0/lib/net20/System.Data.SQLite.dll
--------------------------------------------------------------------------------
/packages/System.Data.SQLite.Core.1.0.93.0/lib/net40/System.Data.SQLite.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/uzbekdev1/DapperRepository/c871ea58a4a61f717594bd2242e99409ea0d3cb7/packages/System.Data.SQLite.Core.1.0.93.0/lib/net40/System.Data.SQLite.dll
--------------------------------------------------------------------------------
/packages/System.Data.SQLite.Core.1.0.93.0/lib/net45/System.Data.SQLite.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/uzbekdev1/DapperRepository/c871ea58a4a61f717594bd2242e99409ea0d3cb7/packages/System.Data.SQLite.Core.1.0.93.0/lib/net45/System.Data.SQLite.dll
--------------------------------------------------------------------------------
/packages/System.Data.SQLite.Core.1.0.93.0/lib/net451/System.Data.SQLite.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/uzbekdev1/DapperRepository/c871ea58a4a61f717594bd2242e99409ea0d3cb7/packages/System.Data.SQLite.Core.1.0.93.0/lib/net451/System.Data.SQLite.dll
--------------------------------------------------------------------------------
/packages/System.Data.SQLite.Core.1.0.93.0/tools/net20/install.ps1:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | #
3 | # install.ps1 --
4 | #
5 | # Written by Joe Mistachkin.
6 | # Released to the public domain, use at your own risk!
7 | #
8 | ###############################################################################
9 |
10 | param($installPath, $toolsPath, $package, $project)
11 |
12 | $platformNames = "x86", "x64"
13 | $fileName = "SQLite.Interop.dll"
14 | $propertyName = "CopyToOutputDirectory"
15 |
16 | foreach($platformName in $platformNames) {
17 | $folder = $project.ProjectItems.Item($platformName)
18 |
19 | if ($folder -eq $null) {
20 | continue
21 | }
22 |
23 | $item = $folder.ProjectItems.Item($fileName)
24 |
25 | if ($item -eq $null) {
26 | continue
27 | }
28 |
29 | $property = $item.Properties.Item($propertyName)
30 |
31 | if ($property -eq $null) {
32 | continue
33 | }
34 |
35 | $property.Value = 1
36 | }
37 |
--------------------------------------------------------------------------------
/packages/System.Data.SQLite.Core.1.0.93.0/tools/net40/install.ps1:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | #
3 | # install.ps1 --
4 | #
5 | # Written by Joe Mistachkin.
6 | # Released to the public domain, use at your own risk!
7 | #
8 | ###############################################################################
9 |
10 | param($installPath, $toolsPath, $package, $project)
11 |
12 | $platformNames = "x86", "x64"
13 | $fileName = "SQLite.Interop.dll"
14 | $propertyName = "CopyToOutputDirectory"
15 |
16 | foreach($platformName in $platformNames) {
17 | $folder = $project.ProjectItems.Item($platformName)
18 |
19 | if ($folder -eq $null) {
20 | continue
21 | }
22 |
23 | $item = $folder.ProjectItems.Item($fileName)
24 |
25 | if ($item -eq $null) {
26 | continue
27 | }
28 |
29 | $property = $item.Properties.Item($propertyName)
30 |
31 | if ($property -eq $null) {
32 | continue
33 | }
34 |
35 | $property.Value = 1
36 | }
37 |
--------------------------------------------------------------------------------
/packages/System.Data.SQLite.Core.1.0.93.0/tools/net45/install.ps1:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | #
3 | # install.ps1 --
4 | #
5 | # Written by Joe Mistachkin.
6 | # Released to the public domain, use at your own risk!
7 | #
8 | ###############################################################################
9 |
10 | param($installPath, $toolsPath, $package, $project)
11 |
12 | $platformNames = "x86", "x64"
13 | $fileName = "SQLite.Interop.dll"
14 | $propertyName = "CopyToOutputDirectory"
15 |
16 | foreach($platformName in $platformNames) {
17 | $folder = $project.ProjectItems.Item($platformName)
18 |
19 | if ($folder -eq $null) {
20 | continue
21 | }
22 |
23 | $item = $folder.ProjectItems.Item($fileName)
24 |
25 | if ($item -eq $null) {
26 | continue
27 | }
28 |
29 | $property = $item.Properties.Item($propertyName)
30 |
31 | if ($property -eq $null) {
32 | continue
33 | }
34 |
35 | $property.Value = 1
36 | }
37 |
--------------------------------------------------------------------------------
/packages/System.Data.SQLite.Core.1.0.93.0/tools/net451/install.ps1:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | #
3 | # install.ps1 --
4 | #
5 | # Written by Joe Mistachkin.
6 | # Released to the public domain, use at your own risk!
7 | #
8 | ###############################################################################
9 |
10 | param($installPath, $toolsPath, $package, $project)
11 |
12 | $platformNames = "x86", "x64"
13 | $fileName = "SQLite.Interop.dll"
14 | $propertyName = "CopyToOutputDirectory"
15 |
16 | foreach($platformName in $platformNames) {
17 | $folder = $project.ProjectItems.Item($platformName)
18 |
19 | if ($folder -eq $null) {
20 | continue
21 | }
22 |
23 | $item = $folder.ProjectItems.Item($fileName)
24 |
25 | if ($item -eq $null) {
26 | continue
27 | }
28 |
29 | $property = $item.Properties.Item($propertyName)
30 |
31 | if ($property -eq $null) {
32 | continue
33 | }
34 |
35 | $property.Value = 1
36 | }
37 |
--------------------------------------------------------------------------------
/packages/repositories.config:
--------------------------------------------------------------------------------
1 |
2 |
3 | ]