├── .gitattributes
├── .gitignore
├── LICENSE
├── README.md
├── TableDependency.SqlClient.Test.Client.Core
├── App.config
├── Models
│ ├── Category.cs
│ ├── CategorysEnum.cs
│ └── Product.cs
├── Program.cs
└── TableDependency.SqlClient.Test.Client.Core.csproj
├── TableDependency.SqlClient.Test.Client.Framework
├── App.config
├── Models
│ ├── Category.cs
│ ├── CategorysEnum.cs
│ └── Product.cs
├── Program.cs
├── Properties
│ └── AssemblyInfo.cs
└── TableDependency.SqlClient.Test.Client.Framework.csproj
├── TableDependency.SqlClient.Test.LoadTests.Listener
├── App.config
├── LoadTest.cs
├── Program.cs
├── Properties
│ └── AssemblyInfo.cs
└── TableDependency.SqlClient.Test.LoadTests.Listener.csproj
├── TableDependency.SqlClient.Test.LoadTests.Writer1
├── App.config
├── Program.cs
├── Properties
│ └── AssemblyInfo.cs
└── TableDependency.SqlClient.Test.LoadTests.Writer1.csproj
├── TableDependency.SqlClient.Test.LoadTests.Writer2
├── App.config
├── Program.cs
├── Properties
│ └── AssemblyInfo.cs
└── TableDependency.SqlClient.Test.LoadTests.Writer2.csproj
├── TableDependency.SqlClient.Test
├── App.config
├── Base
│ └── SqlTableDependencyBaseTest.cs
├── BigIntDecimalAndFloatTypesTest.cs
├── BinaryBitCharVarbinaryTypesTest.cs
├── CancellationTokenTest.cs
├── ComputedColumnTest.cs
├── CultureInfoTest.cs
├── DataAnnotationNotMappedTest1.cs
├── DataAnnotationNotMappedTest2.cs
├── DataAnnotationTest01.cs
├── DataAnnotationTest02.cs
├── DataAnnotationTest03.cs
├── DataAnnotationTest04.cs
├── DataAnnotationTest05.cs
├── DataAnnotationTest06.cs
├── DataAnnotationTest07.cs
├── DataAnnotationTest08.cs
├── DataAnnotationTest09.cs
├── DataAnnotationTest10.cs
├── DatabaseObjectAutoCleanUpTest.cs
├── DateTypeTest.cs
├── EndpointsStatusTest.cs
├── EnumTestSqlServer1.cs
├── EnumTestSqlServer2.cs
├── EventForAllColumnsTest.cs
├── EventForSpecificColumnsTest.cs
├── GuidSmallMoneyTypesTest.cs
├── Inheritance
│ └── SqlTableDependencyTest.cs
├── Issue146Test.cs
├── Issue177Test.cs
├── Issue18Test.cs
├── Issue27Test.cs
├── Issue53Test.cs
├── Issue55Test.cs
├── Issue65Test.cs
├── Issue66Test.cs
├── MargeTest.cs
├── MassiveChangesInSingleCommandTest.cs
├── MassiveChangesTest.cs
├── ModelWithAnnotationUsedWithCunstructorParameterTest.cs
├── Models
│ ├── Category.cs
│ ├── ConversationEndpoint.cs
│ └── Product.cs
├── MultiDmlOperationsOrderTest.cs
├── MultiDmlOperationsTest.cs
├── NVarcharMaxAndVarcharMaxTypeTest1.cs
├── NVarcharMaxAndVarcharMaxTypeTest2.cs
├── NoChangesDuringFirstThreeMinutesTest1.cs
├── NoChangesDuringFirstThreeMinutesTest2.cs
├── NoMapperUseTest.cs
├── NoProblemDurignCommandTimeoutForNoMessagesTest.cs
├── NoTableAndColumnDefinitionsTest.cs
├── NotificationOnlyWhenNewValueIsDifferentFromOldValueTest.cs
├── PreliminaryTest.cs
├── Properties
│ └── AssemblyInfo.cs
├── RealTypesTest.cs
├── RowVersionTypeTest.cs
├── Scripts
│ ├── CleanUpEndpoints.sql
│ ├── CompatibilityLevel.sql
│ ├── DropMessageTypes.sql
│ ├── Monolog.sql
│ └── QueryEndpoints.sql
├── StatusLostConnectionTest.cs
├── StatusTest.cs
├── StopAndStartTest.cs
├── TableDependency.SqlClient.Test.csproj
├── TableNameFromModelClassNameAndUpdateOfTest.cs
├── TableWithSpacesTest.cs
├── TaskCancellationTest.cs
├── TransactionTest1.cs
├── TransactionTest2.cs
├── TransactionTest3.cs
├── TransactionTest4.cs
├── TriggerTypeTest.cs
├── TwoIntancesTest.cs
├── UpdateOfUsingLambaTest.cs
├── UseSchemaOtherThanDBOTest.cs
├── UseSchemaOtherThanDBOTest2.cs
├── WhereCustomFilterTest.cs
├── WhereDateTimeTest.cs
├── WhereEqualToTest.cs
├── WhereFilterUsingSchemaTest.cs
├── WhereMultipleConditionsTest.cs
├── WhereUnitTestBinaryExpressionOnBothSides.cs
├── WhereUnitTestContains.cs
├── WhereUnitTestInnerProperty.cs
├── WhereUnitTestMapper.cs
├── WhereUnitTestMethodsChain.cs
├── WhereUnitTestMoreCondition.cs
├── WhereUnitTestParameterInt.cs
├── WhereUnitTestParameterString.cs
├── WhereUnitTestStartsWith.cs
├── WhereUnitTestSubstring.cs
├── WhereUnitTestToLower.cs
├── WhereUnitTestToString.cs
├── WhereUnitTestToUpper.cs
├── WhereUnitTestTrim.cs
├── WhereWithDataAnnotationTest.cs
├── WhereWithMapperTest.cs
├── XmlAsStringSqlServerTest.cs
├── XmlNVarcharMaxAndVarcharMaxType.cs
├── XmlNVarcharMaxAndVarcharMaxType2.cs
└── packages.config
├── TableDependency.SqlClient
├── Base
│ ├── Abstracts
│ │ ├── IModelToTableMapper.cs
│ │ ├── ITableDependency.cs
│ │ ├── ITableDependencyFilter.cs
│ │ └── IUpdateOfModel.cs
│ ├── Delegates
│ │ ├── ChangedEventHandler.cs
│ │ ├── ErrorEventHandler.cs
│ │ └── StatusEventHandler.cs
│ ├── Enums
│ │ ├── ChangeType.cs
│ │ ├── DmlTriggerType.cs
│ │ ├── SqlTypeEnum.cs
│ │ └── TableDependencyStatus.cs
│ ├── EventArgs
│ │ ├── BaseEventArgs.cs
│ │ ├── ErrorEventArgs.cs
│ │ ├── RecordChangedEventArgs.cs
│ │ └── StatusChangedEventArgs.cs
│ ├── Exceptions
│ │ ├── ColumnTypeNotSupportedException.cs
│ │ ├── DmlTriggerTypeException.cs
│ │ ├── InitializedStoppedException.cs
│ │ ├── InitializingStoppedException.cs
│ │ ├── InvalidConnectionStringException.cs
│ │ ├── MessageMisalignedException.cs
│ │ ├── ModelToTableMapperException.cs
│ │ ├── NoColumnsException.cs
│ │ ├── NoMatchBetweenModelAndTableColumn.cs
│ │ ├── NoMatchBetweenModelAndTableColumns.cs
│ │ ├── NoSubscriberException.cs
│ │ ├── NotExistingTableException.cs
│ │ ├── TableDependencyException.cs
│ │ ├── TableWithNoColumnsException.cs
│ │ ├── UpdateOfException.cs
│ │ ├── UpdateOfModelException.cs
│ │ └── WatchDogTimeOutException.cs
│ ├── Messages
│ │ ├── Message.cs
│ │ ├── MessagesBag.cs
│ │ └── MessagesBagStatus.cs
│ ├── ModelToTableMapper.cs
│ ├── TableDependency.cs
│ ├── UpdateOfModel.cs
│ └── Utilities
│ │ ├── CastHelper.cs
│ │ ├── EnumUtil.cs
│ │ ├── ModelToTableMapperHelper.cs
│ │ ├── ModelUtil.cs
│ │ ├── Separator.cs
│ │ └── TableColumnInfo.cs
├── Enumerations
│ ├── ConversationEndpointState.cs
│ ├── SqlServerRequiredPermission.cs
│ └── SqlServerVersion.cs
├── EventArgs
│ └── SqlRecordChangedEventArgs.cs
├── Exceptions
│ ├── DbObjectsWithSameNameException.cs
│ ├── ImpossibleOpenSqlConnectionException.cs
│ ├── QueueContainingErrorMessageException.cs
│ ├── SanitizeVariableNameException.cs
│ ├── ServiceBrokerConversationHandlerInvalidException.cs
│ ├── ServiceBrokerEndDialogException.cs
│ ├── ServiceBrokerErrorMessageException.cs
│ ├── ServiceBrokerNotEnabledException.cs
│ ├── SqlServerVersionNotSupportedException.cs
│ ├── UserWithMissingPermissionException.cs
│ └── UserWithNoPermissionException.cs
├── Extensions
│ ├── SqlDataReaderExtension.cs
│ ├── StringExtension.cs
│ └── TaskExtensions.cs
├── Messages
│ └── SqlMessageTypes.cs
├── Resources
│ ├── SqlQueries.cs
│ └── SqlScripts.cs
├── SqlTableDependency.cs
├── TableDependency.SqlClient.csproj
├── Utilities
│ ├── PrivilegesTable.cs
│ └── SerializeSqlDataReader.cs
└── Where
│ ├── Helpers
│ └── ParameterHelper.cs
│ └── SqlTableDependencyFilter.cs
├── TableDependency.sln
└── img
├── 2018-04-20 at 10-40-04.png
├── 2018-04-20 at 11-51-49.png
├── DbObjects-min.png
├── No.png
├── NoSmall.png
├── NuGetPackageFilter.png
├── NuGetSqlTableDependency.png
├── Ok.png
├── Receive_notifications_from_Sql_Server_database.gif
├── Workflow-min.png
├── YesSmall.png
├── icons-01.svg
├── if_exclamation-red_46014.png
├── logotype-a-06.svg
├── logotype-b-11.svg
├── rsz_notify.png
├── rsz_table.jpg
└── rsz_table.png
/.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
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | Aug%2019%2C%202018## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 |
10 | # User-specific files (MonoDevelop/Xamarin Studio)
11 | *.userprefs
12 |
13 | # Build results
14 | [Dd]ebug/
15 | [Dd]ebugPublic/
16 | [Rr]elease/
17 | [Rr]eleases/
18 | x64/
19 | x86/
20 | build/
21 | bld/
22 | [Bb]in/
23 | [Oo]bj/
24 |
25 |
26 | # Visual Studio 2015 cache/options directory
27 | .vs/
28 |
29 | # MSTest test Results
30 | [Tt]est[Rr]esult*/
31 | [Bb]uild[Ll]og.*
32 |
33 | # NUNIT
34 | *.VisualState.xml
35 | TestResult.xml
36 |
37 | #Jekyll SEO plugin
38 | _config.yml
39 |
40 | # Build Results of an ATL Project
41 | [Dd]ebugPS/
42 | [Rr]eleasePS/
43 | dlldata.c
44 |
45 | # DNX
46 | project.lock.json
47 | artifacts/
48 |
49 | *_i.c
50 | *_p.c
51 | *_i.h
52 | *.ilk
53 | *.meta
54 | *.obj
55 | *.pch
56 | *.pdb
57 | *.pgc
58 | *.pgd
59 | *.rsp
60 | *.sbr
61 | *.tlb
62 | *.tli
63 | *.tlh
64 | *.tmp
65 | *.tmp_proj
66 | *.log
67 | *.vspscc
68 | *.vssscc
69 | .builds
70 | *.pidb
71 | *.svclog
72 | *.scc
73 |
74 | # Chutzpah Test files
75 | _Chutzpah*
76 |
77 | # Visual C++ cache files
78 | ipch/
79 | *.aps
80 | *.ncb
81 | *.opensdf
82 | *.sdf
83 | *.cachefile
84 |
85 | # Visual Studio profiler
86 | *.psess
87 | *.vsp
88 | *.vspx
89 |
90 | # TFS 2012 Local Workspace
91 | $tf/
92 |
93 | # Guidance Automation Toolkit
94 | *.gpState
95 |
96 | # ReSharper is a .NET coding add-in
97 | _ReSharper*/
98 | *.[Rr]e[Ss]harper
99 | *.DotSettings.user
100 |
101 | # JustCode is a .NET coding add-in
102 | .JustCode
103 |
104 | # TeamCity is a build add-in
105 | _TeamCity*
106 |
107 | # DotCover is a Code Coverage Tool
108 | *.dotCover
109 |
110 | # NCrunch
111 | _NCrunch_*
112 | .*crunch*.local.xml
113 |
114 | # MightyMoose
115 | *.mm.*
116 | AutoTest.Net/
117 |
118 | # Web workbench (sass)
119 | .sass-cache/
120 |
121 | # Installshield output folder
122 | [Ee]xpress/
123 |
124 | # DocProject is a documentation generator add-in
125 | DocProject/buildhelp/
126 | DocProject/Help/*.HxT
127 | DocProject/Help/*.HxC
128 | DocProject/Help/*.hhc
129 | DocProject/Help/*.hhk
130 | DocProject/Help/*.hhp
131 | DocProject/Help/Html2
132 | DocProject/Help/html
133 |
134 | # Click-Once directory
135 | publish/
136 |
137 | # Publish Web Output
138 | *.[Pp]ublish.xml
139 | *.azurePubxml
140 | ## TODO: Comment the next line if you want to checkin your
141 | ## web deploy settings but do note that will include unencrypted
142 | ## passwords
143 | #*.pubxml
144 |
145 | *.publishproj
146 |
147 | # NuGet Packages
148 | *.nupkg
149 | # The packages folder can be ignored because of Package Restore
150 | **/packages/*
151 | # except build/, which is used as an MSBuild target.
152 | !**/packages/build/
153 | # Uncomment if necessary however generally it will be regenerated when needed
154 | #!**/packages/repositories.config
155 |
156 | # Windows Azure Build Output
157 | csx/
158 | *.build.csdef
159 |
160 | # Windows Store app package directory
161 | AppPackages/
162 |
163 | # Visual Studio cache files
164 | # files ending in .cache can be ignored
165 | *.[Cc]ache
166 | # but keep track of directories ending in .cache
167 | !*.[Cc]ache/
168 |
169 | # Others
170 | ClientBin/
171 | [Ss]tyle[Cc]op.*
172 | ~$*
173 | *~
174 | *.dbmdl
175 | *.dbproj.schemaview
176 | *.pfx
177 | *.publishsettings
178 | node_modules/
179 | orleans.codegen.cs
180 |
181 | # RIA/Silverlight projects
182 | Generated_Code/
183 |
184 | # Backup & report files from converting an old project file
185 | # to a newer Visual Studio version. Backup files are not needed,
186 | # because we have git ;-)
187 | _UpgradeReport_Files/
188 | Backup*/
189 | UpgradeLog*.XML
190 | UpgradeLog*.htm
191 |
192 | # SQL Server files
193 | *.mdf
194 | *.ldf
195 |
196 | # Business Intelligence projects
197 | *.rdl.data
198 | *.bim.layout
199 | *.bim_*.settings
200 |
201 | # Microsoft Fakes
202 | FakesAssemblies/
203 |
204 | # Node.js Tools for Visual Studio
205 | .ntvs_analysis.dat
206 |
207 | # Visual Studio 6 build log
208 | *.plg
209 |
210 | # Visual Studio 6 workspace options file
211 | *.opt
212 |
213 | # LightSwitch generated files
214 | GeneratedArtifacts/
215 | _Pvt_Extensions/
216 | ModelManifest.xml
217 |
218 | # Exclude files or folders
219 | NuPkg/**
220 | /img/**
221 | /img/
222 | LICENSE
223 | README.md
224 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017-2018 Christian Del Bianco. All rights reserved.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sub-license, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE
22 |
--------------------------------------------------------------------------------
/TableDependency.SqlClient.Test.Client.Core/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/TableDependency.SqlClient.Test.Client.Core/Models/Category.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace TableDependency.SqlClient.Test.Client.Core.Models
4 | {
5 | public class Category
6 | {
7 | public int Id { get; set; }
8 | public string Name { get; set; }
9 |
10 | public IList Products { get; set; } = new List();
11 | }
12 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient.Test.Client.Core/Models/CategorysEnum.cs:
--------------------------------------------------------------------------------
1 | namespace TableDependency.SqlClient.Test.Client.Core.Models
2 | {
3 | public enum CategorysEnum
4 | {
5 | Food = 1,
6 | Drink = 2,
7 | Dessert = 3
8 | }
9 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient.Test.Client.Core/Models/Product.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace TableDependency.SqlClient.Test.Client.Core.Models
4 | {
5 | public class Product
6 | {
7 | public int Quantity { get; set; }
8 | public int Id { get; set; }
9 | public int CategoryId { get; set; }
10 | public string Name { get; set; }
11 | public DateTime Expiring { get; set; }
12 | public decimal Price { get; set; }
13 | }
14 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient.Test.Client.Core/TableDependency.SqlClient.Test.Client.Core.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp2.0
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | ..\..\..\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7\System.Configuration.dll
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/TableDependency.SqlClient.Test.Client.Framework/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/TableDependency.SqlClient.Test.Client.Framework/Models/Category.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace TableDependency.SqlClient.Test.Client.Framework.Models
4 | {
5 | public class Category
6 | {
7 | public int Id { get; set; }
8 | public string Name { get; set; }
9 |
10 | public IList Products { get; set; } = new List();
11 | }
12 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient.Test.Client.Framework/Models/CategorysEnum.cs:
--------------------------------------------------------------------------------
1 | namespace TableDependency.SqlClient.Test.Client.Framework.Models
2 | {
3 | public enum CategorysEnum
4 | {
5 | Food = 1,
6 | Drink = 2,
7 | Dessert = 3
8 | }
9 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient.Test.Client.Framework/Models/Product.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace TableDependency.SqlClient.Test.Client.Framework.Models
4 | {
5 | public class Product
6 | {
7 | public int Id { get; set; }
8 | public int CategoryId { get; set; }
9 | public string Name { get; set; }
10 | public int Quantity { get; set; }
11 | public DateTime Expiring { get; set; }
12 | public decimal Price { get; set; }
13 | }
14 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient.Test.Client.Framework/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("TableDependency.SqlClient.Test.Client.Framework")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("TableDependency.SqlClient.Test.Client.Framework")]
13 | [assembly: AssemblyCopyright("Copyright © 2018")]
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("36ef3309-9552-412c-83b0-cfc19f77bea1")]
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 |
--------------------------------------------------------------------------------
/TableDependency.SqlClient.Test.Client.Framework/TableDependency.SqlClient.Test.Client.Framework.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {36EF3309-9552-412C-83B0-CFC19F77BEA1}
8 | Exe
9 | TableDependency.SqlClient.Test.Client.Framework
10 | TableDependency.SqlClient.Test.Client.Framework
11 | v4.5.1
12 | 512
13 | true
14 |
15 |
16 |
17 | AnyCPU
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 |
26 |
27 | AnyCPU
28 | pdbonly
29 | true
30 | bin\Release\
31 | TRACE
32 | prompt
33 | 4
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 | {8df673d9-f985-4628-95d6-14f10ff55eee}
50 | TableDependency.SqlClient
51 |
52 |
53 |
54 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/TableDependency.SqlClient.Test.LoadTests.Listener/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/TableDependency.SqlClient.Test.LoadTests.Listener/LoadTest.cs:
--------------------------------------------------------------------------------
1 | namespace TableDependency.SqlClient.Test.LoadTests.Listener
2 | {
3 | public class LoadTest
4 | {
5 | public int Id { get; set; }
6 | public string FirstName { get; set; }
7 | public string SecondName { get; set; }
8 | }
9 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient.Test.LoadTests.Listener/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Configuration;
3 | using System.Data.SqlClient;
4 |
5 | using TableDependency.SqlClient.Base.Enums;
6 | using TableDependency.SqlClient.Base.EventArgs;
7 |
8 | namespace TableDependency.SqlClient.Test.LoadTests.Listener
9 | {
10 | internal class Program
11 | {
12 | private static int _insertCounter;
13 | private static int _updateCounter;
14 | private static int _deleteCounter;
15 |
16 | private static void DropAndCreateTable(string connectionString)
17 | {
18 | using (var sqlConnection = new SqlConnection(connectionString))
19 | {
20 | sqlConnection.Open();
21 | using (var sqlCommand = sqlConnection.CreateCommand())
22 | {
23 | sqlCommand.CommandText = "DROP TABLE [dbo].[LoadTest]";
24 | sqlCommand.ExecuteNonQuery();
25 | sqlCommand.CommandText = "CREATE TABLE [LoadTest] ([Id] [int], [FirstName] nvarchar(50), [SecondName] nvarchar(50))";
26 | sqlCommand.ExecuteNonQuery();
27 | }
28 | }
29 | }
30 |
31 | private static void Main()
32 | {
33 | var connectionString = ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString;
34 | DropAndCreateTable(connectionString);
35 |
36 | using (var tableDependency = new SqlTableDependency(connectionString))
37 | {
38 | tableDependency.OnChanged += TableDependency_Changed;
39 | tableDependency.OnError += TableDependency_OnError;
40 |
41 | tableDependency.Start();
42 | Console.WriteLine("Waiting for receiving notifications...");
43 | Console.WriteLine("Press a key to stop");
44 | Console.ReadKey();
45 |
46 | tableDependency.Stop();
47 | }
48 | }
49 |
50 | private static void TableDependency_OnError(object sender, ErrorEventArgs e)
51 | {
52 | Console.WriteLine(e.Error.Message);
53 | }
54 |
55 | private static void TableDependency_Changed(object sender, RecordChangedEventArgs e)
56 | {
57 | Console.WriteLine(Environment.NewLine);
58 |
59 | if (e.ChangeType == ChangeType.Insert) _insertCounter++;
60 | if (e.ChangeType == ChangeType.Update) _updateCounter++;
61 | if (e.ChangeType == ChangeType.Delete) _deleteCounter++;
62 |
63 | var changedEntity = e.Entity;
64 | Console.WriteLine("DML operation: " + e.ChangeType);
65 | Console.WriteLine("Id: " + changedEntity.Id);
66 | Console.WriteLine("FirstName: " + changedEntity.FirstName);
67 | Console.WriteLine("SecondName: " + changedEntity.SecondName);
68 | Console.WriteLine("---------------------------------------------");
69 | Console.WriteLine("Insert: " + _insertCounter);
70 | Console.WriteLine("Update: " + _updateCounter);
71 | Console.WriteLine("Delete: " + _deleteCounter);
72 | }
73 | }
74 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient.Test.LoadTests.Listener/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("TableDependency.SqlClient.Test.LoadTests.Listener")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("TableDependency.SqlClient.Test.LoadTests.Listener")]
13 | [assembly: AssemblyCopyright("Copyright © 2018")]
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("f0b96d56-82e9-4d42-b7a5-4cde42cb587a")]
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 |
--------------------------------------------------------------------------------
/TableDependency.SqlClient.Test.LoadTests.Listener/TableDependency.SqlClient.Test.LoadTests.Listener.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {F0B96D56-82E9-4D42-B7A5-4CDE42CB587A}
8 | Exe
9 | TableDependency.SqlClient.Test.LoadTests.Listener
10 | TableDependency.SqlClient.Test.LoadTests.Listener
11 | v4.5.1
12 | 512
13 | true
14 |
15 |
16 |
17 | AnyCPU
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 |
26 |
27 | AnyCPU
28 | pdbonly
29 | true
30 | bin\Release\
31 | TRACE
32 | prompt
33 | 4
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 | {110ff47e-d483-4b69-9eca-d784392c6a44}
57 | TableDependency.SqlClient
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/TableDependency.SqlClient.Test.LoadTests.Writer1/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/TableDependency.SqlClient.Test.LoadTests.Writer1/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Configuration;
3 | using System.Data.SqlClient;
4 |
5 | namespace TableDependency.SqlClient.Test.LoadTests.Writer1
6 | {
7 | public class Program
8 | {
9 | public static void Main(string[] args)
10 | {
11 | int deletedCnt = 0;
12 | int insertedCnt = 0;
13 | int updatedCnt = 0;
14 | int total = 999999;
15 | int index = 1;
16 | int i = 1;
17 | var connectionString = ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString;
18 |
19 | Console.Title = new string('*', 10) + " SQL ServerDB Writer 1 " + new string('*', 10);
20 | System.Threading.Thread.Sleep(4000);
21 |
22 | using (var sqlConnection = new SqlConnection(connectionString))
23 | {
24 | sqlConnection.Open();
25 | using (var sqlCommand = sqlConnection.CreateCommand())
26 | {
27 | while (index < total)
28 | {
29 | switch (i)
30 | {
31 | case 1:
32 | sqlCommand.CommandText = "INSERT INTO [LoadTest] ([Id], [FirstName], [SecondName]) VALUES (1, 'mannaggia', 'alla puttana')";
33 | if (sqlCommand.ExecuteNonQuery() > 0) insertedCnt++;
34 | i++;
35 | break;
36 |
37 | case 2:
38 | sqlCommand.CommandText = "UPDATE [LoadTest] SET [FirstName] = 'cazzarola', [SecondName] = '" + Guid.NewGuid() + "' WHERE [Id] = 1";
39 | if (sqlCommand.ExecuteNonQuery() > 0) updatedCnt++;
40 | i++;
41 | break;
42 |
43 | case 3:
44 | sqlCommand.CommandText = "DELETE FROM [LoadTest] WHERE [Id] = 1";
45 | if (sqlCommand.ExecuteNonQuery() > 0) deletedCnt++;
46 | i = 1;
47 | break;
48 | }
49 |
50 | Console.WriteLine("Writer 1 executed: " + Environment.NewLine + sqlCommand.CommandText);
51 | System.Threading.Thread.Sleep(50);
52 | index++;
53 | }
54 | }
55 | }
56 |
57 | Console.WriteLine("INSERT counter: " + insertedCnt);
58 | Console.WriteLine("UPDATE counter: " + updatedCnt);
59 | Console.WriteLine("DELETE counter: " + deletedCnt);
60 |
61 | Console.WriteLine(Environment.NewLine + "Press a key to exit");
62 | Console.ReadKey();
63 | }
64 | }
65 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient.Test.LoadTests.Writer1/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("TableDependency.SqlClient.Test.LoadTests.Writer1")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("TableDependency.SqlClient.Test.LoadTests.Writer1")]
13 | [assembly: AssemblyCopyright("Copyright © 2018")]
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("6a4bbe77-c4b7-4a81-9e2a-d2de4e601268")]
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 |
--------------------------------------------------------------------------------
/TableDependency.SqlClient.Test.LoadTests.Writer1/TableDependency.SqlClient.Test.LoadTests.Writer1.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {6A4BBE77-C4B7-4A81-9E2A-D2DE4E601268}
8 | Exe
9 | TableDependency.SqlClient.Test.LoadTests.Writer1
10 | TableDependency.SqlClient.Test.LoadTests.Writer1
11 | v4.5.1
12 | 512
13 | true
14 |
15 |
16 |
17 | AnyCPU
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 |
26 |
27 | AnyCPU
28 | pdbonly
29 | true
30 | bin\Release\
31 | TRACE
32 | prompt
33 | 4
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/TableDependency.SqlClient.Test.LoadTests.Writer2/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/TableDependency.SqlClient.Test.LoadTests.Writer2/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Configuration;
3 | using System.Data.SqlClient;
4 |
5 | namespace TableDependency.SqlClient.Test.LoadTests.Writer2
6 | {
7 | public class Program
8 | {
9 | public static void Main(string[] args)
10 | {
11 | int deletedCnt = 0;
12 | int insertedCnt = 0;
13 | int updatedCnt = 0;
14 | int total = 7777;
15 | int index = 1;
16 | int i = 1;
17 |
18 | var connectionString = ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString;
19 |
20 | Console.Title = new string('*', 10) + " SQL Server DB Writer 2 " + new string('*', 10);
21 | System.Threading.Thread.Sleep(6000);
22 | using (var sqlConnection = new SqlConnection(connectionString))
23 | {
24 | sqlConnection.Open();
25 | using (var sqlCommand = sqlConnection.CreateCommand())
26 | {
27 | while (index < total)
28 | {
29 | switch (i)
30 | {
31 | case 1:
32 | sqlCommand.CommandText = "INSERT INTO [LoadTest] ([Id], [FirstName], [SecondName]) VALUES (2, 'sono cazzi acidi', 'AAAAS')";
33 | if (sqlCommand.ExecuteNonQuery() > 0) insertedCnt++;
34 | i++;
35 | break;
36 |
37 | case 2:
38 | sqlCommand.CommandText = "UPDATE [LoadTest] SET [FirstName] = 'Guai grossi', [SecondName] = '" + Guid.NewGuid() + "' WHERE [Id] = 2";
39 | if (sqlCommand.ExecuteNonQuery() > 0) updatedCnt++;
40 | i++;
41 | break;
42 |
43 | case 3:
44 | sqlCommand.CommandText = "DELETE FROM [LoadTest] WHERE [Id] = 2";
45 | if (sqlCommand.ExecuteNonQuery() > 0) deletedCnt++;
46 | i = 1;
47 | break;
48 | }
49 |
50 | Console.WriteLine("Writer 2 executed: " + Environment.NewLine + sqlCommand.CommandText);
51 | System.Threading.Thread.Sleep(50);
52 | index++;
53 | }
54 | }
55 | }
56 |
57 | Console.WriteLine("INSERT counter: " + insertedCnt);
58 | Console.WriteLine("UPDATE counter: " + updatedCnt);
59 | Console.WriteLine("DELETE counter: " + deletedCnt);
60 |
61 | Console.WriteLine(Environment.NewLine + "Press a key to exit");
62 | Console.ReadKey();
63 | }
64 | }
65 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient.Test.LoadTests.Writer2/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("TableDependency.SqlClient.Test.LoadTests.Writer2")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("TableDependency.SqlClient.Test.LoadTests.Writer2")]
13 | [assembly: AssemblyCopyright("Copyright © 2018")]
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("ef72470d-79ce-471e-8395-0e9a580e385c")]
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 |
--------------------------------------------------------------------------------
/TableDependency.SqlClient.Test.LoadTests.Writer2/TableDependency.SqlClient.Test.LoadTests.Writer2.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {EF72470D-79CE-471E-8395-0E9A580E385C}
8 | Exe
9 | TableDependency.SqlClient.Test.LoadTests.Writer2
10 | TableDependency.SqlClient.Test.LoadTests.Writer2
11 | v4.5.1
12 | 512
13 | true
14 |
15 |
16 |
17 | AnyCPU
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 |
26 |
27 | AnyCPU
28 | pdbonly
29 | true
30 | bin\Release\
31 | TRACE
32 | prompt
33 | 4
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/TableDependency.SqlClient.Test/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/TableDependency.SqlClient.Test/Issue27Test.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Data.SqlClient;
3 | using System.Threading;
4 |
5 | using Microsoft.VisualStudio.TestTools.UnitTesting;
6 |
7 | namespace TableDependency.SqlClient.Test
8 | {
9 | [TestClass]
10 | public class Issue27Test : Base.SqlTableDependencyBaseTest
11 | {
12 | private class Issue27Model
13 | {
14 | public string Id { get; set; }
15 | public string Message { get; set; }
16 | }
17 |
18 | private static readonly string TableName = typeof(Issue27Model).Name;
19 |
20 | [ClassInitialize]
21 | public static void ClassInitialize(TestContext testContext)
22 | {
23 | using (var sqlConnection = new SqlConnection(ConnectionStringForTestUser))
24 | {
25 | sqlConnection.Open();
26 | using (var sqlCommand = sqlConnection.CreateCommand())
27 | {
28 | sqlCommand.CommandText = $"IF OBJECT_ID('[{TableName}]', 'U') IS NOT NULL DROP TABLE [dbo].[{TableName}]";
29 | sqlCommand.ExecuteNonQuery();
30 | sqlCommand.CommandText = $"CREATE TABLE [{TableName}]([Id] [int] NULL, [Message] [VARCHAR](100) NULL)";
31 | sqlCommand.ExecuteNonQuery();
32 | }
33 | }
34 | }
35 |
36 | [ClassCleanup]
37 | public static void ClassCleanup()
38 | {
39 | using (var sqlConnection = new SqlConnection(ConnectionStringForTestUser))
40 | {
41 | sqlConnection.Open();
42 | using (var sqlCommand = sqlConnection.CreateCommand())
43 | {
44 | sqlCommand.CommandText = $"IF OBJECT_ID('{TableName}', 'U') IS NOT NULL DROP TABLE [{TableName}];";
45 | sqlCommand.ExecuteNonQuery();
46 | }
47 | }
48 | }
49 |
50 | [TestCategory("SqlServer")]
51 | [TestMethod]
52 | public void Test()
53 | {
54 | try
55 | {
56 | string objectNaming;
57 |
58 | using (var tableDependency = new SqlTableDependency(ConnectionStringForTestUser, tableName: TableName))
59 | {
60 | tableDependency.OnChanged += (o, args) => { };
61 | tableDependency.Start();
62 | objectNaming = tableDependency.DataBaseObjectsNamingConvention;
63 |
64 | Thread.Sleep(5000);
65 | }
66 |
67 | Assert.IsTrue(base.AreAllDbObjectDisposed(objectNaming));
68 | Assert.IsTrue(base.CountConversationEndpoints(objectNaming) == 0);
69 | }
70 | catch (Exception exception)
71 | {
72 | Assert.Fail(exception.Message);
73 | }
74 | }
75 | }
76 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient.Test/Models/Category.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace TableDependency.SqlClient.Test.Models
4 | {
5 | public class Category
6 | {
7 | public int Id { get; set; }
8 | public string Description { get; set; }
9 |
10 | public IList Products { get; set; } = new List();
11 | }
12 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient.Test/Models/ConversationEndpoint.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace TableDependency.SqlClient.Test.Models
4 | {
5 | public class ConversationEndpoint
6 | {
7 | public Guid ConversationHandle { get; set; }
8 | public Guid ConversationId { get; set; }
9 | public int IsInitiator { get; set; }
10 | public int ServiceContractId { get; set; }
11 | public Guid ConversationGroupId { get; set; }
12 | public int ServiceId { get; set; }
13 | public DateTime Lifetime { get; set; }
14 | public string State { get; set; }
15 | public string StateDesc { get; set; }
16 | public string FarService { get; set; }
17 | public string FarBrokerInstance { get; set; }
18 | public int PrincipalId { get; set; }
19 | public int FarPrincipalId { get; set; }
20 | public Guid OutboundSessionKeyIdentifier { get; set; }
21 | public Guid InboundSessionKeyIdentifier {get; set; }
22 | public DateTime SecurityTimestamp { get; set; }
23 | public DateTime DialogTimer { get; set; }
24 | }
25 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient.Test/Models/Product.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace TableDependency.SqlClient.Test.Models
4 | {
5 | public class Product
6 | {
7 | public int Id { get; set; }
8 | public int? IdNullable { get; set; }
9 |
10 | public string Code { get; set; }
11 |
12 | public decimal Price { get; set; }
13 | public decimal? PriceNullable { get; set; }
14 |
15 | public float ExcangeRate { get; set; }
16 | public float? ExcangeRateNullable { get; set; }
17 |
18 | public DateTime ExpireDateTime { get; set; }
19 | public DateTime ExpireDateTimeNullable { get; set; }
20 |
21 | public int CategoryId { get; set; }
22 | public Category Category { get; set; }
23 | }
24 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient.Test/NoProblemDurignCommandTimeoutForNoMessagesTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Data.SqlClient;
3 | using System.Threading;
4 |
5 | using Microsoft.VisualStudio.TestTools.UnitTesting;
6 |
7 | using TableDependency.SqlClient.Base;
8 | using TableDependency.SqlClient.Base.Enums;
9 |
10 | namespace TableDependency.SqlClient.Test
11 | {
12 | public class NoProblemDurignCommandTimeoutForNoMessagesSqlServerModel
13 | {
14 | public int Id { get; set; }
15 | public string Name { get; set; }
16 | public string Surname { get; set; }
17 | public DateTime Born { get; set; }
18 | public int Quantity { get; set; }
19 | }
20 |
21 | [TestClass]
22 | public class DatabaseObjectCleanUpNoProblemDurignCommandTimeoutForNoMessagesSqlServer : Base.SqlTableDependencyBaseTest
23 | {
24 | private static string _dbObjectsNaming;
25 | private static readonly string TableName = typeof(NoProblemDurignCommandTimeoutForNoMessagesSqlServerModel).Name;
26 |
27 | [ClassInitialize]
28 | public static void ClassInitialize(TestContext testContext)
29 | {
30 | using (var sqlConnection = new SqlConnection(ConnectionStringForTestUser))
31 | {
32 | sqlConnection.Open();
33 | using (var sqlCommand = sqlConnection.CreateCommand())
34 | {
35 | sqlCommand.CommandText = $"IF OBJECT_ID('{TableName}', 'U') IS NOT NULL DROP TABLE [{TableName}];";
36 | sqlCommand.ExecuteNonQuery();
37 |
38 | sqlCommand.CommandText = $"CREATE TABLE [{TableName}]([Id][int] IDENTITY(1, 1) NOT NULL, [First Name] [NVARCHAR](50) NOT NULL)";
39 | sqlCommand.ExecuteNonQuery();
40 | }
41 | }
42 | }
43 |
44 | [TestCategory("SqlServer")]
45 | [TestMethod]
46 | public void Test()
47 | {
48 | var domaininfo = new AppDomainSetup { ApplicationBase = Environment.CurrentDirectory };
49 | var adevidence = AppDomain.CurrentDomain.Evidence;
50 | var domain = AppDomain.CreateDomain("TableDependencyDomaing", adevidence, domaininfo);
51 | var otherDomainObject = (RunsInAnotherAppDomainNoMessage) domain.CreateInstanceAndUnwrap(typeof (RunsInAnotherAppDomainNoMessage).Assembly.FullName, typeof (RunsInAnotherAppDomainNoMessage).FullName);
52 | _dbObjectsNaming = otherDomainObject.RunTableDependency(ConnectionStringForTestUser, tableName: TableName);
53 | Thread.Sleep(4*60*1000);
54 | var status = otherDomainObject.GetTableDependencyStatus();
55 |
56 | AppDomain.Unload(domain);
57 | Thread.Sleep(3 * 60 * 1000);
58 |
59 | Assert.IsTrue(status != TableDependencyStatus.StopDueToError && status != TableDependencyStatus.StopDueToCancellation);
60 | Assert.IsTrue(base.AreAllDbObjectDisposed(_dbObjectsNaming));
61 | Assert.IsTrue(base.CountConversationEndpoints(_dbObjectsNaming) == 0);
62 | }
63 |
64 | [ClassCleanup]
65 | public static void ClassCleanup()
66 | {
67 | using (var sqlConnection = new SqlConnection(ConnectionStringForTestUser))
68 | {
69 | sqlConnection.Open();
70 | using (var sqlCommand = sqlConnection.CreateCommand())
71 | {
72 | sqlCommand.CommandText = $"IF OBJECT_ID('{TableName}', 'U') IS NOT NULL DROP TABLE [{TableName}];";
73 | sqlCommand.ExecuteNonQuery();
74 | }
75 | }
76 | }
77 |
78 | public class RunsInAnotherAppDomainNoMessage : MarshalByRefObject
79 | {
80 | private SqlTableDependency _tableDependency = null;
81 |
82 | public TableDependencyStatus GetTableDependencyStatus()
83 | {
84 | return this._tableDependency.Status;
85 | }
86 |
87 | public string RunTableDependency(string connectionString, string tableName)
88 | {
89 | var mapper = new ModelToTableMapper();
90 | mapper.AddMapping(c => c.Name, "First Name");
91 |
92 | this._tableDependency = new SqlTableDependency(connectionString, tableName: tableName, mapper: mapper);
93 | this._tableDependency.OnChanged += (o, args) => { };
94 | this._tableDependency.Start(60, 120);
95 |
96 | return this._tableDependency.DataBaseObjectsNamingConvention;
97 | }
98 | }
99 | }
100 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient.Test/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | [assembly: AssemblyTitle("TableDependency.SqlClient.Test")]
6 | [assembly: AssemblyDescription("")]
7 | [assembly: AssemblyConfiguration("")]
8 | [assembly: AssemblyCompany("")]
9 | [assembly: AssemblyProduct("TableDependency.SqlClient.Test")]
10 | [assembly: AssemblyCopyright("Copyright © 2018")]
11 | [assembly: AssemblyTrademark("")]
12 | [assembly: AssemblyCulture("")]
13 |
14 | [assembly: ComVisible(false)]
15 |
16 | [assembly: Guid("50187a69-921c-453c-b616-92b6ff5ad541")]
17 |
18 | // [assembly: AssemblyVersion("1.0.*")]
19 | [assembly: AssemblyVersion("1.0.0.0")]
20 | [assembly: AssemblyFileVersion("1.0.0.0")]
21 |
--------------------------------------------------------------------------------
/TableDependency.SqlClient.Test/Scripts/CleanUpEndpoints.sql:
--------------------------------------------------------------------------------
1 | use TableDependencyDB
2 |
3 | declare @h uniqueidentifier, @count int = 0;
4 |
5 | while (1=1)
6 | begin
7 | set @h = null;
8 | select top(1) @h = conversation_handle
9 | from sys.conversation_endpoints
10 | --where state_desc = N'STARTED_OUTBOUND'
11 | if (@h is null)
12 | begin
13 | break
14 | end
15 | end conversation @h with cleanup;
16 | set @count += 1;
17 | if (@count > 1000)
18 | begin
19 | commit;
20 | set @count = 0;
21 | begin transaction;
22 | end
23 | end
24 |
25 |
26 | select * from sys.conversation_endpoints WITH (NOLOCK)
--------------------------------------------------------------------------------
/TableDependency.SqlClient.Test/Scripts/CompatibilityLevel.sql:
--------------------------------------------------------------------------------
1 | -- https://sqlrus.com/2014/10/compatibility-level-vs-database-version/
2 | SELECT name, compatibility_level from sys.databases WHERE name in ('Northwind', 'TableDependencyDB')
3 | GO
4 |
5 | SELECT name, version from master.dbo.sysdatabases where name in ('Northwind', 'TableDependencyDB')
6 | GO
7 |
8 |
9 |
10 | DBCC TRACEON (3604)
11 | DBCC PAGE('Northwind',1,9,3)
12 | DBCC TRACEOFF (3604)
13 | GO
14 | --using DBCC DBINFO
15 | DBCC TRACEON (3604)
16 | DBCC DBINFO
17 | DBCC TRACEOFF (3604)
18 | GO
19 |
20 | -- useing database property
21 | SELECT DatabaseProperty('Northwind','version')
22 | GODBCC TRACEON (3604)
23 | DBCC PAGE('Northwind',1,9,3)
24 | DBCC TRACEOFF (3604)
25 | GO
26 | --using DBCC DBINFO
27 | DBCC TRACEON (3604)
28 | DBCC DBINFO
29 | DBCC TRACEOFF (3604)
30 | GO
31 |
32 | -- useing database property
33 | SELECT DatabaseProperty('Northwind','version')
34 | GO
35 |
36 |
37 | -- *************************************************************
38 |
39 | use Northwind
40 |
41 | --http://jongurgul.com/blog/database-created-version-internal-database-version-dbi_createversion/
42 | --http://connect.microsoft.com/SQLServer/feedback/details/640864/smo-property-database-version-does-not-return-the-version-used-to-create-the-database-but-the-version-that-is-has-been-upgraded-to-on-the-current-instance
43 | DECLARE @DBINFO TABLE ([ParentObject] VARCHAR(60),[Object] VARCHAR(60),[Field] VARCHAR(30),[VALUE] VARCHAR(4000))
44 | INSERT INTO @DBINFO
45 | EXECUTE sp_executesql N'DBCC DBINFO WITH TABLERESULTS'
46 | SELECT [Field]
47 | ,[VALUE]
48 | ,CASE
49 | WHEN [VALUE] = 515 THEN 'SQL 7'
50 | WHEN [VALUE] = 539 THEN 'SQL 2000'
51 | WHEN [VALUE] IN (611,612) THEN 'SQL 2005'
52 | WHEN [VALUE] = 655 THEN 'SQL 2008'
53 | WHEN [VALUE] = 661 THEN 'SQL 2008R2'
54 | WHEN [VALUE] = 706 THEN 'SQL 2012'
55 | WHEN [VALUE] = 782 THEN 'SQL 2014'
56 | WHEN [VALUE] = 852 THEN 'SQL 2016'
57 | ELSE '?'
58 | END [SQLVersion]
59 | FROM @DBINFO
60 | WHERE [Field] IN ('dbi_createversion','dbi_version')
--------------------------------------------------------------------------------
/TableDependency.SqlClient.Test/Scripts/DropMessageTypes.sql:
--------------------------------------------------------------------------------
1 | DECLARE @name varchar(200)
2 |
3 | DECLARE emp_cursor CURSOR FOR
4 | SELECT name from sys.service_message_types
5 | where name like 'dbo_%'
6 |
7 | OPEN emp_cursor
8 |
9 | FETCH NEXT FROM emp_cursor
10 | INTO @name
11 |
12 |
13 | WHILE @@FETCH_STATUS = 0
14 | BEGIN
15 |
16 | EXECUTE ('DROP MESSAGE TYPE [' + @name + ']')
17 |
18 | FETCH NEXT FROM emp_cursor
19 | INTO @name
20 |
21 |
22 | END
23 | CLOSE emp_cursor;
24 | DEALLOCATE emp_cursor;
--------------------------------------------------------------------------------
/TableDependency.SqlClient.Test/Scripts/Monolog.sql:
--------------------------------------------------------------------------------
1 | --*********************************************************************************************************************
2 | --Even though we want to model a monolog we still need a sender and receiver.
3 | --The receiver is where the important work is done.
4 | --The sender is merely there for completeness in the dialog.
5 | --*********************************************************************************************************************
6 |
7 | --Set it up...
8 | CREATE QUEUE SenderQ;
9 | CREATE QUEUE ReceiverQ;
10 | CREATE SERVICE SenderSvc ON QUEUE SenderQ;
11 | CREATE SERVICE ReceiverSvc ON QUEUE ReceiverQ ([DEFAULT]);
12 | GO
13 |
14 | --to get the monolog pattern to work the Sender must have an activator proc.
15 | --It's sole job is to END CONVERSATION on the sending side.
16 | create PROCEDURE SenderQ_ActivatorProcedure
17 | AS
18 | BEGIN
19 | SET NOCOUNT ON;
20 | DECLARE
21 | @mt sysname,
22 | @h uniqueidentifier;
23 |
24 | --this can be made far more performant and resilient, but this is the most
25 | --basic pattern
26 | RECEIVE TOP (1)
27 | @mt = message_type_name,
28 | @h = conversation_handle
29 | FROM SenderQ;
30 | IF @mt = (N'http://schemas.microsoft.com/SQL/ServiceBroker/EndDialog') OR @mt = (N'http://schemas.microsoft.com/SQL/ServiceBroker/Error')
31 | BEGIN
32 | END CONVERSATION @h;
33 | END
34 | END;
35 | GO
36 |
37 | --now attach the activator proc to the Q.
38 | --Here we set the STATUS to OFF for the demo, we'll enable it below.
39 | ALTER QUEUE SenderQ
40 | WITH ACTIVATION
41 | (
42 | procedure_name = dbo.SenderQ_ActivatorProcedure,
43 | max_queue_readers = 1,
44 | EXECUTE AS OWNER,
45 | STATUS = ON
46 | );
47 | GO
48 |
49 |
50 | --The sender is responsible for pushing the asynchronous message to the receiver.
51 | --The COMMIT is the "synchronous" transaction boundary. The "message" is the asynchronous
52 | --process we want to run in an autonomous transaction.
53 | DECLARE @h UNIQUEIDENTIFIER;
54 | BEGIN DIALOG @h
55 | FROM SERVICE [SenderSvc]
56 | TO SERVICE 'ReceiverSvc'
57 | WITH ENCRYPTION = OFF;
58 |
59 | --SEND ON CONVERSATION @h (0x); --> null
60 | --SEND ON CONVERSATION @h (convert(varbinary,'')); --> null
61 | --SEND ON CONVERSATION @h (convert(varbinary,' ')); --> 0x20
62 | --SEND ON CONVERSATION @h (0x0); --> 0x00
63 |
64 | SEND ON CONVERSATION @h (CONVERT(NVARCHAR(MAX),'')) --> null
65 |
66 | --note that we SEND but we do *not* END CONVERSATION.
67 | --if we did that would be the dreaded "fire-and-forget" anti-pattern.
68 | --Remember: The target always ENDs CONVERSATION first!
69 | --END CONVERSATION @h;
70 |
71 | --everything seems ok so far
72 | select conversation_handle, message_type_name, convert(xml,message_body) as MsgBody, message_body from SenderQ
73 | select conversation_handle, message_type_name, convert(xml,message_body) as MsgBody, message_body from ReceiverQ
74 | select * from sys.conversation_endpoints WITH (NOLOCK);
75 |
76 |
77 |
78 |
79 | --now receiver processes the message
80 | DECLARE @rh UNIQUEIDENTIFIER;
81 | WAITFOR(
82 | RECEIVE
83 | TOP(1) @rh = conversation_handle
84 | FROM ReceiverQ
85 | ), TIMEOUT 2000 ;
86 |
87 | --do whatever work you want to do HERE
88 | --note that we first END CONVERSATION on the receiver side.
89 | END CONVERSATION @rh;
90 | GO
91 |
92 |
93 | --and now the message is automatically acknowledged and the conversation is ended
94 | select conversation_handle, message_type_name, convert(xml,message_body) as MsgBody, message_body from SenderQ
95 | select conversation_handle, message_type_name, convert(xml,message_body) as MsgBody, message_body from ReceiverQ
96 | select * from sys.conversation_endpoints WITH (NOLOCK);
97 |
98 |
99 |
--------------------------------------------------------------------------------
/TableDependency.SqlClient.Test/Scripts/QueryEndpoints.sql:
--------------------------------------------------------------------------------
1 | use TableDependencyDB
2 |
3 | select * from sys.conversation_endpoints WITH (NOLOCK)
4 | --WHERE [conversation_handle] = UPPER('be247ac4-7a68-e811-a571-605718985fcf')
5 |
6 |
--------------------------------------------------------------------------------
/TableDependency.SqlClient.Test/TaskCancellationTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Data.SqlClient;
3 | using System.Threading;
4 |
5 | using Microsoft.VisualStudio.TestTools.UnitTesting;
6 |
7 | using TableDependency.SqlClient.Base;
8 | using TableDependency.SqlClient.Base.EventArgs;
9 |
10 | namespace TableDependency.SqlClient.Test
11 | {
12 | public class TaskCancellationTestSqlServerModel
13 | {
14 | public int Id { get; set; }
15 | public string Name { get; set; }
16 | public string Surname { get; set; }
17 | public DateTime Born { get; set; }
18 | public int Quantity { get; set; }
19 | }
20 |
21 | [TestClass]
22 | public class TaskCancellationTest : Base.SqlTableDependencyBaseTest
23 | {
24 | private static readonly string TableName = typeof(TaskCancellationTestSqlServerModel).Name;
25 |
26 | [ClassInitialize]
27 | public static void ClassInitialize(TestContext testContext)
28 | {
29 | using (var sqlConnection = new SqlConnection(ConnectionStringForTestUser))
30 | {
31 | sqlConnection.Open();
32 | using (var sqlCommand = sqlConnection.CreateCommand())
33 | {
34 | sqlCommand.CommandText = $"IF OBJECT_ID('{TableName}', 'U') IS NOT NULL DROP TABLE [{TableName}];";
35 | sqlCommand.ExecuteNonQuery();
36 |
37 | sqlCommand.CommandText =
38 | $"CREATE TABLE [{TableName}]( " +
39 | "[Id][int] IDENTITY(1, 1) NOT NULL, " +
40 | "[First Name] [NVARCHAR](50) NOT NULL, " +
41 | "[Second Name] [NVARCHAR](50) NOT NULL, " +
42 | "[Born] [DATETIME] NULL)";
43 | sqlCommand.ExecuteNonQuery();
44 | }
45 | }
46 | }
47 |
48 | [TestInitialize]
49 | public void TestInitialize()
50 | {
51 | using (var sqlConnection = new SqlConnection(ConnectionStringForTestUser))
52 | {
53 | sqlConnection.Open();
54 | using (var sqlCommand = sqlConnection.CreateCommand())
55 | {
56 | sqlCommand.CommandText = $"DELETE FROM [{TableName}]";
57 | sqlCommand.ExecuteNonQuery();
58 | }
59 | }
60 | }
61 |
62 | [ClassCleanup]
63 | public static void ClassCleanup()
64 | {
65 | using (var sqlConnection = new SqlConnection(ConnectionStringForTestUser))
66 | {
67 | sqlConnection.Open();
68 | using (var sqlCommand = sqlConnection.CreateCommand())
69 | {
70 | sqlCommand.CommandText = $"IF OBJECT_ID('{TableName}', 'U') IS NOT NULL DROP TABLE [{TableName}];";
71 | sqlCommand.ExecuteNonQuery();
72 | }
73 | }
74 | }
75 |
76 | [TestCategory("SqlServer")]
77 | [TestMethod]
78 | public void Test()
79 | {
80 | string naming = null;
81 | SqlTableDependency tableDependency = null;
82 |
83 | try
84 | {
85 | var mapper = new ModelToTableMapper();
86 | mapper.AddMapping(c => c.Name, "First Name").AddMapping(c => c.Surname, "Second Name");
87 |
88 | tableDependency = new SqlTableDependency(ConnectionStringForTestUser, tableName: TableName, mapper: mapper);
89 | tableDependency.OnChanged += TableDependency_Changed;
90 | tableDependency.Start();
91 | naming = tableDependency.DataBaseObjectsNamingConvention;
92 |
93 | Thread.Sleep(1000 * 15 * 1);
94 | tableDependency.Stop();
95 |
96 | Thread.Sleep(5000);
97 | }
98 | catch
99 | {
100 | tableDependency?.Dispose();
101 | }
102 |
103 | Assert.IsTrue(base.AreAllDbObjectDisposed(naming));
104 | Assert.IsTrue(base.CountConversationEndpoints(naming)== 0);
105 | }
106 |
107 | private static void TableDependency_Changed(object sender, RecordChangedEventArgs e)
108 | {
109 | }
110 | }
111 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient.Test/WhereUnitTestBinaryExpressionOnBothSides.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq.Expressions;
3 |
4 | using Microsoft.VisualStudio.TestTools.UnitTesting;
5 |
6 | using TableDependency.SqlClient.Test.Models;
7 | using TableDependency.SqlClient.Where;
8 |
9 | namespace TableDependency.SqlClient.Test
10 | {
11 | [TestClass]
12 | public class WhereUnitTestBinaryExpressionOnBothSides
13 | {
14 | [TestMethod]
15 | public void ExpressionOnBothSides1()
16 | {
17 | // Arrange
18 | Expression> expression = p => p.Code.Substring(1,3).ToLower() == p.Id.ToString().ToLower();
19 |
20 | // Act
21 | var where = new SqlTableDependencyFilter(expression).Translate();
22 |
23 | // Assert
24 | Assert.AreEqual("(LOWER(SUBSTRING([Code], 1, 3)) = LOWER(CONVERT(varchar(MAX), [Id])))", where);
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/TableDependency.SqlClient.Test/WhereUnitTestContains.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using System.Linq.Expressions;
4 |
5 | using Microsoft.VisualStudio.TestTools.UnitTesting;
6 |
7 | using TableDependency.SqlClient.Test.Models;
8 | using TableDependency.SqlClient.Where;
9 |
10 | namespace TableDependency.SqlClient.Test
11 | {
12 | [TestClass]
13 | public class WhereUnitTestContains
14 | {
15 | [TestMethod]
16 | public void StringContains1()
17 | {
18 | // Arrange
19 | Expression> expression = p => p.Code.Contains("123");
20 |
21 | // Act
22 | var where = new SqlTableDependencyFilter(expression).Translate();
23 |
24 | // Assert
25 | Assert.AreEqual("[Code] LIKE '%123%'", where);
26 | }
27 |
28 | [TestMethod]
29 | public void StringContains2()
30 | {
31 | // Arrange
32 | Expression> expression = p => p.Code.Contains("123");
33 |
34 | // Act
35 | var where = new SqlTableDependencyFilter(expression).Translate();
36 |
37 | // Assert
38 | Assert.AreEqual("[Code] LIKE '%123%'", where);
39 | }
40 |
41 | [TestMethod]
42 | public void ColumnContainsNumbers()
43 | {
44 | var ids = new[] { 1, 2, 3 };
45 |
46 | // Arrange
47 | Expression> expression = p => ids.Contains(p.Id);
48 |
49 | // Act
50 | var where = new SqlTableDependencyFilter(expression).Translate();
51 |
52 | // Assert
53 | Assert.AreEqual("[Id] IN (1,2,3)", where);
54 | }
55 |
56 | [TestMethod]
57 | public void ColumnContainsStrings()
58 | {
59 | var codes = new[] { "one", "two" };
60 |
61 | // Arrange
62 | Expression> expression = p => codes.Contains(p.Code);
63 |
64 | // Act
65 | var where = new SqlTableDependencyFilter(expression).Translate();
66 |
67 | // Assert
68 | Assert.AreEqual("[Code] IN ('one','two')", where);
69 | }
70 |
71 | [TestMethod]
72 | public void ColumnContainsDecimals()
73 | {
74 | var prices = new[] { 123.45M, 432.10M };
75 |
76 | // Arrange
77 | Expression> expression = p => prices.Contains(p.Price);
78 |
79 | // Act
80 | var where = new SqlTableDependencyFilter(expression).Translate();
81 |
82 | // Assert
83 | Assert.AreEqual("[Price] IN (123.45,432.10)", where);
84 | }
85 |
86 | [TestMethod]
87 | public void ColumnContainsFloats()
88 | {
89 | var prices = new[] { 123.45f, 432.10f };
90 |
91 | // Arrange
92 | Expression> expression = p => prices.Contains(p.ExcangeRate);
93 |
94 | // Act
95 | var where = new SqlTableDependencyFilter(expression).Translate();
96 |
97 | // Assert
98 | Assert.AreEqual($"[ExcangeRate] IN ({123.45},{432.1})", where);
99 | }
100 |
101 | [TestMethod]
102 | public void ColumnContainsDates()
103 | {
104 | var codes = new[] {
105 | DateTime.ParseExact("2010-05-18 14:40:52,531", "yyyy-MM-dd HH:mm:ss,fff", System.Globalization.CultureInfo.InvariantCulture),
106 | DateTime.ParseExact("2009-05-18 14:40:52,531", "yyyy-MM-dd HH:mm:ss,fff", System.Globalization.CultureInfo.InvariantCulture)
107 | };
108 |
109 | // Arrange
110 | Expression> expression = p => codes.Contains(p.ExpireDateTime);
111 |
112 | // Act
113 | var where = new SqlTableDependencyFilter(expression).Translate();
114 |
115 | // Assert
116 | Assert.AreEqual("[ExpireDateTime] IN ('2010-05-18T14:40:52','2009-05-18T14:40:52')", where);
117 | }
118 | }
119 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient.Test/WhereUnitTestInnerProperty.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq.Expressions;
3 |
4 | using Microsoft.VisualStudio.TestTools.UnitTesting;
5 |
6 | using TableDependency.SqlClient.Test.Models;
7 | using TableDependency.SqlClient.Where;
8 |
9 | namespace TableDependency.SqlClient.Test
10 | {
11 | [TestClass]
12 | public class WhereUnitTestInnerProperty
13 | {
14 | [TestMethod]
15 | [ExpectedException(typeof(NotSupportedException))]
16 | public void ExceptionExpected1()
17 | {
18 | // Arrange
19 | Expression> expression = p => p.Category.Description == "Pasta";
20 |
21 | // Act
22 | var where = new SqlTableDependencyFilter(expression).Translate();
23 |
24 | // Assert
25 | Assert.AreEqual("(UPPER([Code]) = '123')", where);
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient.Test/WhereUnitTestMapper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq.Expressions;
3 |
4 | using Microsoft.VisualStudio.TestTools.UnitTesting;
5 |
6 | using TableDependency.SqlClient.Base;
7 | using TableDependency.SqlClient.Test.Models;
8 | using TableDependency.SqlClient.Where;
9 |
10 | namespace TableDependency.SqlClient.Test
11 | {
12 | [TestClass]
13 | public class WhereUnitTestMapper
14 | {
15 | [TestMethod]
16 | public void Mapping1()
17 | {
18 | var mapper = new ModelToTableMapper();
19 | mapper.AddMapping(c => c.Code, "BarCode");
20 |
21 | // Arrange
22 | Expression> expression = p => p.Code == "042100005264";
23 |
24 | // Act
25 | var where = new SqlTableDependencyFilter(expression, mapper).Translate();
26 |
27 | // Assert
28 | Assert.AreEqual("([BarCode] = '042100005264')", where);
29 | }
30 |
31 | [TestMethod]
32 | public void Mapping2()
33 | {
34 | var mapper = new ModelToTableMapper();
35 | mapper.AddMapping(c => c.Code, "[BarCode]");
36 |
37 | // Arrange
38 | Expression> expression = p => p.Code == "042100005264";
39 |
40 | // Act
41 | var where = new SqlTableDependencyFilter(expression, mapper).Translate();
42 |
43 | // Assert
44 | Assert.AreEqual("([BarCode] = '042100005264')", where);
45 | }
46 | }
47 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient.Test/WhereUnitTestMethodsChain.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq.Expressions;
3 |
4 | using Microsoft.VisualStudio.TestTools.UnitTesting;
5 |
6 | using TableDependency.SqlClient.Test.Models;
7 | using TableDependency.SqlClient.Where;
8 |
9 | namespace TableDependency.SqlClient.Test
10 | {
11 | [TestClass]
12 | public class WhereUnitTestMethodsChain
13 | {
14 | [TestMethod]
15 | public void MethodsChain1()
16 | {
17 | // Arrange
18 | Expression> expression = p => p.Code.Trim().ToUpper().Substring(0, 3).EndsWith("WWW");
19 |
20 | // Act
21 | var where = new SqlTableDependencyFilter(expression).Translate();
22 |
23 | // Assert
24 | Assert.AreEqual("SUBSTRING(UPPER(LTRIM(RTRIM([Code]))), 0, 3) LIKE '%WWW'", where);
25 | }
26 |
27 | [TestMethod]
28 | public void MethodsChain2()
29 | {
30 | // Arrange
31 | Expression> expression = p => p.Code.Trim().ToUpper().Substring(0, 3).Contains("WWW");
32 |
33 | // Act
34 | var where = new SqlTableDependencyFilter(expression).Translate();
35 |
36 | // Assert
37 | Assert.AreEqual("SUBSTRING(UPPER(LTRIM(RTRIM([Code]))), 0, 3) LIKE '%WWW%'", where);
38 | }
39 | }
40 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient.Test/WhereUnitTestParameterInt.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq.Expressions;
3 |
4 | using Microsoft.VisualStudio.TestTools.UnitTesting;
5 |
6 | using TableDependency.SqlClient.Test.Models;
7 | using TableDependency.SqlClient.Where;
8 |
9 | namespace TableDependency.SqlClient.Test
10 | {
11 | [TestClass]
12 | public class WhereUnitTestParameterInt
13 | {
14 | [TestMethod]
15 | public void UnitTestParameters1()
16 | {
17 | var par1 = 123;
18 |
19 | // Arrange
20 | Expression> expression = p => p.Id == par1;
21 |
22 | // Act
23 | var where = new SqlTableDependencyFilter(expression).Translate();
24 |
25 | // Assert
26 | Assert.AreEqual("([Id] = 123)", where);
27 | }
28 |
29 | [TestMethod]
30 | public void UnitTestParameters2()
31 | {
32 | var par1 = 123;
33 |
34 | // Arrange
35 | Expression> expression = p => p.Id >= par1;
36 |
37 | // Act
38 | var where = new SqlTableDependencyFilter(expression).Translate();
39 |
40 | // Assert
41 | Assert.AreEqual("([Id] >= 123)", where);
42 | }
43 |
44 | [TestMethod]
45 | public void UnitTestParameters3()
46 | {
47 | var par1 = 123;
48 | var par2 = 321;
49 |
50 | // Arrange
51 | Expression> expression = p => p.Id >= par1 && p.Id <= par2;
52 |
53 | // Act
54 | var where = new SqlTableDependencyFilter(expression).Translate();
55 |
56 | // Assert
57 | Assert.AreEqual("(([Id] >= 123) AND ([Id] <= 321))", where);
58 | }
59 |
60 | [TestMethod]
61 | [ExpectedException(typeof(NotSupportedException))]
62 | public void UnitTestParameters4()
63 | {
64 | var par1 = "123";
65 |
66 | // Arrange
67 | Expression> expression = p => p.Id >= Int32.Parse(par1);
68 |
69 | // Act
70 | var where = new SqlTableDependencyFilter(expression).Translate();
71 |
72 | // Assert
73 | }
74 | }
75 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient.Test/WhereUnitTestParameterString.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq.Expressions;
3 |
4 | using Microsoft.VisualStudio.TestTools.UnitTesting;
5 |
6 | using TableDependency.SqlClient.Test.Models;
7 | using TableDependency.SqlClient.Where;
8 |
9 | namespace TableDependency.SqlClient.Test
10 | {
11 | [TestClass]
12 | public class WhereUnitTestParameterString
13 | {
14 | [TestMethod]
15 | public void UnitTestParameters1()
16 | {
17 | var par1 = "WWW";
18 |
19 | // Arrange
20 | Expression> expression = p => p.Code.Trim().ToUpper().Substring(0, 3).EndsWith(par1);
21 |
22 | // Act
23 | var where = new SqlTableDependencyFilter(expression).Translate();
24 |
25 | // Assert
26 | Assert.AreEqual("SUBSTRING(UPPER(LTRIM(RTRIM([Code]))), 0, 3) LIKE '%WWW'", where);
27 | }
28 |
29 | [TestMethod]
30 | public void UnitTestParameters2()
31 | {
32 | var par1 = "WWW";
33 |
34 | // Arrange
35 | Expression> expression = p => p.Code.Trim().ToUpper().Substring(0, 3).Contains(par1);
36 |
37 | // Act
38 | var where = new SqlTableDependencyFilter(expression).Translate();
39 |
40 | // Assert
41 | Assert.AreEqual("SUBSTRING(UPPER(LTRIM(RTRIM([Code]))), 0, 3) LIKE '%WWW%'", where);
42 | }
43 |
44 | [TestMethod]
45 | public void UnitTestParameters3()
46 | {
47 | var par1 = "WWW";
48 |
49 | // Arrange
50 | Expression> expression = p => p.Code.Trim().ToUpper().Substring(0, 3).StartsWith(par1);
51 |
52 | // Act
53 | var where = new SqlTableDependencyFilter(expression).Translate();
54 |
55 | // Assert
56 | Assert.AreEqual("SUBSTRING(UPPER(LTRIM(RTRIM([Code]))), 0, 3) LIKE 'WWW%'", where);
57 | }
58 |
59 | [TestMethod]
60 | public void UnitTestParameters4()
61 | {
62 | var par1 = "WWW";
63 |
64 | // Arrange
65 | Expression> expression = p => p.Code.Trim().ToUpper().Substring(0, 3).Equals(par1);
66 |
67 | // Act
68 | var where = new SqlTableDependencyFilter(expression).Translate();
69 |
70 | // Assert
71 | Assert.AreEqual("SUBSTRING(UPPER(LTRIM(RTRIM([Code]))), 0, 3) = 'WWW'", where);
72 | }
73 |
74 | [TestMethod]
75 | public void UnitTestParameters5()
76 | {
77 | var par1 = "WWW";
78 |
79 | // Arrange
80 | Expression> expression = p => p.Code.Trim().ToUpper().Substring(0, 3) == par1;
81 |
82 | // Act
83 | var where = new SqlTableDependencyFilter(expression).Translate();
84 |
85 | // Assert
86 | Assert.AreEqual("(SUBSTRING(UPPER(LTRIM(RTRIM([Code]))), 0, 3) = 'WWW')", where);
87 | }
88 |
89 | [TestMethod]
90 | public void UnitTestParameters6()
91 | {
92 | var par1 = "WWW";
93 |
94 | // Arrange
95 | Expression> expression = p => p.Code.Trim().ToLower().Substring(0, 3) == par1.ToLower();
96 |
97 | // Act
98 | var where = new SqlTableDependencyFilter(expression).Translate();
99 |
100 | // Assert
101 | Assert.AreEqual("(SUBSTRING(LOWER(LTRIM(RTRIM([Code]))), 0, 3) = LOWER('WWW'))", where);
102 | }
103 |
104 | [TestMethod]
105 | public void UnitTestParameters7()
106 | {
107 | var par1 = "WWW";
108 |
109 | // Arrange
110 | Expression> expression = p => p.Code.Trim().ToLower().Substring(0, 3) == par1.Trim().ToLower().Substring(0, 3);
111 |
112 | // Act
113 | var where = new SqlTableDependencyFilter(expression).Translate();
114 |
115 | // Assert
116 | Assert.AreEqual("(SUBSTRING(LOWER(LTRIM(RTRIM([Code]))), 0, 3) = SUBSTRING(LOWER(LTRIM(RTRIM('WWW'))), 0, 3))", where);
117 | }
118 | }
119 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient.Test/WhereUnitTestStartsWith.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq.Expressions;
3 |
4 | using Microsoft.VisualStudio.TestTools.UnitTesting;
5 |
6 | using TableDependency.SqlClient.Test.Models;
7 | using TableDependency.SqlClient.Where;
8 |
9 | namespace TableDependency.SqlClient.Test
10 | {
11 | [TestClass]
12 | public class WhereUnitTestStartsWith
13 | {
14 | [TestMethod]
15 | public void StartsWith1()
16 | {
17 | // Arrange
18 | Expression> expression = p => p.Code.StartsWith("123");
19 |
20 | // Act
21 | var where = new SqlTableDependencyFilter(expression).Translate();
22 |
23 | // Assert
24 | Assert.AreEqual("[Code] LIKE '123%'", where);
25 | }
26 |
27 | [TestMethod]
28 | public void EndsWith1()
29 | {
30 | // Arrange
31 | Expression> expression = p => p.Code.EndsWith("123");
32 |
33 | // Act
34 | var where = new SqlTableDependencyFilter(expression).Translate();
35 |
36 | // Assert
37 | Assert.AreEqual("[Code] LIKE '%123'", where);
38 | }
39 |
40 | [TestMethod]
41 | public void StartsAndEndsWith1()
42 | {
43 | // Arrange
44 | Expression> expression = p => p.Code.EndsWith("123") && p.Code.StartsWith("123");
45 |
46 | // Act
47 | var where = new SqlTableDependencyFilter(expression).Translate();
48 |
49 | // Assert
50 | Assert.AreEqual("([Code] LIKE '%123' AND [Code] LIKE '123%')", where);
51 | }
52 |
53 | [TestMethod]
54 | public void StartsAndEndsWith2()
55 | {
56 | // Arrange
57 | Expression> expression = p => (p.Code.EndsWith("123")) && (p.Code.StartsWith("123"));
58 |
59 | // Act
60 | var where = new SqlTableDependencyFilter(expression).Translate();
61 |
62 | // Assert
63 | Assert.AreEqual("([Code] LIKE '%123' AND [Code] LIKE '123%')", where);
64 | }
65 |
66 | [TestMethod]
67 | public void StartsOrEndsWith1()
68 | {
69 | // Arrange
70 | Expression> expression = p => p.Code.EndsWith("123") || p.Code.StartsWith("123");
71 |
72 | // Act
73 | var where = new SqlTableDependencyFilter(expression).Translate();
74 |
75 | // Assert
76 | Assert.AreEqual("([Code] LIKE '%123' OR [Code] LIKE '123%')", where);
77 | }
78 |
79 | [TestMethod]
80 | public void EndsOrStartsWith2()
81 | {
82 | // Arrange
83 | Expression> expression = p => p.Code.StartsWith("123") || p.Code.EndsWith("123");
84 |
85 | // Act
86 | var where = new SqlTableDependencyFilter(expression).Translate();
87 |
88 | // Assert
89 | Assert.AreEqual("([Code] LIKE '123%' OR [Code] LIKE '%123')", where);
90 | }
91 | }
92 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient.Test/WhereUnitTestSubstring.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq.Expressions;
3 |
4 | using Microsoft.VisualStudio.TestTools.UnitTesting;
5 |
6 | using TableDependency.SqlClient.Test.Models;
7 | using TableDependency.SqlClient.Where;
8 |
9 | namespace TableDependency.SqlClient.Test
10 | {
11 | [TestClass]
12 | public class WhereUnitTestSubstring
13 | {
14 | [TestMethod]
15 | public void SubstringTests1()
16 | {
17 | // Arrange
18 | Expression> expression = p => p.Code.Substring(0, 3) == "123";
19 |
20 | // Act
21 | var where = new SqlTableDependencyFilter(expression).Translate();
22 |
23 | // Assert
24 | Assert.AreEqual("(SUBSTRING([Code], 0, 3) = '123')", where);
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/TableDependency.SqlClient.Test/WhereUnitTestToLower.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq.Expressions;
3 |
4 | using Microsoft.VisualStudio.TestTools.UnitTesting;
5 |
6 | using TableDependency.SqlClient.Test.Models;
7 | using TableDependency.SqlClient.Where;
8 |
9 | namespace TableDependency.SqlClient.Test
10 | {
11 | [TestClass]
12 | public class WhereUnitTestToLower
13 | {
14 | [TestMethod]
15 | public void ToLower1()
16 | {
17 | // Arrange
18 | Expression> expression = p => p.Code.ToLower() == "123";
19 |
20 | // Act
21 | var where = new SqlTableDependencyFilter(expression).Translate();
22 |
23 | // Assert
24 | Assert.AreEqual("(LOWER([Code]) = '123')", where);
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient.Test/WhereUnitTestToString.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using System.Linq.Expressions;
4 |
5 | using Microsoft.VisualStudio.TestTools.UnitTesting;
6 |
7 | using TableDependency.SqlClient.Test.Models;
8 | using TableDependency.SqlClient.Where;
9 |
10 | namespace TableDependency.SqlClient.Test
11 | {
12 | [TestClass]
13 | public class WhereUnitTestToString
14 | {
15 | [TestMethod]
16 | public void ToStringOnIntField1()
17 | {
18 | // Arrange
19 | Expression> expression = p => p.Price.ToString() == "123";
20 |
21 | // Act
22 | var where = new SqlTableDependencyFilter(expression).Translate();
23 |
24 | // Assert
25 | Assert.AreEqual("(CONVERT(varchar(MAX), [Price]) = '123')", where);
26 | }
27 |
28 |
29 | [TestMethod]
30 | public void ToStringWithInvariantCulture1()
31 | {
32 | // Arrange
33 | Expression> expression = p => p.Price.ToString(CultureInfo.InvariantCulture) == "123.4";
34 |
35 | // Act
36 | var where = new SqlTableDependencyFilter(expression).Translate();
37 |
38 | // Assert
39 | Assert.AreEqual("(CONVERT(varchar(MAX), [Price]) = '123.4')", where);
40 | }
41 |
42 | [TestMethod]
43 | public void ToStringOnStringField1()
44 | {
45 | // Arrange
46 | Expression> expression = p => p.Code.ToString() == "123.4";
47 |
48 | // Act
49 | var where = new SqlTableDependencyFilter(expression).Translate();
50 |
51 | // Assert
52 | Assert.AreEqual("(CONVERT(varchar(MAX), [Code]) = '123.4')", where);
53 | }
54 | }
55 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient.Test/WhereUnitTestToUpper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq.Expressions;
3 |
4 | using Microsoft.VisualStudio.TestTools.UnitTesting;
5 |
6 | using TableDependency.SqlClient.Test.Models;
7 | using TableDependency.SqlClient.Where;
8 |
9 | namespace TableDependency.SqlClient.Test
10 | {
11 | [TestClass]
12 | public class WhereUnitTestToUpper
13 | {
14 | [TestMethod]
15 | public void ToUpper1()
16 | {
17 | // Arrange
18 | Expression> expression = p => p.Code.ToUpper() == "123";
19 |
20 | // Act
21 | var where = new SqlTableDependencyFilter(expression).Translate();
22 |
23 | // Assert
24 | Assert.AreEqual("(UPPER([Code]) = '123')", where);
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient.Test/WhereUnitTestTrim.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel.DataAnnotations.Schema;
3 | using System.Linq.Expressions;
4 |
5 | using Microsoft.VisualStudio.TestTools.UnitTesting;
6 |
7 | using TableDependency.SqlClient.Test.Models;
8 | using TableDependency.SqlClient.Where;
9 |
10 | namespace TableDependency.SqlClient.Test
11 | {
12 | [Table("TrimTest")]
13 | public class TrimTest
14 | {
15 | public string Name { get; set; }
16 |
17 | [Column("Long Description")]
18 | public string Description { get; set; }
19 | }
20 |
21 | [TestClass]
22 | public class WhereUnitTestTrim
23 | {
24 | [TestMethod]
25 | public void Trim1()
26 | {
27 | // Arrange
28 | Expression> expression = p => p.Code.Trim() == "123";
29 |
30 | // Act
31 | var where = new SqlTableDependencyFilter(expression).Translate();
32 |
33 | // Assert
34 | Assert.AreEqual("(LTRIM(RTRIM([Code])) = '123')", where);
35 | }
36 |
37 | [TestMethod]
38 | public void LTrim1()
39 | {
40 | // Arrange
41 | Expression> expression = p => p.Code.TrimEnd() == "123";
42 |
43 | // Act
44 | var where = new SqlTableDependencyFilter(expression).Translate();
45 |
46 | // Assert
47 | Assert.AreEqual("(RTRIM([Code]) = '123')", where);
48 | }
49 |
50 | [TestMethod]
51 | public void RTrim1()
52 | {
53 | // Arrange
54 | Expression> expression = p => p.Code.TrimStart() == "123";
55 |
56 | // Act
57 | var where = new SqlTableDependencyFilter(expression).Translate();
58 |
59 | // Assert
60 | Assert.AreEqual("(LTRIM([Code]) = '123')", where);
61 | }
62 |
63 | [TestMethod]
64 | public void LRTrim1()
65 | {
66 | // Arrange
67 | Expression> expression = p => p.Code.TrimStart() == "123" && p.Code.TrimEnd() == "123";
68 |
69 | // Act
70 | var where = new SqlTableDependencyFilter(expression).Translate();
71 |
72 | // Assert
73 | Assert.AreEqual("((LTRIM([Code]) = '123') AND (RTRIM([Code]) = '123'))", where);
74 | }
75 |
76 | [TestMethod]
77 | public void RLTrim1()
78 | {
79 | // Arrange
80 | Expression> expression = p => p.Code.TrimEnd() == "123" && p.Code.TrimStart() == "123";
81 |
82 | // Act
83 | var where = new SqlTableDependencyFilter(expression).Translate();
84 |
85 | // Assert
86 | Assert.AreEqual("((RTRIM([Code]) = '123') AND (LTRIM([Code]) = '123'))", where);
87 | }
88 | }
89 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient.Test/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/TableDependency.SqlClient/Base/Abstracts/IModelToTableMapper.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // TableDependency, SqlTableDependency
3 | // Copyright (c) 2015-2020 Christian Del Bianco. All rights reserved.
4 | //
5 | // Permission is hereby granted, free of charge, to any person
6 | // obtaining a copy of this software and associated documentation
7 | // files (the "Software"), to deal in the Software without
8 | // restriction, including without limitation the rights to use,
9 | // copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | // copies of the Software, and to permit persons to whom the
11 | // Software is furnished to do so, subject to the following
12 | // conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be
15 | // included in all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | // OTHER DEALINGS IN THE SOFTWARE.
25 | #endregion
26 |
27 | using System;
28 | using System.Collections.Generic;
29 | using System.Linq.Expressions;
30 | using System.Reflection;
31 |
32 | namespace TableDependency.SqlClient.Base.Abstracts
33 | {
34 | public interface IModelToTableMapper where T : class
35 | {
36 | ModelToTableMapper AddMapping(Expression> expression, string columnName);
37 | int Count();
38 | string GetMapping(PropertyInfo propertyInfo);
39 | IDictionary GetMappings();
40 | string GetMapping(string tableColumnName);
41 | }
42 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient/Base/Abstracts/ITableDependency.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // TableDependency, SqlTableDependency
3 | // Copyright (c) 2015-2020 Christian Del Bianco. All rights reserved.
4 | //
5 | // Permission is hereby granted, free of charge, to any person
6 | // obtaining a copy of this software and associated documentation
7 | // files (the "Software"), to deal in the Software without
8 | // restriction, including without limitation the rights to use,
9 | // copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | // copies of the Software, and to permit persons to whom the
11 | // Software is furnished to do so, subject to the following
12 | // conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be
15 | // included in all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | // OTHER DEALINGS IN THE SOFTWARE.
25 | #endregion
26 |
27 | using System;
28 | using System.Diagnostics;
29 | using System.Globalization;
30 | using System.Text;
31 |
32 | using TableDependency.SqlClient.Base.Delegates;
33 | using TableDependency.SqlClient.Base.Enums;
34 |
35 | namespace TableDependency.SqlClient.Base.Abstracts
36 | {
37 | public interface ITableDependency : IDisposable
38 | {
39 | #region Events
40 |
41 | event ErrorEventHandler OnError;
42 | event StatusEventHandler OnStatusChanged;
43 |
44 | #endregion
45 |
46 | #region Methods
47 |
48 | void Start(int timeOut = 120, int watchDogTimeOut = 180);
49 | void Stop();
50 |
51 | #endregion
52 |
53 | #region Properties
54 |
55 | TraceLevel TraceLevel { get; set; }
56 | TraceListener TraceListener { get; set; }
57 | TableDependencyStatus Status { get; }
58 | Encoding Encoding { get; set; }
59 | CultureInfo CultureInfo { get; set; }
60 | string DataBaseObjectsNamingConvention { get; }
61 | string TableName { get; }
62 | string SchemaName { get; }
63 |
64 | #endregion
65 | }
66 |
67 | public interface ITableDependency : ITableDependency where T : class, new()
68 | {
69 | #region Events
70 |
71 | event ChangedEventHandler OnChanged;
72 |
73 | #endregion
74 | }
75 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient/Base/Abstracts/ITableDependencyFilter.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // TableDependency, SqlTableDependency, SqlTableDependencyFilter
3 | // Copyright (c) 2015-2020 Christian Del Bianco. All rights reserved.
4 | //
5 | // Permission is hereby granted, free of charge, to any person
6 | // obtaining a copy of this software and associated documentation
7 | // files (the "Software"), to deal in the Software without
8 | // restriction, including without limitation the rights to use,
9 | // copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | // copies of the Software, and to permit persons to whom the
11 | // Software is furnished to do so, subject to the following
12 | // conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be
15 | // included in all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | // OTHER DEALINGS IN THE SOFTWARE.
25 | #endregion
26 |
27 | namespace TableDependency.SqlClient.Base.Abstracts
28 | {
29 | public interface ITableDependencyFilter
30 | {
31 | string Translate();
32 | }
33 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient/Base/Abstracts/IUpdateOfModel.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // TableDependency, SqlTableDependency
3 | // Copyright (c) 2015-2020 Christian Del Bianco. All rights reserved.
4 | //
5 | // Permission is hereby granted, free of charge, to any person
6 | // obtaining a copy of this software and associated documentation
7 | // files (the "Software"), to deal in the Software without
8 | // restriction, including without limitation the rights to use,
9 | // copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | // copies of the Software, and to permit persons to whom the
11 | // Software is furnished to do so, subject to the following
12 | // conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be
15 | // included in all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | // OTHER DEALINGS IN THE SOFTWARE.
25 | #endregion
26 |
27 | using System;
28 | using System.Collections.Generic;
29 | using System.Linq.Expressions;
30 | using System.Reflection;
31 |
32 | namespace TableDependency.SqlClient.Base.Abstracts
33 | {
34 | public interface IUpdateOfModel where T : class
35 | {
36 | void Add(params Expression>[] expressions);
37 | int Count();
38 | IList GetPropertiesInfos();
39 | }
40 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient/Base/Delegates/ChangedEventHandler.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // TableDependency, SqlTableDependency
3 | // Copyright (c) 2015-2020 Christian Del Bianco. All rights reserved.
4 | //
5 | // Permission is hereby granted, free of charge, to any person
6 | // obtaining a copy of this software and associated documentation
7 | // files (the "Software"), to deal in the Software without
8 | // restriction, including without limitation the rights to use,
9 | // copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | // copies of the Software, and to permit persons to whom the
11 | // Software is furnished to do so, subject to the following
12 | // conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be
15 | // included in all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | // OTHER DEALINGS IN THE SOFTWARE.
25 | #endregion
26 |
27 | using TableDependency.SqlClient.Base.EventArgs;
28 |
29 | namespace TableDependency.SqlClient.Base.Delegates
30 | {
31 | public delegate void ChangedEventHandler(object sender, RecordChangedEventArgs e) where T : class, new();
32 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient/Base/Delegates/ErrorEventHandler.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // TableDependency, SqlTableDependency
3 | // Copyright (c) 2015-2020 Christian Del Bianco. All rights reserved.
4 | //
5 | // Permission is hereby granted, free of charge, to any person
6 | // obtaining a copy of this software and associated documentation
7 | // files (the "Software"), to deal in the Software without
8 | // restriction, including without limitation the rights to use,
9 | // copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | // copies of the Software, and to permit persons to whom the
11 | // Software is furnished to do so, subject to the following
12 | // conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be
15 | // included in all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | // OTHER DEALINGS IN THE SOFTWARE.
25 | #endregion
26 |
27 | using TableDependency.SqlClient.Base.EventArgs;
28 |
29 | namespace TableDependency.SqlClient.Base.Delegates
30 | {
31 | public delegate void ErrorEventHandler(object sender, ErrorEventArgs e);
32 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient/Base/Delegates/StatusEventHandler.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // TableDependency, SqlTableDependency
3 | // Copyright (c) 2015-2020 Christian Del Bianco. All rights reserved.
4 | //
5 | // Permission is hereby granted, free of charge, to any person
6 | // obtaining a copy of this software and associated documentation
7 | // files (the "Software"), to deal in the Software without
8 | // restriction, including without limitation the rights to use,
9 | // copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | // copies of the Software, and to permit persons to whom the
11 | // Software is furnished to do so, subject to the following
12 | // conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be
15 | // included in all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | // OTHER DEALINGS IN THE SOFTWARE.
25 | #endregion
26 |
27 | using TableDependency.SqlClient.Base.EventArgs;
28 |
29 | namespace TableDependency.SqlClient.Base.Delegates
30 | {
31 | public delegate void StatusEventHandler(object sender, StatusChangedEventArgs e);
32 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient/Base/Enums/ChangeType.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // TableDependency, SqlTableDependency
3 | // Copyright (c) 2015-2020 Christian Del Bianco. All rights reserved.
4 | //
5 | // Permission is hereby granted, free of charge, to any person
6 | // obtaining a copy of this software and associated documentation
7 | // files (the "Software"), to deal in the Software without
8 | // restriction, including without limitation the rights to use,
9 | // copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | // copies of the Software, and to permit persons to whom the
11 | // Software is furnished to do so, subject to the following
12 | // conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be
15 | // included in all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | // OTHER DEALINGS IN THE SOFTWARE.
25 | #endregion
26 |
27 | namespace TableDependency.SqlClient.Base.Enums
28 | {
29 | public enum ChangeType
30 | {
31 | None,
32 | Delete,
33 | Insert,
34 | Update
35 | }
36 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient/Base/Enums/DmlTriggerType.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // TableDependency, SqlTableDependency
3 | // Copyright (c) 2015-2020 Christian Del Bianco. All rights reserved.
4 | //
5 | // Permission is hereby granted, free of charge, to any person
6 | // obtaining a copy of this software and associated documentation
7 | // files (the "Software"), to deal in the Software without
8 | // restriction, including without limitation the rights to use,
9 | // copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | // copies of the Software, and to permit persons to whom the
11 | // Software is furnished to do so, subject to the following
12 | // conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be
15 | // included in all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | // OTHER DEALINGS IN THE SOFTWARE.
25 | #endregion
26 |
27 | using System;
28 |
29 | namespace TableDependency.SqlClient.Base.Enums
30 | {
31 | [Flags]
32 | public enum DmlTriggerType
33 | {
34 | Delete = 1,
35 | Insert = 2,
36 | Update = 4,
37 | All = 8
38 | }
39 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient/Base/Enums/TableDependencyStatus.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // TableDependency, SqlTableDependency
3 | // Copyright (c) 2015-2020 Christian Del Bianco. All rights reserved.
4 | //
5 | // Permission is hereby granted, free of charge, to any person
6 | // obtaining a copy of this software and associated documentation
7 | // files (the "Software"), to deal in the Software without
8 | // restriction, including without limitation the rights to use,
9 | // copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | // copies of the Software, and to permit persons to whom the
11 | // Software is furnished to do so, subject to the following
12 | // conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be
15 | // included in all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | // OTHER DEALINGS IN THE SOFTWARE.
25 | #endregion
26 |
27 | namespace TableDependency.SqlClient.Base.Enums
28 | {
29 | public enum TableDependencyStatus
30 | {
31 | None,
32 | Starting,
33 | Started,
34 | WaitingForNotification,
35 | StopDueToCancellation,
36 | StopDueToError
37 | }
38 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient/Base/EventArgs/BaseEventArgs.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // TableDependency, SqlTableDependency
3 | // Copyright (c) 2015-2020 Christian Del Bianco. All rights reserved.
4 | //
5 | // Permission is hereby granted, free of charge, to any person
6 | // obtaining a copy of this software and associated documentation
7 | // files (the "Software"), to deal in the Software without
8 | // restriction, including without limitation the rights to use,
9 | // copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | // copies of the Software, and to permit persons to whom the
11 | // Software is furnished to do so, subject to the following
12 | // conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be
15 | // included in all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | // OTHER DEALINGS IN THE SOFTWARE.
25 | #endregion
26 |
27 | using System.Globalization;
28 |
29 | namespace TableDependency.SqlClient.Base.EventArgs
30 | {
31 | public abstract class BaseEventArgs : System.EventArgs
32 | {
33 | #region Properties
34 |
35 | public CultureInfo CultureInfo { get; protected set; }
36 | public string Server { get; protected set; }
37 | public string Database { get; protected set; }
38 | public string Sender { get; protected set; }
39 |
40 | #endregion
41 |
42 | #region Constructors
43 |
44 | protected BaseEventArgs(
45 | string server,
46 | string database,
47 | string sender,
48 | CultureInfo cultureInfo = null)
49 | {
50 | this.Server = server;
51 | this.Database = database;
52 | this.Sender = sender;
53 | this.CultureInfo = cultureInfo;
54 | }
55 |
56 | #endregion
57 | }
58 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient/Base/EventArgs/ErrorEventArgs.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // TableDependency, SqlTableDependency
3 | // Copyright (c) 2015-2020 Christian Del Bianco. All rights reserved.
4 | //
5 | // Permission is hereby granted, free of charge, to any person
6 | // obtaining a copy of this software and associated documentation
7 | // files (the "Software"), to deal in the Software without
8 | // restriction, including without limitation the rights to use,
9 | // copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | // copies of the Software, and to permit persons to whom the
11 | // Software is furnished to do so, subject to the following
12 | // conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be
15 | // included in all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | // OTHER DEALINGS IN THE SOFTWARE.
25 | #endregion
26 |
27 | using System;
28 |
29 | namespace TableDependency.SqlClient.Base.EventArgs
30 | {
31 | public class ErrorEventArgs : BaseEventArgs
32 | {
33 | #region Properties
34 |
35 | public string Message { get; }
36 |
37 | public Exception Error { get; protected set; }
38 |
39 | #endregion
40 |
41 | #region Constructors
42 |
43 | internal ErrorEventArgs(
44 | Exception e,
45 | string server,
46 | string database,
47 | string sender) : this("TableDependency stopped working", e, server, database, sender)
48 | {
49 |
50 | }
51 |
52 | internal ErrorEventArgs(
53 | string message,
54 | Exception e,
55 | string server,
56 | string database,
57 | string sender) : base(server, database, sender)
58 | {
59 | this.Message = message;
60 | this.Error = e;
61 | }
62 |
63 | #endregion
64 | }
65 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient/Base/EventArgs/StatusChangedEventArgs.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // TableDependency, SqlTableDependency
3 | // Copyright (c) 2015-2020 Christian Del Bianco. All rights reserved.
4 | //
5 | // Permission is hereby granted, free of charge, to any person
6 | // obtaining a copy of this software and associated documentation
7 | // files (the "Software"), to deal in the Software without
8 | // restriction, including without limitation the rights to use,
9 | // copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | // copies of the Software, and to permit persons to whom the
11 | // Software is furnished to do so, subject to the following
12 | // conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be
15 | // included in all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | // OTHER DEALINGS IN THE SOFTWARE.
25 | #endregion
26 |
27 | using TableDependency.SqlClient.Base.Enums;
28 |
29 | namespace TableDependency.SqlClient.Base.EventArgs
30 | {
31 | public class StatusChangedEventArgs : BaseEventArgs
32 | {
33 | #region Properties
34 |
35 | public TableDependencyStatus Status { get; protected set; }
36 |
37 | #endregion
38 |
39 | #region Constructors
40 |
41 | internal StatusChangedEventArgs(
42 | TableDependencyStatus status,
43 | string server,
44 | string database,
45 | string sender) : base(server, database, sender)
46 | {
47 | this.Status = status;
48 | }
49 |
50 | #endregion
51 | }
52 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient/Base/Exceptions/ColumnTypeNotSupportedException.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // TableDependency, SqlTableDependency
3 | // Copyright (c) 2015-2020 Christian Del Bianco. All rights reserved.
4 | //
5 | // Permission is hereby granted, free of charge, to any person
6 | // obtaining a copy of this software and associated documentation
7 | // files (the "Software"), to deal in the Software without
8 | // restriction, including without limitation the rights to use,
9 | // copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | // copies of the Software, and to permit persons to whom the
11 | // Software is furnished to do so, subject to the following
12 | // conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be
15 | // included in all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | // OTHER DEALINGS IN THE SOFTWARE.
25 | #endregion
26 |
27 | namespace TableDependency.SqlClient.Base.Exceptions
28 | {
29 | public class ColumnTypeNotSupportedException : TableDependencyException
30 | {
31 | public ColumnTypeNotSupportedException(string message = null)
32 | : base(message)
33 | {
34 |
35 | }
36 | }
37 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient/Base/Exceptions/DmlTriggerTypeException.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // TableDependency, SqlTableDependency
3 | // Copyright (c) 2015-2020 Christian Del Bianco. All rights reserved.
4 | //
5 | // Permission is hereby granted, free of charge, to any person
6 | // obtaining a copy of this software and associated documentation
7 | // files (the "Software"), to deal in the Software without
8 | // restriction, including without limitation the rights to use,
9 | // copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | // copies of the Software, and to permit persons to whom the
11 | // Software is furnished to do so, subject to the following
12 | // conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be
15 | // included in all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | // OTHER DEALINGS IN THE SOFTWARE.
25 | #endregion
26 |
27 | namespace TableDependency.SqlClient.Base.Exceptions
28 | {
29 | public class DmlTriggerTypeException : TableDependencyException
30 | {
31 | public DmlTriggerTypeException(string message = null)
32 | : base(message)
33 | {
34 |
35 | }
36 | }
37 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient/Base/Exceptions/InitializedStoppedException.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // TableDependency, SqlTableDependency
3 | // Copyright (c) 2015-2020 Christian Del Bianco. All rights reserved.
4 | //
5 | // Permission is hereby granted, free of charge, to any person
6 | // obtaining a copy of this software and associated documentation
7 | // files (the "Software"), to deal in the Software without
8 | // restriction, including without limitation the rights to use,
9 | // copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | // copies of the Software, and to permit persons to whom the
11 | // Software is furnished to do so, subject to the following
12 | // conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be
15 | // included in all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | // OTHER DEALINGS IN THE SOFTWARE.
25 | #endregion
26 |
27 | namespace TableDependency.SqlClient.Base.Exceptions
28 | {
29 | public class InitializedStoppedException : TableDependencyException
30 | {
31 | public InitializedStoppedException()
32 | : base("Initialization stopped.")
33 | {
34 |
35 | }
36 | }
37 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient/Base/Exceptions/InitializingStoppedException.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // TableDependency, SqlTableDependency
3 | // Copyright (c) 2015-2020 Christian Del Bianco. All rights reserved.
4 | //
5 | // Permission is hereby granted, free of charge, to any person
6 | // obtaining a copy of this software and associated documentation
7 | // files (the "Software"), to deal in the Software without
8 | // restriction, including without limitation the rights to use,
9 | // copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | // copies of the Software, and to permit persons to whom the
11 | // Software is furnished to do so, subject to the following
12 | // conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be
15 | // included in all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | // OTHER DEALINGS IN THE SOFTWARE.
25 | #endregion
26 |
27 | namespace TableDependency.SqlClient.Base.Exceptions
28 | {
29 | public class InitializingStoppedException : TableDependencyException
30 | {
31 | public InitializingStoppedException()
32 | : base("Initialization stopped.")
33 | {
34 |
35 | }
36 | }
37 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient/Base/Exceptions/InvalidConnectionStringException.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // TableDependency, SqlTableDependency
3 | // Copyright (c) 2015-2020 Christian Del Bianco. All rights reserved.
4 | //
5 | // Permission is hereby granted, free of charge, to any person
6 | // obtaining a copy of this software and associated documentation
7 | // files (the "Software"), to deal in the Software without
8 | // restriction, including without limitation the rights to use,
9 | // copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | // copies of the Software, and to permit persons to whom the
11 | // Software is furnished to do so, subject to the following
12 | // conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be
15 | // included in all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | // OTHER DEALINGS IN THE SOFTWARE.
25 | #endregion
26 |
27 | using System;
28 |
29 | namespace TableDependency.SqlClient.Base.Exceptions
30 | {
31 | public class InvalidConnectionStringException : TableDependencyException
32 | {
33 | public InvalidConnectionStringException(string connectionString, Exception innerException = null)
34 | : base($"Invalid connection string ({connectionString})", innerException)
35 | {
36 |
37 | }
38 | }
39 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient/Base/Exceptions/MessageMisalignedException.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // TableDependency, SqlTableDependency
3 | // Copyright (c) 2015-2020 Christian Del Bianco. All rights reserved.
4 | //
5 | // Permission is hereby granted, free of charge, to any person
6 | // obtaining a copy of this software and associated documentation
7 | // files (the "Software"), to deal in the Software without
8 | // restriction, including without limitation the rights to use,
9 | // copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | // copies of the Software, and to permit persons to whom the
11 | // Software is furnished to do so, subject to the following
12 | // conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be
15 | // included in all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | // OTHER DEALINGS IN THE SOFTWARE.
25 | #endregion
26 |
27 | namespace TableDependency.SqlClient.Base.Exceptions
28 | {
29 | public class MessageMisalignedException : TableDependencyException
30 | {
31 | public MessageMisalignedException(string message = null)
32 | : base(message)
33 | { }
34 | }
35 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient/Base/Exceptions/ModelToTableMapperException.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // TableDependency, SqlTableDependency
3 | // Copyright (c) 2015-2020 Christian Del Bianco. All rights reserved.
4 | //
5 | // Permission is hereby granted, free of charge, to any person
6 | // obtaining a copy of this software and associated documentation
7 | // files (the "Software"), to deal in the Software without
8 | // restriction, including without limitation the rights to use,
9 | // copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | // copies of the Software, and to permit persons to whom the
11 | // Software is furnished to do so, subject to the following
12 | // conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be
15 | // included in all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | // OTHER DEALINGS IN THE SOFTWARE.
25 | #endregion
26 |
27 | namespace TableDependency.SqlClient.Base.Exceptions
28 | {
29 | public class ModelToTableMapperException : TableDependencyException
30 | {
31 | public ModelToTableMapperException(string message)
32 | : base(message)
33 | { }
34 | }
35 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient/Base/Exceptions/NoColumnsException.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // TableDependency, SqlTableDependency
3 | // Copyright (c) 2015-2020 Christian Del Bianco. All rights reserved.
4 | //
5 | // Permission is hereby granted, free of charge, to any person
6 | // obtaining a copy of this software and associated documentation
7 | // files (the "Software"), to deal in the Software without
8 | // restriction, including without limitation the rights to use,
9 | // copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | // copies of the Software, and to permit persons to whom the
11 | // Software is furnished to do so, subject to the following
12 | // conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be
15 | // included in all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | // OTHER DEALINGS IN THE SOFTWARE.
25 | #endregion
26 |
27 | namespace TableDependency.SqlClient.Base.Exceptions
28 | {
29 | public class NoColumnsException : TableDependencyException
30 | {
31 | public NoColumnsException(string tableName)
32 | : base($"No columns for table {tableName}")
33 | { }
34 | }
35 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient/Base/Exceptions/NoMatchBetweenModelAndTableColumn.cs:
--------------------------------------------------------------------------------
1 | namespace TableDependency.SqlClient.Base.Exceptions
2 | {
3 | public class NoMatchBetweenModelAndTableColumn : TableDependencyException
4 | {
5 | public NoMatchBetweenModelAndTableColumn(string modelProperty)
6 | : base("Property {modelProperty} in your C# model has a value that is not compatible with the matching table columns.")
7 | { }
8 | }
9 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient/Base/Exceptions/NoMatchBetweenModelAndTableColumns.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // TableDependency, SqlTableDependency
3 | // Copyright (c) 2015-2020 Christian Del Bianco. All rights reserved.
4 | //
5 | // Permission is hereby granted, free of charge, to any person
6 | // obtaining a copy of this software and associated documentation
7 | // files (the "Software"), to deal in the Software without
8 | // restriction, including without limitation the rights to use,
9 | // copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | // copies of the Software, and to permit persons to whom the
11 | // Software is furnished to do so, subject to the following
12 | // conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be
15 | // included in all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | // OTHER DEALINGS IN THE SOFTWARE.
25 | #endregion
26 |
27 | namespace TableDependency.SqlClient.Base.Exceptions
28 | {
29 | public class NoMatchBetweenModelAndTableColumns : TableDependencyException
30 | {
31 | public NoMatchBetweenModelAndTableColumns(string message = null)
32 | : base(message ?? "Your C# model has no matching property with table columns.")
33 | { }
34 | }
35 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient/Base/Exceptions/NoSubscriberException.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // TableDependency, SqlTableDependency
3 | // Copyright (c) 2015-2020 Christian Del Bianco. All rights reserved.
4 | //
5 | // Permission is hereby granted, free of charge, to any person
6 | // obtaining a copy of this software and associated documentation
7 | // files (the "Software"), to deal in the Software without
8 | // restriction, including without limitation the rights to use,
9 | // copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | // copies of the Software, and to permit persons to whom the
11 | // Software is furnished to do so, subject to the following
12 | // conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be
15 | // included in all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | // OTHER DEALINGS IN THE SOFTWARE.
25 | #endregion
26 |
27 | namespace TableDependency.SqlClient.Base.Exceptions
28 | {
29 | public class NoSubscriberException : TableDependencyException
30 | {
31 | public NoSubscriberException()
32 | : base("No event subscribers registered for receiving notifications. Define an event handler method as event receiver.")
33 | { }
34 | }
35 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient/Base/Exceptions/NotExistingTableException.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // TableDependency, SqlTableDependency
3 | // Copyright (c) 2015-2020 Christian Del Bianco. All rights reserved.
4 | //
5 | // Permission is hereby granted, free of charge, to any person
6 | // obtaining a copy of this software and associated documentation
7 | // files (the "Software"), to deal in the Software without
8 | // restriction, including without limitation the rights to use,
9 | // copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | // copies of the Software, and to permit persons to whom the
11 | // Software is furnished to do so, subject to the following
12 | // conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be
15 | // included in all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | // OTHER DEALINGS IN THE SOFTWARE.
25 | #endregion
26 |
27 | namespace TableDependency.SqlClient.Base.Exceptions
28 | {
29 | public class NotExistingTableException : TableDependencyException
30 | {
31 | public NotExistingTableException(string tableName)
32 | : base($"I cannot find a database table named '{tableName}'.")
33 | { }
34 | }
35 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient/Base/Exceptions/TableDependencyException.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // TableDependency, SqlTableDependency
3 | // Copyright (c) 2015-2020 Christian Del Bianco. All rights reserved.
4 | //
5 | // Permission is hereby granted, free of charge, to any person
6 | // obtaining a copy of this software and associated documentation
7 | // files (the "Software"), to deal in the Software without
8 | // restriction, including without limitation the rights to use,
9 | // copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | // copies of the Software, and to permit persons to whom the
11 | // Software is furnished to do so, subject to the following
12 | // conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be
15 | // included in all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | // OTHER DEALINGS IN THE SOFTWARE.
25 | #endregion
26 |
27 | using System;
28 |
29 | namespace TableDependency.SqlClient.Base.Exceptions
30 | {
31 | public abstract class TableDependencyException : Exception
32 | {
33 | protected TableDependencyException(string message, Exception innerException = null)
34 | : base(message, innerException)
35 | { }
36 | }
37 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient/Base/Exceptions/TableWithNoColumnsException.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // TableDependency, SqlTableDependency
3 | // Copyright (c) 2015-2020 Christian Del Bianco. All rights reserved.
4 | //
5 | // Permission is hereby granted, free of charge, to any person
6 | // obtaining a copy of this software and associated documentation
7 | // files (the "Software"), to deal in the Software without
8 | // restriction, including without limitation the rights to use,
9 | // copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | // copies of the Software, and to permit persons to whom the
11 | // Software is furnished to do so, subject to the following
12 | // conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be
15 | // included in all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | // OTHER DEALINGS IN THE SOFTWARE.
25 | #endregion
26 |
27 | namespace TableDependency.SqlClient.Base.Exceptions
28 | {
29 | public class TableWithNoColumnsException : TableDependencyException
30 | {
31 | public TableWithNoColumnsException(string tableName)
32 | : base($"I cannot find any column for table named '{tableName}'.")
33 | {
34 |
35 | }
36 | }
37 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient/Base/Exceptions/UpdateOfException.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // TableDependency, SqlTableDependency
3 | // Copyright (c) 2015-2020 Christian Del Bianco. All rights reserved.
4 | //
5 | // Permission is hereby granted, free of charge, to any person
6 | // obtaining a copy of this software and associated documentation
7 | // files (the "Software"), to deal in the Software without
8 | // restriction, including without limitation the rights to use,
9 | // copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | // copies of the Software, and to permit persons to whom the
11 | // Software is furnished to do so, subject to the following
12 | // conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be
15 | // included in all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | // OTHER DEALINGS IN THE SOFTWARE.
25 | #endregion
26 |
27 | namespace TableDependency.SqlClient.Base.Exceptions
28 | {
29 | public class UpdateOfException : TableDependencyException
30 | {
31 | public UpdateOfException(string message)
32 | : base(message)
33 | {
34 |
35 | }
36 | }
37 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient/Base/Exceptions/UpdateOfModelException.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // TableDependency, SqlTableDependency
3 | // Copyright (c) 2015-2020 Christian Del Bianco. All rights reserved.
4 | //
5 | // Permission is hereby granted, free of charge, to any person
6 | // obtaining a copy of this software and associated documentation
7 | // files (the "Software"), to deal in the Software without
8 | // restriction, including without limitation the rights to use,
9 | // copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | // copies of the Software, and to permit persons to whom the
11 | // Software is furnished to do so, subject to the following
12 | // conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be
15 | // included in all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | // OTHER DEALINGS IN THE SOFTWARE.
25 | #endregion
26 |
27 | namespace TableDependency.SqlClient.Base.Exceptions
28 | {
29 | public class UpdateOfModelException : TableDependencyException
30 | {
31 | public UpdateOfModelException(string message)
32 | : base(message)
33 | {
34 |
35 | }
36 | }
37 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient/Base/Exceptions/WatchDogTimeOutException.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // TableDependency, SqlTableDependency
3 | // Copyright (c) 2015-2020 Christian Del Bianco. All rights reserved.
4 | //
5 | // Permission is hereby granted, free of charge, to any person
6 | // obtaining a copy of this software and associated documentation
7 | // files (the "Software"), to deal in the Software without
8 | // restriction, including without limitation the rights to use,
9 | // copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | // copies of the Software, and to permit persons to whom the
11 | // Software is furnished to do so, subject to the following
12 | // conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be
15 | // included in all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | // OTHER DEALINGS IN THE SOFTWARE.
25 | #endregion
26 |
27 | namespace TableDependency.SqlClient.Base.Exceptions
28 | {
29 | public class WatchDogTimeOutException : TableDependencyException
30 | {
31 | public WatchDogTimeOutException(string message = null)
32 | : base(message)
33 | { }
34 | }
35 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient/Base/Messages/Message.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // TableDependency, SqlTableDependency
3 | // Copyright (c) 2015-2020 Christian Del Bianco. All rights reserved.
4 | //
5 | // Permission is hereby granted, free of charge, to any person
6 | // obtaining a copy of this software and associated documentation
7 | // files (the "Software"), to deal in the Software without
8 | // restriction, including without limitation the rights to use,
9 | // copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | // copies of the Software, and to permit persons to whom the
11 | // Software is furnished to do so, subject to the following
12 | // conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be
15 | // included in all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | // OTHER DEALINGS IN THE SOFTWARE.
25 | #endregion
26 |
27 | using System;
28 |
29 | namespace TableDependency.SqlClient.Base.Messages
30 | {
31 | public class Message
32 | {
33 | #region Properties
34 |
35 | public bool IsOldValue => this.MessageType.EndsWith("/old", StringComparison.InvariantCultureIgnoreCase);
36 | public string MessageType { get; }
37 | public string Recipient { get; }
38 | public byte[] Body { get; }
39 |
40 | #endregion
41 |
42 | #region Constructors
43 |
44 | public Message(string messageType, byte[] body)
45 | {
46 | this.Recipient = this.GetRecipient(messageType);
47 | this.Body = body;
48 | this.MessageType = messageType;
49 | }
50 |
51 | #endregion
52 |
53 | #region Private methods
54 |
55 | private string GetRecipient(string rawMessageType)
56 | {
57 | var messageTypeTokens = rawMessageType.Split('/');
58 |
59 | return rawMessageType.EndsWith("/old", StringComparison.InvariantCultureIgnoreCase)
60 | ? messageTypeTokens[messageTypeTokens.Length - 2]
61 | : messageTypeTokens[messageTypeTokens.Length - 1];
62 | }
63 |
64 | #endregion
65 | }
66 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient/Base/Messages/MessagesBagStatus.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // TableDependency, SqlTableDependency
3 | // Copyright (c) 2015-2020 Christian Del Bianco. All rights reserved.
4 | //
5 | // Permission is hereby granted, free of charge, to any person
6 | // obtaining a copy of this software and associated documentation
7 | // files (the "Software"), to deal in the Software without
8 | // restriction, including without limitation the rights to use,
9 | // copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | // copies of the Software, and to permit persons to whom the
11 | // Software is furnished to do so, subject to the following
12 | // conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be
15 | // included in all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | // OTHER DEALINGS IN THE SOFTWARE.
25 | #endregion
26 |
27 | namespace TableDependency.SqlClient.Base.Messages
28 | {
29 | public enum MessagesBagStatus
30 | {
31 | Empty,
32 | Collecting,
33 | Ready
34 | }
35 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient/Base/UpdateOfModel.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // TableDependency, SqlTableDependency
3 | // Copyright (c) 2015-2020 Christian Del Bianco. All rights reserved.
4 | //
5 | // Permission is hereby granted, free of charge, to any person
6 | // obtaining a copy of this software and associated documentation
7 | // files (the "Software"), to deal in the Software without
8 | // restriction, including without limitation the rights to use,
9 | // copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | // copies of the Software, and to permit persons to whom the
11 | // Software is furnished to do so, subject to the following
12 | // conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be
15 | // included in all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | // OTHER DEALINGS IN THE SOFTWARE.
25 | #endregion
26 |
27 | using System;
28 | using System.Collections.Generic;
29 | using System.Linq.Expressions;
30 | using System.Reflection;
31 |
32 | using TableDependency.SqlClient.Base.Abstracts;
33 | using TableDependency.SqlClient.Base.Exceptions;
34 |
35 | namespace TableDependency.SqlClient.Base
36 | {
37 | public class UpdateOfModel : IUpdateOfModel where T : class
38 | {
39 | private readonly List _updateOfList = new List();
40 |
41 | ///
42 | /// Adds a property name used to specifying which table column must be monitored for changes.
43 | ///
44 | /// The expressions.
45 | public void Add(params Expression>[] expressions)
46 | {
47 | if (expressions != null && expressions.Length > 0)
48 | {
49 | foreach (var expression in expressions)
50 | {
51 | if (expression.Body is MemberExpression memberExpression)
52 | {
53 | _updateOfList.Add((PropertyInfo)memberExpression.Member);
54 | }
55 | else
56 | {
57 | var unaryExpression = expression.Body as UnaryExpression;
58 | if (unaryExpression?.Operand is MemberExpression memberExpressionByOperator)
59 | {
60 | _updateOfList.Add((PropertyInfo)memberExpressionByOperator.Member);
61 | }
62 | else
63 | {
64 | throw new UpdateOfModelException("'expression' parameter should be a member expression.");
65 | }
66 | }
67 | }
68 | }
69 | else
70 | {
71 | throw new UpdateOfModelException("UpdateOfModel cannot be empty.");
72 | }
73 | }
74 |
75 | ///
76 | /// Counts this instance.
77 | ///
78 | ///
79 | public int Count()
80 | {
81 | return _updateOfList.Count;
82 | }
83 |
84 | ///
85 | /// Gets the properties infos.
86 | ///
87 | ///
88 | public IList GetPropertiesInfos()
89 | {
90 | return _updateOfList;
91 | }
92 | }
93 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient/Base/Utilities/EnumUtil.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // TableDependency, SqlTableDependency
3 | // Copyright (c) 2015-2020 Christian Del Bianco. All rights reserved.
4 | //
5 | // Permission is hereby granted, free of charge, to any person
6 | // obtaining a copy of this software and associated documentation
7 | // files (the "Software"), to deal in the Software without
8 | // restriction, including without limitation the rights to use,
9 | // copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | // copies of the Software, and to permit persons to whom the
11 | // Software is furnished to do so, subject to the following
12 | // conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be
15 | // included in all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | // OTHER DEALINGS IN THE SOFTWARE.
25 | #endregion
26 |
27 | using System;
28 | using System.ComponentModel;
29 | using System.Linq;
30 |
31 | namespace TableDependency.SqlClient.Base.Utilities
32 | {
33 | public static class EnumUtil
34 | {
35 | public static string GetDescriptionFromEnumValue(Enum value)
36 | {
37 | var attribute = value.GetType()
38 | .GetField(value.ToString())
39 | .GetCustomAttributes(typeof(DescriptionAttribute), false)
40 | .SingleOrDefault() as DescriptionAttribute;
41 |
42 | return attribute == null ? value.ToString() : attribute.Description;
43 | }
44 | }
45 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient/Base/Utilities/ModelToTableMapperHelper.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // TableDependency, SqlTableDependency
3 | // Copyright (c) 2015-2020 Christian Del Bianco. All rights reserved.
4 | //
5 | // Permission is hereby granted, free of charge, to any person
6 | // obtaining a copy of this software and associated documentation
7 | // files (the "Software"), to deal in the Software without
8 | // restriction, including without limitation the rights to use,
9 | // copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | // copies of the Software, and to permit persons to whom the
11 | // Software is furnished to do so, subject to the following
12 | // conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be
15 | // included in all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | // OTHER DEALINGS IN THE SOFTWARE.
25 | #endregion
26 |
27 | using System.Collections.Generic;
28 | using System.ComponentModel.DataAnnotations.Schema;
29 | using System.Linq;
30 | using System.Reflection;
31 |
32 | using TableDependency.SqlClient.Base.Abstracts;
33 |
34 | namespace TableDependency.SqlClient.Base.Utilities
35 | {
36 | public static class ModelToTableMapperHelper where T : class, new()
37 | {
38 | public static IModelToTableMapper GetModelMapperFromColumnDataAnnotation(IEnumerable tableColumns)
39 | {
40 | var modelPropertyInfosWithColumnAttribute = typeof(T)
41 | .GetProperties(BindingFlags.GetProperty | BindingFlags.Instance | BindingFlags.Public)
42 | .Where(x => CustomAttributeExtensions.IsDefined((MemberInfo)x, typeof(ColumnAttribute), false))
43 | .ToArray();
44 |
45 | if (!modelPropertyInfosWithColumnAttribute.Any()) return null;
46 |
47 | var mapper = new ModelToTableMapper();
48 | foreach (var propertyInfo in modelPropertyInfosWithColumnAttribute)
49 | {
50 | var attribute = propertyInfo.GetCustomAttribute(typeof(ColumnAttribute));
51 | var dbColumnName = ((ColumnAttribute)attribute)?.Name;
52 | if (string.IsNullOrWhiteSpace(dbColumnName) && tableColumns.Any(tc => tc.Name == propertyInfo.Name))
53 | {
54 | dbColumnName = propertyInfo.Name;
55 | mapper.AddMapping(propertyInfo, dbColumnName);
56 | continue;
57 | }
58 |
59 | if (!string.IsNullOrWhiteSpace(dbColumnName))
60 | {
61 | mapper.AddMapping(propertyInfo, dbColumnName);
62 | }
63 | }
64 |
65 | return mapper;
66 | }
67 | }
68 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient/Base/Utilities/ModelUtil.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // TableDependency, SqlTableDependency
3 | // Copyright (c) 2015-2020 Christian Del Bianco. All rights reserved.
4 | //
5 | // Permission is hereby granted, free of charge, to any person
6 | // obtaining a copy of this software and associated documentation
7 | // files (the "Software"), to deal in the Software without
8 | // restriction, including without limitation the rights to use,
9 | // copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | // copies of the Software, and to permit persons to whom the
11 | // Software is furnished to do so, subject to the following
12 | // conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be
15 | // included in all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | // OTHER DEALINGS IN THE SOFTWARE.
25 | #endregion
26 |
27 | using System;
28 | using System.Collections.Generic;
29 | using System.Linq;
30 | using System.Reflection;
31 |
32 | namespace TableDependency.SqlClient.Base.Utilities
33 | {
34 | public static class ModelUtil
35 | {
36 | private static readonly IList ProcessableModelTypes = new List
37 | {
38 | typeof (string),
39 | typeof (char),
40 | typeof (short), typeof (short?),
41 | typeof (int), typeof (int?),
42 | typeof (long), typeof (long?),
43 | typeof (decimal), typeof (decimal?),
44 | typeof (float), typeof (float?),
45 | typeof (DateTime), typeof (DateTime?),
46 | typeof (DateTimeOffset), typeof (DateTimeOffset?),
47 | typeof (TimeSpan),
48 | typeof (double), typeof (double?),
49 | typeof (bool), typeof (bool?),
50 | typeof (byte[]),
51 | typeof (char[]),
52 | typeof (sbyte),
53 | typeof (byte),
54 | typeof (Guid),
55 | typeof (Enum)
56 | };
57 |
58 | public static IEnumerable GetModelPropertiesInfo()
59 | {
60 | return typeof(T)
61 | .GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.SetField)
62 | .Where(propertyInfo => ModelUtil.ProcessableModelTypes.Contains(propertyInfo.PropertyType) || propertyInfo.PropertyType.GetTypeInfo().IsEnum || (propertyInfo.PropertyType.GetTypeInfo().IsGenericType && propertyInfo.PropertyType.GetGenericTypeDefinition() == typeof(Nullable<>)))
63 | .ToArray();
64 | }
65 | }
66 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient/Base/Utilities/Separator.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | #endregion
3 |
4 | using System;
5 |
6 | namespace TableDependency.SqlClient.Base.Utilities
7 | {
8 | public class Separator
9 | {
10 | private int _currentIndex = 1;
11 | private int _startIndex;
12 | private string _separator;
13 |
14 | public Separator(string separator) : this(1, separator)
15 | {
16 | }
17 |
18 | public Separator(int startIndex, string separator)
19 | {
20 | _separator = separator;
21 | _startIndex = startIndex;
22 | }
23 |
24 | public Separator(int startIndex, char separator)
25 | {
26 | _separator = String.Concat(String.Empty, separator);
27 | _startIndex = startIndex;
28 | }
29 |
30 | public string GetSeparator()
31 | {
32 | return _currentIndex++ >= _startIndex ? _separator : String.Empty;
33 | }
34 |
35 | public void Reset()
36 | {
37 | _currentIndex = 1;
38 | }
39 |
40 | public void Reset(int startIndex, string separator)
41 | {
42 | _currentIndex = 1;
43 | _separator = separator;
44 | _startIndex = startIndex;
45 | }
46 |
47 | public void Reset(int startIndex)
48 | {
49 | _currentIndex = 1;
50 | _startIndex = startIndex;
51 | }
52 | }
53 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient/Base/Utilities/TableColumnInfo.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // TableDependency, SqlTableDependency
3 | // Copyright (c) 2015-2020 Christian Del Bianco. All rights reserved.
4 | //
5 | // Permission is hereby granted, free of charge, to any person
6 | // obtaining a copy of this software and associated documentation
7 | // files (the "Software"), to deal in the Software without
8 | // restriction, including without limitation the rights to use,
9 | // copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | // copies of the Software, and to permit persons to whom the
11 | // Software is furnished to do so, subject to the following
12 | // conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be
15 | // included in all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | // OTHER DEALINGS IN THE SOFTWARE.
25 | #endregion
26 |
27 | namespace TableDependency.SqlClient.Base.Utilities
28 | {
29 | public class TableColumnInfo
30 | {
31 | public TableColumnInfo(string name, string type, string size = null)
32 | {
33 | this.Name = name;
34 | this.Type = type;
35 | this.Size = size;
36 | }
37 |
38 | public string Name { get; set; }
39 | public string Type { get; set; }
40 | public string Size { get; set; }
41 | }
42 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient/Enumerations/ConversationEndpointState.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // TableDependency, SqlTableDependency
3 | // Copyright (c) 2015-2020 Christian Del Bianco. All rights reserved.
4 | //
5 | // Permission is hereby granted, free of charge, to any person
6 | // obtaining a copy of this software and associated documentation
7 | // files (the "Software"), to deal in the Software without
8 | // restriction, including without limitation the rights to use,
9 | // copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | // copies of the Software, and to permit persons to whom the
11 | // Software is furnished to do so, subject to the following
12 | // conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be
15 | // included in all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | // OTHER DEALINGS IN THE SOFTWARE.
25 | #endregion
26 |
27 | using System.ComponentModel;
28 |
29 | namespace TableDependency.SqlClient.Enumerations
30 | {
31 | ///
32 | /// https://docs.microsoft.com/en-us/sql/relational-databases/system-catalog-views/sys-conversation-endpoints-transact-sql?view=sql-server-2017
33 | ///
34 | public enum ConversationEndpointState
35 | {
36 | [Description("STARTED_OUTBOUND")]
37 | SO,
38 |
39 | [Description("STARTED_INBOUND")]
40 | SI,
41 |
42 | [Description("CONVERSING")]
43 | CO,
44 |
45 | [Description("DISCONNECTED_INBOUND")]
46 | DI,
47 |
48 | [Description("DISCONNECTED_OUTBOUND")]
49 | DO,
50 |
51 | [Description("ERROR")]
52 | ER,
53 |
54 | [Description("CLOSED")]
55 | CD
56 | }
57 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient/Enumerations/SqlServerRequiredPermission.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // TableDependency, SqlTableDependency
3 | // Copyright (c) 2015-2020 Christian Del Bianco. All rights reserved.
4 | //
5 | // Permission is hereby granted, free of charge, to any person
6 | // obtaining a copy of this software and associated documentation
7 | // files (the "Software"), to deal in the Software without
8 | // restriction, including without limitation the rights to use,
9 | // copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | // copies of the Software, and to permit persons to whom the
11 | // Software is furnished to do so, subject to the following
12 | // conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be
15 | // included in all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | // OTHER DEALINGS IN THE SOFTWARE.
25 | #endregion
26 |
27 | using System.ComponentModel;
28 |
29 | namespace TableDependency.SqlClient.Enumerations
30 | {
31 | ///
32 | /// https://msdn.microsoft.com/en-us/library/ms178569.aspx
33 | ///
34 | internal enum SqlServerRequiredPermission
35 | {
36 | [Description("ALTER")]
37 | Alter,
38 |
39 | [Description("CONNECT")]
40 | Connect,
41 |
42 | [Description("CONTROL")]
43 | Control,
44 |
45 | [Description("CREATE CONTRACT")]
46 | CreateContract,
47 |
48 | [Description("CREATE MESSAGE TYPE")]
49 | CreateMessageType,
50 |
51 | [Description("CREATE PROCEDURE")]
52 | CreateProcedure,
53 |
54 | [Description("CREATE QUEUE")]
55 | CreateQueue,
56 |
57 | [Description("CREATE SERVICE")]
58 | CreateService,
59 |
60 | [Description("EXECUTE")]
61 | Execute,
62 |
63 | [Description("SELECT")]
64 | Select,
65 |
66 | [Description("SUBSCRIBE QUERY NOTIFICATIONS")]
67 | SubscribeForQueryNotifications,
68 |
69 | [Description("VIEW DATABASE STATE")]
70 | ViewDatabaseState,
71 |
72 | [Description("VIEW DEFINITION")]
73 | ViewDefinition
74 | }
75 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient/Enumerations/SqlServerVersion.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // TableDependency, SqlTableDependency
3 | // Copyright (c) 2015-2020 Christian Del Bianco. All rights reserved.
4 | //
5 | // Permission is hereby granted, free of charge, to any person
6 | // obtaining a copy of this software and associated documentation
7 | // files (the "Software"), to deal in the Software without
8 | // restriction, including without limitation the rights to use,
9 | // copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | // copies of the Software, and to permit persons to whom the
11 | // Software is furnished to do so, subject to the following
12 | // conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be
15 | // included in all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | // OTHER DEALINGS IN THE SOFTWARE.
25 | #endregion
26 |
27 | namespace TableDependency.SqlClient.Enumerations
28 | {
29 | public enum SqlServerVersion
30 | {
31 | Unknown = 0,
32 | SqlServer2000 = 2000,
33 | SqlServer2005 = 2005,
34 | SqlServer2008 = 2008,
35 | SqlServer2012 = 2012,
36 | SqlServerLatest = int.MaxValue
37 | }
38 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient/EventArgs/SqlRecordChangedEventArgs.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // TableDependency, SqlTableDependency
3 | // Copyright (c) 2015-2020 Christian Del Bianco. All rights reserved.
4 | //
5 | // Permission is hereby granted, free of charge, to any person
6 | // obtaining a copy of this software and associated documentation
7 | // files (the "Software"), to deal in the Software without
8 | // restriction, including without limitation the rights to use,
9 | // copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | // copies of the Software, and to permit persons to whom the
11 | // Software is furnished to do so, subject to the following
12 | // conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be
15 | // included in all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | // OTHER DEALINGS IN THE SOFTWARE.
25 | #endregion
26 |
27 | using System;
28 | using System.Collections.Generic;
29 | using System.Globalization;
30 | using System.Reflection;
31 | using System.Text;
32 |
33 | using TableDependency.SqlClient.Base.Abstracts;
34 | using TableDependency.SqlClient.Base.EventArgs;
35 | using TableDependency.SqlClient.Base.Messages;
36 | using TableDependency.SqlClient.Base.Utilities;
37 | using TableDependency.SqlClient.Extensions;
38 |
39 | namespace TableDependency.SqlClient.EventArgs
40 | {
41 | public sealed class SqlRecordChangedEventArgs : RecordChangedEventArgs where T : class, new()
42 | {
43 | public SqlRecordChangedEventArgs(
44 | MessagesBag messagesBag,
45 | IModelToTableMapper mapper,
46 | IEnumerable userInterestedColumns,
47 | string server,
48 | string database,
49 | string sender,
50 | CultureInfo cultureInfo,
51 | bool includeOldValues) : base(
52 | messagesBag,
53 | mapper,
54 | userInterestedColumns,
55 | server,
56 | database,
57 | sender,
58 | cultureInfo,
59 | includeOldValues)
60 | {
61 | }
62 |
63 | public override object GetValue(PropertyInfo entityPropertyInfo, TableColumnInfo columnInfo, byte[] message)
64 | {
65 | if (message == null || message.Length == 0) return null;
66 |
67 | if (entityPropertyInfo.PropertyType.GetTypeInfo().IsEnum)
68 | {
69 | var stringValue = Encoding.Unicode.GetString(message);
70 | var value = Enum.Parse(entityPropertyInfo.PropertyType, stringValue);
71 | return value.GetHashCode();
72 | }
73 |
74 | if (entityPropertyInfo.PropertyType == typeof(byte[])) return message;
75 |
76 | if (entityPropertyInfo.PropertyType == typeof(bool) || entityPropertyInfo.PropertyType == typeof(bool?)) return Encoding.Unicode.GetString(message).ToBoolean();
77 |
78 | if (entityPropertyInfo.PropertyType == typeof(char[])) return Encoding.Unicode.GetString(message).ToCharArray();
79 |
80 | return base.GetValue(entityPropertyInfo, columnInfo, message);
81 | }
82 | }
83 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient/Exceptions/DbObjectsWithSameNameException.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // TableDependency, SqlTableDependency
3 | // Copyright (c) 2015-2020 Christian Del Bianco. All rights reserved.
4 | //
5 | // Permission is hereby granted, free of charge, to any person
6 | // obtaining a copy of this software and associated documentation
7 | // files (the "Software"), to deal in the Software without
8 | // restriction, including without limitation the rights to use,
9 | // copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | // copies of the Software, and to permit persons to whom the
11 | // Software is furnished to do so, subject to the following
12 | // conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be
15 | // included in all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | // OTHER DEALINGS IN THE SOFTWARE.
25 | #endregion
26 |
27 | using TableDependency.SqlClient.Base.Exceptions;
28 |
29 | namespace TableDependency.SqlClient.Exceptions
30 | {
31 | public class DbObjectsWithSameNameException : TableDependencyException
32 | {
33 | protected internal DbObjectsWithSameNameException(string naming)
34 | : base($"Already existing database objects (queue, trigger, stored procedure or service broker) with name '{naming}'.")
35 | { }
36 | }
37 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient/Exceptions/ImpossibleOpenSqlConnectionException.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // TableDependency, SqlTableDependency
3 | // Copyright (c) 2015-2020 Christian Del Bianco. All rights reserved.
4 | //
5 | // Permission is hereby granted, free of charge, to any person
6 | // obtaining a copy of this software and associated documentation
7 | // files (the "Software"), to deal in the Software without
8 | // restriction, including without limitation the rights to use,
9 | // copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | // copies of the Software, and to permit persons to whom the
11 | // Software is furnished to do so, subject to the following
12 | // conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be
15 | // included in all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | // OTHER DEALINGS IN THE SOFTWARE.
25 | #endregion
26 |
27 | using System;
28 |
29 | using TableDependency.SqlClient.Base.Exceptions;
30 |
31 | namespace TableDependency.SqlClient.Exceptions
32 | {
33 | public class ImpossibleOpenSqlConnectionException : TableDependencyException
34 | {
35 | protected internal ImpossibleOpenSqlConnectionException(string connectionString, Exception exception)
36 | : base($"Impossible open db connection using the following connection string '{connectionString}'.", exception)
37 | { }
38 | }
39 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient/Exceptions/QueueContainingErrorMessageException.cs:
--------------------------------------------------------------------------------
1 | using TableDependency.SqlClient.Base.Exceptions;
2 | using TableDependency.SqlClient.Messages;
3 |
4 | namespace TableDependency.SqlClient.Exceptions
5 | {
6 | public class QueueContainingErrorMessageException : TableDependencyException
7 | {
8 | public QueueContainingErrorMessageException() : base($"Queue containig a '{SqlMessageTypes.ErrorType}' message.")
9 | {
10 | }
11 | }
12 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient/Exceptions/SanitizeVariableNameException.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // TableDependency, SqlTableDependency
3 | // Copyright (c) 2015-2020 Christian Del Bianco. All rights reserved.
4 | //
5 | // Permission is hereby granted, free of charge, to any person
6 | // obtaining a copy of this software and associated documentation
7 | // files (the "Software"), to deal in the Software without
8 | // restriction, including without limitation the rights to use,
9 | // copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | // copies of the Software, and to permit persons to whom the
11 | // Software is furnished to do so, subject to the following
12 | // conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be
15 | // included in all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | // OTHER DEALINGS IN THE SOFTWARE.
25 | #endregion
26 |
27 | using TableDependency.SqlClient.Base.Exceptions;
28 |
29 | namespace TableDependency.SqlClient.Exceptions
30 | {
31 | public class SanitizeVariableNameException : TableDependencyException
32 | {
33 | protected internal SanitizeVariableNameException(string tableColumnName)
34 | : base($"Impossible to define a variable for table column '{tableColumnName}'.")
35 | { }
36 | }
37 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient/Exceptions/ServiceBrokerConversationHandlerInvalidException.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // TableDependency, SqlTableDependency
3 | // Copyright (c) 2015-2020 Christian Del Bianco. All rights reserved.
4 | //
5 | // Permission is hereby granted, free of charge, to any person
6 | // obtaining a copy of this software and associated documentation
7 | // files (the "Software"), to deal in the Software without
8 | // restriction, including without limitation the rights to use,
9 | // copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | // copies of the Software, and to permit persons to whom the
11 | // Software is furnished to do so, subject to the following
12 | // conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be
15 | // included in all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | // OTHER DEALINGS IN THE SOFTWARE.
25 | #endregion
26 |
27 | using TableDependency.SqlClient.Base.Exceptions;
28 |
29 | namespace TableDependency.SqlClient.Exceptions
30 | {
31 | public class ServiceBrokerConversationHandlerInvalidException : TableDependencyException
32 | {
33 | protected internal ServiceBrokerConversationHandlerInvalidException()
34 | : base($"Conversation handle invalid.")
35 | { }
36 | }
37 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient/Exceptions/ServiceBrokerEndDialogException.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // TableDependency, SqlTableDependency
3 | // Copyright (c) 2015-2020 Christian Del Bianco. All rights reserved.
4 | //
5 | // Permission is hereby granted, free of charge, to any person
6 | // obtaining a copy of this software and associated documentation
7 | // files (the "Software"), to deal in the Software without
8 | // restriction, including without limitation the rights to use,
9 | // copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | // copies of the Software, and to permit persons to whom the
11 | // Software is furnished to do so, subject to the following
12 | // conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be
15 | // included in all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | // OTHER DEALINGS IN THE SOFTWARE.
25 | #endregion
26 |
27 | using TableDependency.SqlClient.Base.Exceptions;
28 |
29 | namespace TableDependency.SqlClient.Exceptions
30 | {
31 | public class ServiceBrokerEndDialogException : TableDependencyException
32 | {
33 | protected internal ServiceBrokerEndDialogException(string naming)
34 | : base($"Service broker '{naming}' ended the conversation.")
35 | { }
36 | }
37 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient/Exceptions/ServiceBrokerErrorMessageException.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // TableDependency, SqlTableDependency
3 | // Copyright (c) 2015-2020 Christian Del Bianco. All rights reserved.
4 | //
5 | // Permission is hereby granted, free of charge, to any person
6 | // obtaining a copy of this software and associated documentation
7 | // files (the "Software"), to deal in the Software without
8 | // restriction, including without limitation the rights to use,
9 | // copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | // copies of the Software, and to permit persons to whom the
11 | // Software is furnished to do so, subject to the following
12 | // conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be
15 | // included in all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | // OTHER DEALINGS IN THE SOFTWARE.
25 | #endregion
26 |
27 | using TableDependency.SqlClient.Base.Exceptions;
28 |
29 | namespace TableDependency.SqlClient.Exceptions
30 | {
31 | public class ServiceBrokerErrorMessageException : TableDependencyException
32 | {
33 | protected internal ServiceBrokerErrorMessageException(string naming)
34 | : base($"Service broker '{naming}' send an error message.")
35 | { }
36 | }
37 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient/Exceptions/ServiceBrokerNotEnabledException.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // TableDependency, SqlTableDependency
3 | // Copyright (c) 2015-2020 Christian Del Bianco. All rights reserved.
4 | //
5 | // Permission is hereby granted, free of charge, to any person
6 | // obtaining a copy of this software and associated documentation
7 | // files (the "Software"), to deal in the Software without
8 | // restriction, including without limitation the rights to use,
9 | // copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | // copies of the Software, and to permit persons to whom the
11 | // Software is furnished to do so, subject to the following
12 | // conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be
15 | // included in all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | // OTHER DEALINGS IN THE SOFTWARE.
25 | #endregion
26 |
27 | using TableDependency.SqlClient.Base.Exceptions;
28 |
29 | namespace TableDependency.SqlClient.Exceptions
30 | {
31 | public class ServiceBrokerNotEnabledException : TableDependencyException
32 | {
33 | protected internal ServiceBrokerNotEnabledException()
34 | : base("Service broker not enable. Please activete it using 'ALTER DATABASE MyDatabase SET ENABLE_BROKER' command.")
35 | { }
36 | }
37 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient/Exceptions/SqlServerVersionNotSupportedException.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // TableDependency, SqlTableDependency
3 | // Copyright (c) 2015-2020 Christian Del Bianco. All rights reserved.
4 | //
5 | // Permission is hereby granted, free of charge, to any person
6 | // obtaining a copy of this software and associated documentation
7 | // files (the "Software"), to deal in the Software without
8 | // restriction, including without limitation the rights to use,
9 | // copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | // copies of the Software, and to permit persons to whom the
11 | // Software is furnished to do so, subject to the following
12 | // conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be
15 | // included in all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | // OTHER DEALINGS IN THE SOFTWARE.
25 | #endregion
26 |
27 | using TableDependency.SqlClient.Base.Exceptions;
28 | using TableDependency.SqlClient.Enumerations;
29 |
30 | namespace TableDependency.SqlClient.Exceptions
31 | {
32 | public class SqlServerVersionNotSupportedException : TableDependencyException
33 | {
34 | protected internal SqlServerVersionNotSupportedException()
35 | : base("SQL Server version not supported from SqlTableDependency.")
36 | {
37 | }
38 |
39 | protected internal SqlServerVersionNotSupportedException(SqlServerVersion sqlVersion)
40 | : base($"SQL Server {sqlVersion.GetHashCode()} is not supported from SqlTableDependency.")
41 | {
42 | }
43 | }
44 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient/Exceptions/UserWithMissingPermissionException.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // TableDependency, SqlTableDependency
3 | // Copyright (c) 2015-2020 Christian Del Bianco. All rights reserved.
4 | //
5 | // Permission is hereby granted, free of charge, to any person
6 | // obtaining a copy of this software and associated documentation
7 | // files (the "Software"), to deal in the Software without
8 | // restriction, including without limitation the rights to use,
9 | // copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | // copies of the Software, and to permit persons to whom the
11 | // Software is furnished to do so, subject to the following
12 | // conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be
15 | // included in all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | // OTHER DEALINGS IN THE SOFTWARE.
25 | #endregion
26 |
27 | using TableDependency.SqlClient.Base.Exceptions;
28 |
29 | namespace TableDependency.SqlClient.Exceptions
30 | {
31 | public class UserWithMissingPermissionException : TableDependencyException
32 | {
33 | protected internal UserWithMissingPermissionException(string missingPermission)
34 | : base($"User with no '{missingPermission.ToUpper()}' permission.")
35 | { }
36 | }
37 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient/Exceptions/UserWithNoPermissionException.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // TableDependency, SqlTableDependency
3 | // Copyright (c) 2015-2020 Christian Del Bianco. All rights reserved.
4 | //
5 | // Permission is hereby granted, free of charge, to any person
6 | // obtaining a copy of this software and associated documentation
7 | // files (the "Software"), to deal in the Software without
8 | // restriction, including without limitation the rights to use,
9 | // copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | // copies of the Software, and to permit persons to whom the
11 | // Software is furnished to do so, subject to the following
12 | // conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be
15 | // included in all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | // OTHER DEALINGS IN THE SOFTWARE.
25 | #endregion
26 |
27 | using TableDependency.SqlClient.Base.Exceptions;
28 |
29 | namespace TableDependency.SqlClient.Exceptions
30 | {
31 | public class UserWithNoPermissionException : TableDependencyException
32 | {
33 | protected internal UserWithNoPermissionException()
34 | : base("User without permissions.")
35 | { }
36 | }
37 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient/Extensions/SqlDataReaderExtension.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // TableDependency, SqlTableDependency
3 | // Copyright (c) 2015-2020 Christian Del Bianco. All rights reserved.
4 | //
5 | // Permission is hereby granted, free of charge, to any person
6 | // obtaining a copy of this software and associated documentation
7 | // files (the "Software"), to deal in the Software without
8 | // restriction, including without limitation the rights to use,
9 | // copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | // copies of the Software, and to permit persons to whom the
11 | // Software is furnished to do so, subject to the following
12 | // conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be
15 | // included in all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | // OTHER DEALINGS IN THE SOFTWARE.
25 | #endregion
26 |
27 | using System.Data.SqlClient;
28 |
29 | namespace TableDependency.SqlClient.Extensions
30 | {
31 | public static class SqlDataReaderExtension
32 | {
33 | public static string GetSafeString(this SqlDataReader reader, int columnIndex)
34 | {
35 | if (reader.IsDBNull(columnIndex)) return null;
36 | var characterMaximumLength = reader.GetValue(columnIndex);
37 | return characterMaximumLength?.ToString();
38 | }
39 | }
40 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient/Extensions/StringExtension.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // TableDependency, SqlTableDependency
3 | // Copyright (c) 2015-2020 Christian Del Bianco. All rights reserved.
4 | //
5 | // Permission is hereby granted, free of charge, to any person
6 | // obtaining a copy of this software and associated documentation
7 | // files (the "Software"), to deal in the Software without
8 | // restriction, including without limitation the rights to use,
9 | // copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | // copies of the Software, and to permit persons to whom the
11 | // Software is furnished to do so, subject to the following
12 | // conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be
15 | // included in all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | // OTHER DEALINGS IN THE SOFTWARE.
25 | #endregion
26 |
27 | using System;
28 |
29 | namespace TableDependency.SqlClient.Extensions
30 | {
31 | public static class StringExtension
32 | {
33 | public static string ConvertNumericType(this string type)
34 | {
35 | return string.Equals(type.ToLowerInvariant(), "numeric", StringComparison.OrdinalIgnoreCase) ? "decimal" : type.ToLowerInvariant();
36 | }
37 |
38 | public static bool? ToBoolean(this string str)
39 | {
40 | var cleanValue = (str ?? string.Empty).Trim();
41 |
42 | if (string.Equals(cleanValue, "0", StringComparison.OrdinalIgnoreCase)) return false;
43 | if (string.Equals(cleanValue, "1", StringComparison.OrdinalIgnoreCase)) return true;
44 |
45 | return null;
46 | }
47 | }
48 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient/Extensions/TaskExtensions.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // TableDependency, SqlTableDependency
3 | // Copyright (c) 2015-2020 Christian Del Bianco. All rights reserved.
4 | //
5 | // Permission is hereby granted, free of charge, to any person
6 | // obtaining a copy of this software and associated documentation
7 | // files (the "Software"), to deal in the Software without
8 | // restriction, including without limitation the rights to use,
9 | // copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | // copies of the Software, and to permit persons to whom the
11 | // Software is furnished to do so, subject to the following
12 | // conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be
15 | // included in all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | // OTHER DEALINGS IN THE SOFTWARE.
25 | #endregion
26 |
27 | using System;
28 | using System.Threading;
29 | using System.Threading.Tasks;
30 |
31 | namespace TableDependency.SqlClient.Extensions
32 | {
33 | public static class TaskExtensions
34 | {
35 | public static async Task WithCancellation(this Task task, CancellationToken cancellationToken)
36 | {
37 | var tcs = new TaskCompletionSource();
38 | using (cancellationToken.Register(s => ((TaskCompletionSource)s).TrySetResult(true), tcs))
39 | {
40 | if (task != await Task.WhenAny(task, tcs.Task))
41 | {
42 | throw new OperationCanceledException(cancellationToken);
43 | }
44 | }
45 |
46 | return task.Result;
47 | }
48 | }
49 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient/Messages/SqlMessageTypes.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // TableDependency, SqlTableDependency
3 | // Copyright (c) 2015-2020 Christian Del Bianco. All rights reserved.
4 | //
5 | // Permission is hereby granted, free of charge, to any person
6 | // obtaining a copy of this software and associated documentation
7 | // files (the "Software"), to deal in the Software without
8 | // restriction, including without limitation the rights to use,
9 | // copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | // copies of the Software, and to permit persons to whom the
11 | // Software is furnished to do so, subject to the following
12 | // conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be
15 | // included in all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | // OTHER DEALINGS IN THE SOFTWARE.
25 | #endregion
26 |
27 | namespace TableDependency.SqlClient.Messages
28 | {
29 | public static class SqlMessageTypes
30 | {
31 | ///
32 | /// System message type for event notification messages.
33 | ///
34 | public const string EventNotificationType = "http://schemas.microsoft.com/SQL/Notifications/EventNotification";
35 |
36 | ///
37 | /// System message type for query notification messages.
38 | ///
39 | public const string QueryNotificationType = "http://schemas.microsoft.com/SQL/Notifications/QueryNotification";
40 |
41 | ///
42 | /// System message type for message indicating failed remote service binding.
43 | ///
44 | public const string FailedRemoteServiceBindingType = "http://schemas.microsoft.com/SQL/ServiceBroker/BrokerConfigurationNotice/FailedRemoteServiceBinding";
45 |
46 | ///
47 | /// System message type for message indicating failed route.
48 | ///
49 | public const string FailedRouteType = "http://schemas.microsoft.com/SQL/ServiceBroker/BrokerConfigurationNotice/FailedRoute";
50 |
51 | ///
52 | /// System message type for message indicating missing remote service binding.
53 | ///
54 | public const string MissingRemoteServiceBindingType = "http://schemas.microsoft.com/SQL/ServiceBroker/BrokerConfigurationNotice/MissingRemoteServiceBinding";
55 |
56 | ///
57 | /// System message type for message indicating missing route.
58 | ///
59 | public const string MissingRouteType = "http://schemas.microsoft.com/SQL/ServiceBroker/BrokerConfigurationNotice/MissingRoute";
60 |
61 | ///
62 | /// System message type for dialog timer messages.
63 | ///
64 | public const string DialogTimerType = "http://schemas.microsoft.com/SQL/ServiceBroker/DialogTimer";
65 |
66 | ///
67 | /// System message type for message indicating end of dialog.
68 | ///
69 | public const string EndDialogType = "http://schemas.microsoft.com/SQL/ServiceBroker/EndDialog";
70 |
71 | ///
72 | /// System message type for error messages.
73 | ///
74 | public const string ErrorType = "http://schemas.microsoft.com/SQL/ServiceBroker/Error";
75 |
76 | ///
77 | /// System message type for diagnostic description messages.
78 | ///
79 | public const string DescriptionType = "http://schemas.microsoft.com/SQL/ServiceBroker/ServiceDiagnostic/Description";
80 |
81 | ///
82 | /// System message type for diagnostic query messages.
83 | ///
84 | public const string QueryType = "http://schemas.microsoft.com/SQL/ServiceBroker/ServiceDiagnostic/Query";
85 |
86 | ///
87 | /// System message type for diagnostic status messages.
88 | ///
89 | public const string StatusType = "http://schemas.microsoft.com/SQL/ServiceBroker/ServiceDiagnostic/Status";
90 |
91 | ///
92 | /// System message type for echo service messages.
93 | ///
94 | public const string EchoType = "http://schemas.microsoft.com/SQL/ServiceBroker/ServiceEcho/Echo";
95 | }
96 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient/TableDependency.SqlClient.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | true
5 | true
6 | 8.5.8
7 | net451;netstandard2.0;netcoreapp2.0
8 | Christian Del Bianco © 2015-2020
9 | https://github.com/christiandelbianco/monitor-table-change-with-sqltabledependency/blob/master/LICENSE
10 | SqlTableDependency is a high-level implementation to access table record change notifications from SQL Server. This class allows you to detect changes on a database table. Every change will send a notification messages contains values for the updated, inserted or deleted record, avoid you to execute a further select to update your application data. If you want to use record change notifications without paying attention to the underlying Service Broker infrastructure, the SqlTableDependency class is your choice. The SqlTableDependency class represents a notification dependency between an application and a SQL Server Table. When you use SqlTableDependency to get notifications, this componenet provides the low-level implementation creating the Queue and Service Broker. In this way SqlTableDependency class provides access to notifications without knowing anything about the underlying Service Broker infrastructure. Once a record change happens, SqlTableDependency's event subscribers are notified.
11 | https://github.com/christiandelbianco/monitor-table-change-with-sqltabledependency/wiki/Release-Notes
12 | SqlTableDependency
13 | Christian Del Bianco
14 | Christian Del Bianco
15 | TableDependency.SqlClient
16 | https://github.com/christiandelbianco/monitor-table-change-with-sqltabledependency
17 | http://sqltabledependency.somee.com/rsz_notify.png
18 | https://github.com/christiandelbianco/monitor-table-change-with-sqltabledependency
19 | GitHub
20 | SQL Server dependency notifications record table change
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/TableDependency.SqlClient/Utilities/PrivilegesTable.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // TableDependency, SqlTableDependency
3 | // Copyright (c) 2015-2020 Christian Del Bianco. All rights reserved.
4 | //
5 | // Permission is hereby granted, free of charge, to any person
6 | // obtaining a copy of this software and associated documentation
7 | // files (the "Software"), to deal in the Software without
8 | // restriction, including without limitation the rights to use,
9 | // copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | // copies of the Software, and to permit persons to whom the
11 | // Software is furnished to do so, subject to the following
12 | // conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be
15 | // included in all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | // OTHER DEALINGS IN THE SOFTWARE.
25 | #endregion
26 |
27 | using System;
28 | using System.Collections.Generic;
29 |
30 | namespace TableDependency.SqlClient.Utilities
31 | {
32 | internal class PrivilegesTable
33 | {
34 | public List Rows { get; set; } = new List();
35 |
36 | public static PrivilegesTable FromEnumerable(IEnumerable> rows)
37 | {
38 | var privilegesTable = new PrivilegesTable();
39 | foreach (var row in rows) privilegesTable.Rows.Add(Privilege.FromDictionary(row));
40 | return privilegesTable;
41 | }
42 | }
43 |
44 | internal class Privilege
45 | {
46 | public string UserName { get; set; }
47 | public string UserType { get; set; }
48 | public string DatabaseUserName { get; set; }
49 | public string Role { get; set; }
50 | public string PermissionType { get; set; }
51 | public string PermissionState { get; set; }
52 | public string ObjectType { get; set; }
53 | public string ObjectName { get; set; }
54 | public string ColumnName { get; set; }
55 |
56 | public static Privilege FromDictionary(Dictionary columns)
57 | {
58 | var privilege = new Privilege();
59 |
60 | foreach (var column in columns)
61 | {
62 | foreach (var propertyInfo in privilege.GetType().GetProperties())
63 | {
64 | if (column.Key != propertyInfo.Name) continue;
65 |
66 | var theValue = column.Value == DBNull.Value ? null : column.Value;
67 | propertyInfo.SetValue(privilege, theValue);
68 | break;
69 | }
70 | }
71 |
72 | return privilege;
73 | }
74 | }
75 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient/Utilities/SerializeSqlDataReader.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // TableDependency, SqlTableDependency
3 | // Copyright (c) 2015-2020 Christian Del Bianco. All rights reserved.
4 | //
5 | // Permission is hereby granted, free of charge, to any person
6 | // obtaining a copy of this software and associated documentation
7 | // files (the "Software"), to deal in the Software without
8 | // restriction, including without limitation the rights to use,
9 | // copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | // copies of the Software, and to permit persons to whom the
11 | // Software is furnished to do so, subject to the following
12 | // conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be
15 | // included in all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | // OTHER DEALINGS IN THE SOFTWARE.
25 | #endregion
26 |
27 | using System.Collections.Generic;
28 | using System.Data;
29 | using System.Data.SqlClient;
30 | using System.Linq;
31 |
32 | namespace TableDependency.SqlClient.Utilities
33 | {
34 | internal class SerializeSqlDataReader
35 | {
36 | public static IEnumerable> Serialize(SqlDataReader reader)
37 | {
38 | var results = new List>();
39 | var cols = new List();
40 | for (var i = 0; i < reader.FieldCount; i++) cols.Add(reader.GetName(i));
41 |
42 | while (reader.Read()) results.Add(SerializeRow(cols, reader));
43 |
44 | return results;
45 | }
46 |
47 | private static Dictionary SerializeRow(IEnumerable cols, IDataRecord reader)
48 | {
49 | return cols.ToDictionary(col => col, col => reader[col]);
50 | }
51 | }
52 | }
--------------------------------------------------------------------------------
/TableDependency.SqlClient/Where/Helpers/ParameterHelper.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // TableDependency, SqlTableDependency, SqlTableDependencyFilter
3 | // Copyright (c) 2015-2020 Christian Del Bianco. All rights reserved.
4 | //
5 | // Permission is hereby granted, free of charge, to any person
6 | // obtaining a copy of this software and associated documentation
7 | // files (the "Software"), to deal in the Software without
8 | // restriction, including without limitation the rights to use,
9 | // copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | // copies of the Software, and to permit persons to whom the
11 | // Software is furnished to do so, subject to the following
12 | // conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be
15 | // included in all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | // OTHER DEALINGS IN THE SOFTWARE.
25 | #endregion
26 |
27 | namespace TableDependency.SqlClient.Where.Helpers
28 | {
29 | internal class ParameterHelper
30 | {
31 | private string _prepend;
32 | private string _append;
33 |
34 | internal string Prepend
35 | {
36 | get
37 | {
38 | var value = _prepend;
39 | _prepend = null;
40 | return value;
41 | }
42 |
43 | set => _prepend = value;
44 | }
45 |
46 | internal string Append
47 | {
48 | get
49 | {
50 | var value = _append;
51 | _append = null;
52 | return value;
53 | }
54 |
55 | set => _append = value;
56 | }
57 | }
58 | }
--------------------------------------------------------------------------------
/img/2018-04-20 at 10-40-04.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IsNemoEqualTrue/monitor-table-change-with-sqltabledependency/e2b18fa1a453e8ff6ee6d4da73c571883420b92b/img/2018-04-20 at 10-40-04.png
--------------------------------------------------------------------------------
/img/2018-04-20 at 11-51-49.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IsNemoEqualTrue/monitor-table-change-with-sqltabledependency/e2b18fa1a453e8ff6ee6d4da73c571883420b92b/img/2018-04-20 at 11-51-49.png
--------------------------------------------------------------------------------
/img/DbObjects-min.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IsNemoEqualTrue/monitor-table-change-with-sqltabledependency/e2b18fa1a453e8ff6ee6d4da73c571883420b92b/img/DbObjects-min.png
--------------------------------------------------------------------------------
/img/No.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IsNemoEqualTrue/monitor-table-change-with-sqltabledependency/e2b18fa1a453e8ff6ee6d4da73c571883420b92b/img/No.png
--------------------------------------------------------------------------------
/img/NoSmall.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IsNemoEqualTrue/monitor-table-change-with-sqltabledependency/e2b18fa1a453e8ff6ee6d4da73c571883420b92b/img/NoSmall.png
--------------------------------------------------------------------------------
/img/NuGetPackageFilter.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IsNemoEqualTrue/monitor-table-change-with-sqltabledependency/e2b18fa1a453e8ff6ee6d4da73c571883420b92b/img/NuGetPackageFilter.png
--------------------------------------------------------------------------------
/img/NuGetSqlTableDependency.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IsNemoEqualTrue/monitor-table-change-with-sqltabledependency/e2b18fa1a453e8ff6ee6d4da73c571883420b92b/img/NuGetSqlTableDependency.png
--------------------------------------------------------------------------------
/img/Ok.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IsNemoEqualTrue/monitor-table-change-with-sqltabledependency/e2b18fa1a453e8ff6ee6d4da73c571883420b92b/img/Ok.png
--------------------------------------------------------------------------------
/img/Receive_notifications_from_Sql_Server_database.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IsNemoEqualTrue/monitor-table-change-with-sqltabledependency/e2b18fa1a453e8ff6ee6d4da73c571883420b92b/img/Receive_notifications_from_Sql_Server_database.gif
--------------------------------------------------------------------------------
/img/Workflow-min.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IsNemoEqualTrue/monitor-table-change-with-sqltabledependency/e2b18fa1a453e8ff6ee6d4da73c571883420b92b/img/Workflow-min.png
--------------------------------------------------------------------------------
/img/YesSmall.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IsNemoEqualTrue/monitor-table-change-with-sqltabledependency/e2b18fa1a453e8ff6ee6d4da73c571883420b92b/img/YesSmall.png
--------------------------------------------------------------------------------
/img/icons-01.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
25 |
--------------------------------------------------------------------------------
/img/if_exclamation-red_46014.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IsNemoEqualTrue/monitor-table-change-with-sqltabledependency/e2b18fa1a453e8ff6ee6d4da73c571883420b92b/img/if_exclamation-red_46014.png
--------------------------------------------------------------------------------
/img/rsz_notify.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IsNemoEqualTrue/monitor-table-change-with-sqltabledependency/e2b18fa1a453e8ff6ee6d4da73c571883420b92b/img/rsz_notify.png
--------------------------------------------------------------------------------
/img/rsz_table.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IsNemoEqualTrue/monitor-table-change-with-sqltabledependency/e2b18fa1a453e8ff6ee6d4da73c571883420b92b/img/rsz_table.jpg
--------------------------------------------------------------------------------
/img/rsz_table.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IsNemoEqualTrue/monitor-table-change-with-sqltabledependency/e2b18fa1a453e8ff6ee6d4da73c571883420b92b/img/rsz_table.png
--------------------------------------------------------------------------------