├── .gitattributes
├── .gitignore
├── LICENSE
├── README.md
├── SqlVirtualEntityDataProvider.sln
└── SqlVirtualEntityDataProvider
├── App_Packages
└── MarkMpn.Sql4Cds.Engine
│ ├── AttributeMetadataCache.cs
│ ├── DisconnectedException.cs
│ ├── FetchXml.cs
│ ├── FetchXml2Sql.cs
│ ├── IAttributeMetadataCache.cs
│ └── ScriptDom.cs
├── BaseExecutionContext.cs
├── EnvironmentSpecificExtensions.cs
├── Mappers
└── GenericMapper.cs
├── MikeFactorial.Xrm.Plugins.DataProviders.Key.snk
├── PluginBase.cs
├── PluginExecutionContext.cs
├── Properties
└── AssemblyInfo.cs
├── Solutions
├── PreviousVersions
│ ├── VirtualEntityProvidersSamplebyMike_1_0_0_3.zip
│ ├── VirtualEntityProvidersSamplebyMike_1_0_0_3_managed.zip
│ ├── VirtualEntityProvidersbyMike_1_0_0_3.zip
│ └── VirtualEntityProvidersbyMike_1_0_0_3_managed.zip
├── VirtualEntityProvidersSamplebyMike_1_0_0_4.zip
├── VirtualEntityProvidersSamplebyMike_1_0_0_4_managed.zip
├── VirtualEntityProvidersbyMike_1_0_0_4.zip
└── VirtualEntityProvidersbyMike_1_0_0_4_managed.zip
├── SqlVirtualEntityDataProvider.cs
├── SqlVirtualEntityDataProvider.csproj
└── packages.config
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.rsuser
8 | *.suo
9 | *.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Build results
17 | [Dd]ebug/
18 | [Dd]ebugPublic/
19 | [Rr]elease/
20 | [Rr]eleases/
21 | x64/
22 | x86/
23 | [Aa][Rr][Mm]/
24 | [Aa][Rr][Mm]64/
25 | bld/
26 | [Bb]in/
27 | [Oo]bj/
28 | [Ll]og/
29 |
30 | # Visual Studio 2015/2017 cache/options directory
31 | .vs/
32 | # Uncomment if you have tasks that create the project's static files in wwwroot
33 | #wwwroot/
34 |
35 | # Visual Studio 2017 auto generated files
36 | Generated\ Files/
37 |
38 | # MSTest test Results
39 | [Tt]est[Rr]esult*/
40 | [Bb]uild[Ll]og.*
41 |
42 | # NUNIT
43 | *.VisualState.xml
44 | TestResult.xml
45 |
46 | # Build Results of an ATL Project
47 | [Dd]ebugPS/
48 | [Rr]eleasePS/
49 | dlldata.c
50 |
51 | # Benchmark Results
52 | BenchmarkDotNet.Artifacts/
53 |
54 | # .NET Core
55 | project.lock.json
56 | project.fragment.lock.json
57 | artifacts/
58 |
59 | # StyleCop
60 | StyleCopReport.xml
61 |
62 | # Files built by Visual Studio
63 | *_i.c
64 | *_p.c
65 | *_h.h
66 | *.ilk
67 | *.meta
68 | *.obj
69 | *.iobj
70 | *.pch
71 | *.pdb
72 | *.ipdb
73 | *.pgc
74 | *.pgd
75 | *.rsp
76 | *.sbr
77 | *.tlb
78 | *.tli
79 | *.tlh
80 | *.tmp
81 | *.tmp_proj
82 | *_wpftmp.csproj
83 | *.log
84 | *.vspscc
85 | *.vssscc
86 | .builds
87 | *.pidb
88 | *.svclog
89 | *.scc
90 |
91 | # Chutzpah Test files
92 | _Chutzpah*
93 |
94 | # Visual C++ cache files
95 | ipch/
96 | *.aps
97 | *.ncb
98 | *.opendb
99 | *.opensdf
100 | *.sdf
101 | *.cachefile
102 | *.VC.db
103 | *.VC.VC.opendb
104 |
105 | # Visual Studio profiler
106 | *.psess
107 | *.vsp
108 | *.vspx
109 | *.sap
110 |
111 | # Visual Studio Trace Files
112 | *.e2e
113 |
114 | # TFS 2012 Local Workspace
115 | $tf/
116 |
117 | # Guidance Automation Toolkit
118 | *.gpState
119 |
120 | # ReSharper is a .NET coding add-in
121 | _ReSharper*/
122 | *.[Rr]e[Ss]harper
123 | *.DotSettings.user
124 |
125 | # JustCode is a .NET coding add-in
126 | .JustCode
127 |
128 | # TeamCity is a build add-in
129 | _TeamCity*
130 |
131 | # DotCover is a Code Coverage Tool
132 | *.dotCover
133 |
134 | # AxoCover is a Code Coverage Tool
135 | .axoCover/*
136 | !.axoCover/settings.json
137 |
138 | # Visual Studio code coverage results
139 | *.coverage
140 | *.coveragexml
141 |
142 | # NCrunch
143 | _NCrunch_*
144 | .*crunch*.local.xml
145 | nCrunchTemp_*
146 |
147 | # MightyMoose
148 | *.mm.*
149 | AutoTest.Net/
150 |
151 | # Web workbench (sass)
152 | .sass-cache/
153 |
154 | # Installshield output folder
155 | [Ee]xpress/
156 |
157 | # DocProject is a documentation generator add-in
158 | DocProject/buildhelp/
159 | DocProject/Help/*.HxT
160 | DocProject/Help/*.HxC
161 | DocProject/Help/*.hhc
162 | DocProject/Help/*.hhk
163 | DocProject/Help/*.hhp
164 | DocProject/Help/Html2
165 | DocProject/Help/html
166 |
167 | # Click-Once directory
168 | publish/
169 |
170 | # Publish Web Output
171 | *.[Pp]ublish.xml
172 | *.azurePubxml
173 | # Note: Comment the next line if you want to checkin your web deploy settings,
174 | # but database connection strings (with potential passwords) will be unencrypted
175 | *.pubxml
176 | *.publishproj
177 |
178 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
179 | # checkin your Azure Web App publish settings, but sensitive information contained
180 | # in these scripts will be unencrypted
181 | PublishScripts/
182 |
183 | # NuGet Packages
184 | *.nupkg
185 | # The packages folder can be ignored because of Package Restore
186 | **/[Pp]ackages/*
187 | # except build/, which is used as an MSBuild target.
188 | !**/[Pp]ackages/build/
189 | # Uncomment if necessary however generally it will be regenerated when needed
190 | #!**/[Pp]ackages/repositories.config
191 | # NuGet v3's project.json files produces more ignorable files
192 | *.nuget.props
193 | *.nuget.targets
194 |
195 | # Microsoft Azure Build Output
196 | csx/
197 | *.build.csdef
198 |
199 | # Microsoft Azure Emulator
200 | ecf/
201 | rcf/
202 |
203 | # Windows Store app package directories and files
204 | AppPackages/
205 | BundleArtifacts/
206 | Package.StoreAssociation.xml
207 | _pkginfo.txt
208 | *.appx
209 |
210 | # Visual Studio cache files
211 | # files ending in .cache can be ignored
212 | *.[Cc]ache
213 | # but keep track of directories ending in .cache
214 | !?*.[Cc]ache/
215 |
216 | # Others
217 | ClientBin/
218 | ~$*
219 | *~
220 | *.dbmdl
221 | *.dbproj.schemaview
222 | *.jfm
223 | *.pfx
224 | *.publishsettings
225 | orleans.codegen.cs
226 |
227 | # Including strong name files can present a security risk
228 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
229 | #*.snk
230 |
231 | # Since there are multiple workflows, uncomment next line to ignore bower_components
232 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
233 | #bower_components/
234 |
235 | # RIA/Silverlight projects
236 | Generated_Code/
237 |
238 | # Backup & report files from converting an old project file
239 | # to a newer Visual Studio version. Backup files are not needed,
240 | # because we have git ;-)
241 | _UpgradeReport_Files/
242 | Backup*/
243 | UpgradeLog*.XML
244 | UpgradeLog*.htm
245 | ServiceFabricBackup/
246 | *.rptproj.bak
247 |
248 | # SQL Server files
249 | *.mdf
250 | *.ldf
251 | *.ndf
252 |
253 | # Business Intelligence projects
254 | *.rdl.data
255 | *.bim.layout
256 | *.bim_*.settings
257 | *.rptproj.rsuser
258 | *- Backup*.rdl
259 |
260 | # Microsoft Fakes
261 | FakesAssemblies/
262 |
263 | # GhostDoc plugin setting file
264 | *.GhostDoc.xml
265 |
266 | # Node.js Tools for Visual Studio
267 | .ntvs_analysis.dat
268 | node_modules/
269 |
270 | # Visual Studio 6 build log
271 | *.plg
272 |
273 | # Visual Studio 6 workspace options file
274 | *.opt
275 |
276 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
277 | *.vbw
278 |
279 | # Visual Studio LightSwitch build output
280 | **/*.HTMLClient/GeneratedArtifacts
281 | **/*.DesktopClient/GeneratedArtifacts
282 | **/*.DesktopClient/ModelManifest.xml
283 | **/*.Server/GeneratedArtifacts
284 | **/*.Server/ModelManifest.xml
285 | _Pvt_Extensions
286 |
287 | # Paket dependency manager
288 | .paket/paket.exe
289 | paket-files/
290 |
291 | # FAKE - F# Make
292 | .fake/
293 |
294 | # JetBrains Rider
295 | .idea/
296 | *.sln.iml
297 |
298 | # CodeRush personal settings
299 | .cr/personal
300 |
301 | # Python Tools for Visual Studio (PTVS)
302 | __pycache__/
303 | *.pyc
304 |
305 | # Cake - Uncomment if you are using it
306 | # tools/**
307 | # !tools/packages.config
308 |
309 | # Tabs Studio
310 | *.tss
311 |
312 | # Telerik's JustMock configuration file
313 | *.jmconfig
314 |
315 | # BizTalk build output
316 | *.btp.cs
317 | *.btm.cs
318 | *.odx.cs
319 | *.xsd.cs
320 |
321 | # OpenCover UI analysis results
322 | OpenCover/
323 |
324 | # Azure Stream Analytics local run output
325 | ASALocalRun/
326 |
327 | # MSBuild Binary and Structured Log
328 | *.binlog
329 |
330 | # NVidia Nsight GPU debugger configuration file
331 | *.nvuser
332 |
333 | # MFractors (Xamarin productivity tool) working folder
334 | .mfractor/
335 |
336 | # Local History for Visual Studio
337 | .localhistory/
338 |
339 | # BeatPulse healthcheck temp database
340 | healthchecksdb
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Michael Ochs
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, sublicense, 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 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # SqlVirtualEntityDataProvider
2 | A Virtual Entity Data Provider using a direct SQL Connection to Azure SQL / SQL On-Prem. With contributions from Mark Carrington and Jonas Rapp . Relies on Sql4CDS from Mark Carrington.
3 |
4 | The project includes a managed / unmanaged solution that you can import and configure for a quick start to creating SQL based Virtual Entities as well as the source code to customize to your specific requirements.
5 |
6 |
7 | Features:
8 |
9 | Display SQL Tables as Virtual Entities using only a connection string to your SQL instance
10 | Automatically convert FetchXml queries to SQL via Sql4Cds.
11 | Automatically convert integer key values to guids without the need for a guid column in the Azure SQL table
12 | Display Virtual Entities as lookups on OOB or custom entities or other virtual entities.
13 |
14 | You can get started using the Sample App using the instructions below. More to follow with respect to configuring the Provider for personal / corporate use outside of the provided sample App.
15 |
16 |
Required: A Dynamics 365 or Power Apps Subscription Required: An Azure Subscription with Rights to Create Resources Optional: SQL Server Management Studio (to test your connection)
17 |
18 |
19 |
20 | Setting Up Your Sample SQL Azure Instance
21 |
22 |
23 |
24 | Configure a new Azure SQL Server and Database
25 |
26 |
27 |
28 | Navigate to portal.azure.com and signin Click Create a Resource + Databases Click SQL Database or Managed Instance Select your Subcription and Resource Group Select Create New if you don't already have a SQL Server InstanceEnter Server Name Enter Server Admin Login Enter and Confirm the Password for your Admin Account Select Okay Now Click on NetworkingSet Connectivity Method to Public Endpoint Select Add Current Client IP Address and Allow Azure Services to Access this server Click Additional SettingsNext to Use existing data select Sample Select the remaining defaults to create your Azure SQL Server and Database Once the server and database are provisioned go to the resource and select Connection Strings from Menu Copy the ADO.NET Connection String to use in the next step
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 | Installing and Configuring the Solution
37 |
38 |
39 |
40 | Download either the Unmanaged or Managed (recommended) SQL Virtual Entity Sample Solution . (NOTE: I plan to grow this over time and add more features, but it's a good starting point and I welcome feedback and contributions. A big thanks to @rappen for allowing me to use some of his code to translate FetchXML to SQL that he has included as open source in FetchXML Builder with some slight modifications.)NOTE: There are 4 solutions available both the managed / unmanaged solution for the Sample App, which contains the preconfigured entities for the sample SQL database and the Provider only App that contains only the provider so you can roll your own Virtual Entities. Import the solution by going to make.powerapps.com and logging into your tenant. Select the environment you want to import the solution into. Go to Solutions and select Import and select the solution you downloaded.After the Solution has been imported you should see a new Model Driven App under Apps called "Azure SQL Product Catalog Sample" NOTE: This app is based on the sample data that is installed with the Azure SQL database when you choose to install sample data. In the next article I'll walk through how I created this app so you can create your own using the same Data Provider.
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 | The final step to configuring the app to display Products and Product Categories from Azure SQL is to configure the Provider using your specific SQL Connection String.Open the Azure SQL Product Catalog Sample App (NOTE: You'll see an error when you launch the app because you haven't configured the connection)
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 | Open Advanced FindSearch for 'SQL Providers' Open the record that is returned and paste the SQL Connection String from Azure SQL and Save the Record IMPORTANT: You will need to replace the {your_password} in the connection string with your password.
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 | Click on Products or Product Categories from the Left Menu to see the Products and Categories stored in Azure SQL.NOTE: If you get an error at this point it could be related to your Azure SQL Firewall and as such you may need to allow specific IPs through.
65 |
66 |
--------------------------------------------------------------------------------
/SqlVirtualEntityDataProvider.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.29519.87
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SqlVirtualEntityDataProvider", "SqlVirtualEntityDataProvider\SqlVirtualEntityDataProvider.csproj", "{62D2D0A0-395E-4970-824A-12001296CC43}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {62D2D0A0-395E-4970-824A-12001296CC43}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {62D2D0A0-395E-4970-824A-12001296CC43}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {62D2D0A0-395E-4970-824A-12001296CC43}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {62D2D0A0-395E-4970-824A-12001296CC43}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {251E7F6B-CE0B-4E20-AB50-96EE460E4B5B}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/SqlVirtualEntityDataProvider/App_Packages/MarkMpn.Sql4Cds.Engine/AttributeMetadataCache.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Xrm.Sdk;
2 | using Microsoft.Xrm.Sdk.Messages;
3 | using Microsoft.Xrm.Sdk.Metadata;
4 | using System;
5 | using System.Collections.Generic;
6 | using System.Threading.Tasks;
7 |
8 | namespace MarkMpn.Sql4Cds.Engine
9 | {
10 | ///
11 | /// A default implementation of
12 | ///
13 | public class AttributeMetadataCache : IAttributeMetadataCache
14 | {
15 | private readonly IOrganizationService _org;
16 | private readonly IDictionary _metadata;
17 | private readonly ISet _loading;
18 |
19 | ///
20 | /// Creates a new
21 | ///
22 | /// The to retrieve the metadata from
23 | public AttributeMetadataCache(IOrganizationService org)
24 | {
25 | _org = org;
26 | _metadata = new Dictionary();
27 | _loading = new HashSet();
28 | }
29 |
30 | ///
31 | public EntityMetadata this[string name]
32 | {
33 | get
34 | {
35 | if (_metadata.TryGetValue(name, out var value))
36 | return value;
37 |
38 | var metadata = (RetrieveEntityResponse)_org.Execute(new RetrieveEntityRequest
39 | {
40 | LogicalName = name,
41 | EntityFilters = EntityFilters.Attributes | EntityFilters.Relationships
42 | });
43 |
44 | _metadata[name] = metadata.EntityMetadata;
45 | return metadata.EntityMetadata;
46 | }
47 | }
48 |
49 | ///
50 | public bool TryGetValue(string logicalName, out EntityMetadata metadata)
51 | {
52 | if (_metadata.TryGetValue(logicalName, out metadata))
53 | return true;
54 |
55 | if (_loading.Add(logicalName))
56 | {
57 | var task = Task.Run(() => this[logicalName]);
58 | OnMetadataLoading(new MetadataLoadingEventArgs(logicalName, task));
59 | }
60 |
61 | return false;
62 | }
63 |
64 | ///
65 | /// Loads the metadata for all entities in the background.
66 | ///
67 | /// A task that indicates when all the metadata has been loaded
68 | public Task LoadAllAsync()
69 | {
70 | var task = Task.Run(() =>
71 | {
72 | var entities = ((RetrieveAllEntitiesResponse)_org.Execute(new RetrieveAllEntitiesRequest
73 | {
74 | EntityFilters = EntityFilters.Attributes | EntityFilters.Relationships
75 | })).EntityMetadata;
76 |
77 | foreach (var entity in entities)
78 | _metadata[entity.LogicalName] = entity;
79 | });
80 |
81 | OnMetadataLoading(new MetadataLoadingEventArgs(null, task));
82 |
83 | return task;
84 | }
85 |
86 | public event EventHandler MetadataLoading;
87 |
88 | protected void OnMetadataLoading(MetadataLoadingEventArgs args)
89 | {
90 | MetadataLoading?.Invoke(this, args);
91 | }
92 | }
93 |
94 | ///
95 | /// Holds the details of a metadata background loading event
96 | ///
97 | public class MetadataLoadingEventArgs : EventArgs
98 | {
99 | ///
100 | /// Creates a new
101 | ///
102 | /// The name of the entity the metadata is being loaded for
103 | /// A task that indicates when the metadata has been loaded
104 | public MetadataLoadingEventArgs(string logicalName, Task task)
105 | {
106 | LogicalName = logicalName;
107 | Task = task;
108 | }
109 |
110 | ///
111 | /// The name of the entity the metadata is being loaded for
112 | ///
113 | public string LogicalName { get; }
114 |
115 | ///
116 | /// A task that indicates when the metadata has been loaded
117 | ///
118 | public Task Task { get; }
119 | }
120 | }
121 |
--------------------------------------------------------------------------------
/SqlVirtualEntityDataProvider/App_Packages/MarkMpn.Sql4Cds.Engine/DisconnectedException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace MarkMpn.Sql4Cds.Engine
4 | {
5 | ///
6 | /// An exception that is thrown when the conversion process requires a connnection to the CDS instance but it is disconnected
7 | ///
8 | [Serializable]
9 | public class DisconnectedException : ApplicationException
10 | {
11 | ///
12 | /// Creates a new
13 | ///
14 | public DisconnectedException() : base("This conversion cannot be run while disconnected from the server")
15 | {
16 | }
17 |
18 | ///
19 | /// Creates a new
20 | ///
21 | ///
22 | public DisconnectedException(string message) : base(message)
23 | {
24 | }
25 |
26 | ///
27 | /// Creates a new
28 | ///
29 | ///
30 | ///
31 | public DisconnectedException(string message, Exception innerException) : base(message, innerException)
32 | {
33 | }
34 |
35 | protected DisconnectedException(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext)
36 | {
37 | throw new NotImplementedException();
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/SqlVirtualEntityDataProvider/App_Packages/MarkMpn.Sql4Cds.Engine/FetchXml.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | //
12 | // This source code was auto-generated by xsd, Version=4.6.1055.0.
13 | //
14 | namespace MarkMpn.Sql4Cds.Engine.FetchXml {
15 | using System.Xml.Serialization;
16 |
17 |
18 | ///
19 | [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.1055.0")]
20 | [System.SerializableAttribute()]
21 | [System.Diagnostics.DebuggerStepThroughAttribute()]
22 | [System.ComponentModel.DesignerCategoryAttribute("code")]
23 | [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
24 | [System.Xml.Serialization.XmlRootAttribute(Namespace="", IsNullable=false)]
25 | public partial class condition {
26 |
27 | private conditionValue[] itemsField;
28 |
29 | private string columnField;
30 |
31 | private string attributeField;
32 |
33 | private string entitynameField;
34 |
35 | private @operator operatorField;
36 |
37 | private string valueField;
38 |
39 | private AggregateType aggregateField;
40 |
41 | private bool aggregateFieldSpecified;
42 |
43 | private RowAggregateType rowaggregateField;
44 |
45 | private bool rowaggregateFieldSpecified;
46 |
47 | private string aliasField;
48 |
49 | private string uinameField;
50 |
51 | private string uitypeField;
52 |
53 | private TrueFalse01Type uihiddenField;
54 |
55 | private bool uihiddenFieldSpecified;
56 |
57 | ///
58 | [System.Xml.Serialization.XmlElementAttribute("value")]
59 | public conditionValue[] Items {
60 | get {
61 | return this.itemsField;
62 | }
63 | set {
64 | this.itemsField = value;
65 | }
66 | }
67 |
68 | ///
69 | [System.Xml.Serialization.XmlAttributeAttribute()]
70 | public string column {
71 | get {
72 | return this.columnField;
73 | }
74 | set {
75 | this.columnField = value;
76 | }
77 | }
78 |
79 | ///
80 | [System.Xml.Serialization.XmlAttributeAttribute()]
81 | public string attribute {
82 | get {
83 | return this.attributeField;
84 | }
85 | set {
86 | this.attributeField = value;
87 | }
88 | }
89 |
90 | ///
91 | [System.Xml.Serialization.XmlAttributeAttribute()]
92 | public string entityname {
93 | get {
94 | return this.entitynameField;
95 | }
96 | set {
97 | this.entitynameField = value;
98 | }
99 | }
100 |
101 | ///
102 | [System.Xml.Serialization.XmlAttributeAttribute()]
103 | public @operator @operator {
104 | get {
105 | return this.operatorField;
106 | }
107 | set {
108 | this.operatorField = value;
109 | }
110 | }
111 |
112 | ///
113 | [System.Xml.Serialization.XmlAttributeAttribute()]
114 | public string value {
115 | get {
116 | return this.valueField;
117 | }
118 | set {
119 | this.valueField = value;
120 | }
121 | }
122 |
123 | ///
124 | [System.Xml.Serialization.XmlAttributeAttribute()]
125 | public AggregateType aggregate {
126 | get {
127 | return this.aggregateField;
128 | }
129 | set {
130 | this.aggregateField = value;
131 | }
132 | }
133 |
134 | ///
135 | [System.Xml.Serialization.XmlIgnoreAttribute()]
136 | public bool aggregateSpecified {
137 | get {
138 | return this.aggregateFieldSpecified;
139 | }
140 | set {
141 | this.aggregateFieldSpecified = value;
142 | }
143 | }
144 |
145 | ///
146 | [System.Xml.Serialization.XmlAttributeAttribute()]
147 | public RowAggregateType rowaggregate {
148 | get {
149 | return this.rowaggregateField;
150 | }
151 | set {
152 | this.rowaggregateField = value;
153 | }
154 | }
155 |
156 | ///
157 | [System.Xml.Serialization.XmlIgnoreAttribute()]
158 | public bool rowaggregateSpecified {
159 | get {
160 | return this.rowaggregateFieldSpecified;
161 | }
162 | set {
163 | this.rowaggregateFieldSpecified = value;
164 | }
165 | }
166 |
167 | ///
168 | [System.Xml.Serialization.XmlAttributeAttribute()]
169 | public string alias {
170 | get {
171 | return this.aliasField;
172 | }
173 | set {
174 | this.aliasField = value;
175 | }
176 | }
177 |
178 | ///
179 | [System.Xml.Serialization.XmlAttributeAttribute()]
180 | public string uiname {
181 | get {
182 | return this.uinameField;
183 | }
184 | set {
185 | this.uinameField = value;
186 | }
187 | }
188 |
189 | ///
190 | [System.Xml.Serialization.XmlAttributeAttribute()]
191 | public string uitype {
192 | get {
193 | return this.uitypeField;
194 | }
195 | set {
196 | this.uitypeField = value;
197 | }
198 | }
199 |
200 | ///
201 | [System.Xml.Serialization.XmlAttributeAttribute()]
202 | public TrueFalse01Type uihidden {
203 | get {
204 | return this.uihiddenField;
205 | }
206 | set {
207 | this.uihiddenField = value;
208 | }
209 | }
210 |
211 | ///
212 | [System.Xml.Serialization.XmlIgnoreAttribute()]
213 | public bool uihiddenSpecified {
214 | get {
215 | return this.uihiddenFieldSpecified;
216 | }
217 | set {
218 | this.uihiddenFieldSpecified = value;
219 | }
220 | }
221 |
222 | [XmlAttribute]
223 | public string valueof { get; set; }
224 | }
225 |
226 | ///
227 | [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.1055.0")]
228 | [System.SerializableAttribute()]
229 | [System.Diagnostics.DebuggerStepThroughAttribute()]
230 | [System.ComponentModel.DesignerCategoryAttribute("code")]
231 | [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
232 | public partial class conditionValue {
233 |
234 | private string uinameField;
235 |
236 | private string uitypeField;
237 |
238 | private string valueField;
239 |
240 | ///
241 | [System.Xml.Serialization.XmlAttributeAttribute()]
242 | public string uiname {
243 | get {
244 | return this.uinameField;
245 | }
246 | set {
247 | this.uinameField = value;
248 | }
249 | }
250 |
251 | ///
252 | [System.Xml.Serialization.XmlAttributeAttribute()]
253 | public string uitype {
254 | get {
255 | return this.uitypeField;
256 | }
257 | set {
258 | this.uitypeField = value;
259 | }
260 | }
261 |
262 | ///
263 | [System.Xml.Serialization.XmlTextAttribute()]
264 | public string Value {
265 | get {
266 | return this.valueField;
267 | }
268 | set {
269 | this.valueField = value;
270 | }
271 | }
272 | }
273 |
274 | ///
275 | [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.1055.0")]
276 | [System.SerializableAttribute()]
277 | [System.Diagnostics.DebuggerStepThroughAttribute()]
278 | [System.ComponentModel.DesignerCategoryAttribute("code")]
279 | public partial class FieldXmlFieldUIType {
280 |
281 | private string idField;
282 |
283 | private string descriptionField;
284 |
285 | private string languagecodeField;
286 |
287 | ///
288 | [System.Xml.Serialization.XmlAttributeAttribute()]
289 | public string id {
290 | get {
291 | return this.idField;
292 | }
293 | set {
294 | this.idField = value;
295 | }
296 | }
297 |
298 | ///
299 | [System.Xml.Serialization.XmlAttributeAttribute()]
300 | public string description {
301 | get {
302 | return this.descriptionField;
303 | }
304 | set {
305 | this.descriptionField = value;
306 | }
307 | }
308 |
309 | ///
310 | [System.Xml.Serialization.XmlAttributeAttribute(DataType="positiveInteger")]
311 | public string languagecode {
312 | get {
313 | return this.languagecodeField;
314 | }
315 | set {
316 | this.languagecodeField = value;
317 | }
318 | }
319 | }
320 |
321 | ///
322 | [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.1055.0")]
323 | [System.SerializableAttribute()]
324 | [System.Diagnostics.DebuggerStepThroughAttribute()]
325 | [System.ComponentModel.DesignerCategoryAttribute("code")]
326 | public partial class SerializedTrueFalse01Type {
327 |
328 | private string nameField;
329 |
330 | private TrueFalse01Type valueField;
331 |
332 | ///
333 | [System.Xml.Serialization.XmlAttributeAttribute()]
334 | public string name {
335 | get {
336 | return this.nameField;
337 | }
338 | set {
339 | this.nameField = value;
340 | }
341 | }
342 |
343 | ///
344 | [System.Xml.Serialization.XmlTextAttribute()]
345 | public TrueFalse01Type Value {
346 | get {
347 | return this.valueField;
348 | }
349 | set {
350 | this.valueField = value;
351 | }
352 | }
353 | }
354 |
355 | ///
356 | [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.1055.0")]
357 | [System.SerializableAttribute()]
358 | public enum TrueFalse01Type {
359 |
360 | ///
361 | [System.Xml.Serialization.XmlEnumAttribute("0")]
362 | Item0,
363 |
364 | ///
365 | [System.Xml.Serialization.XmlEnumAttribute("1")]
366 | Item1,
367 | }
368 |
369 | ///
370 | [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.1055.0")]
371 | [System.SerializableAttribute()]
372 | [System.Diagnostics.DebuggerStepThroughAttribute()]
373 | [System.ComponentModel.DesignerCategoryAttribute("code")]
374 | public partial class SerializedInteger {
375 |
376 | private string formattedvalueField;
377 |
378 | private string valueField;
379 |
380 | ///
381 | [System.Xml.Serialization.XmlAttributeAttribute()]
382 | public string formattedvalue {
383 | get {
384 | return this.formattedvalueField;
385 | }
386 | set {
387 | this.formattedvalueField = value;
388 | }
389 | }
390 |
391 | ///
392 | [System.Xml.Serialization.XmlTextAttribute(DataType="nonNegativeInteger")]
393 | public string Value {
394 | get {
395 | return this.valueField;
396 | }
397 | set {
398 | this.valueField = value;
399 | }
400 | }
401 | }
402 |
403 | ///
404 | [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.1055.0")]
405 | [System.SerializableAttribute()]
406 | [System.Diagnostics.DebuggerStepThroughAttribute()]
407 | [System.ComponentModel.DesignerCategoryAttribute("code")]
408 | public partial class FetchLinkEntityType {
409 |
410 | private object[] itemsField;
411 |
412 | private string nameField;
413 |
414 | private string toField;
415 |
416 | private string fromField;
417 |
418 | private string aliasField;
419 |
420 | private string linktypeField;
421 |
422 | private bool visibleField;
423 |
424 | private bool visibleFieldSpecified;
425 |
426 | private bool intersectField;
427 |
428 | private bool intersectFieldSpecified;
429 |
430 | private bool enableprefilteringField;
431 |
432 | private bool enableprefilteringFieldSpecified;
433 |
434 | private string prefilterparameternameField;
435 |
436 | ///
437 | [System.Xml.Serialization.XmlElementAttribute("all-attributes", typeof(allattributes))]
438 | [System.Xml.Serialization.XmlElementAttribute("attribute", typeof(FetchAttributeType))]
439 | [System.Xml.Serialization.XmlElementAttribute("filter", typeof(filter))]
440 | [System.Xml.Serialization.XmlElementAttribute("link-entity", typeof(FetchLinkEntityType))]
441 | [System.Xml.Serialization.XmlElementAttribute("order", typeof(FetchOrderType))]
442 | public object[] Items {
443 | get {
444 | return this.itemsField;
445 | }
446 | set {
447 | this.itemsField = value;
448 | }
449 | }
450 |
451 | ///
452 | [System.Xml.Serialization.XmlAttributeAttribute()]
453 | public string name {
454 | get {
455 | return this.nameField;
456 | }
457 | set {
458 | this.nameField = value;
459 | }
460 | }
461 |
462 | ///
463 | [System.Xml.Serialization.XmlAttributeAttribute()]
464 | public string to {
465 | get {
466 | return this.toField;
467 | }
468 | set {
469 | this.toField = value;
470 | }
471 | }
472 |
473 | ///
474 | [System.Xml.Serialization.XmlAttributeAttribute()]
475 | public string from {
476 | get {
477 | return this.fromField;
478 | }
479 | set {
480 | this.fromField = value;
481 | }
482 | }
483 |
484 | ///
485 | [System.Xml.Serialization.XmlAttributeAttribute()]
486 | public string alias {
487 | get {
488 | return this.aliasField;
489 | }
490 | set {
491 | this.aliasField = value;
492 | }
493 | }
494 |
495 | ///
496 | [System.Xml.Serialization.XmlAttributeAttribute("link-type")]
497 | public string linktype {
498 | get {
499 | return this.linktypeField;
500 | }
501 | set {
502 | this.linktypeField = value;
503 | }
504 | }
505 |
506 | ///
507 | [System.Xml.Serialization.XmlAttributeAttribute()]
508 | public bool visible {
509 | get {
510 | return this.visibleField;
511 | }
512 | set {
513 | this.visibleField = value;
514 | }
515 | }
516 |
517 | ///
518 | [System.Xml.Serialization.XmlIgnoreAttribute()]
519 | public bool visibleSpecified {
520 | get {
521 | return this.visibleFieldSpecified;
522 | }
523 | set {
524 | this.visibleFieldSpecified = value;
525 | }
526 | }
527 |
528 | ///
529 | [System.Xml.Serialization.XmlAttributeAttribute()]
530 | public bool intersect {
531 | get {
532 | return this.intersectField;
533 | }
534 | set {
535 | this.intersectField = value;
536 | }
537 | }
538 |
539 | ///
540 | [System.Xml.Serialization.XmlIgnoreAttribute()]
541 | public bool intersectSpecified {
542 | get {
543 | return this.intersectFieldSpecified;
544 | }
545 | set {
546 | this.intersectFieldSpecified = value;
547 | }
548 | }
549 |
550 | ///
551 | [System.Xml.Serialization.XmlAttributeAttribute()]
552 | public bool enableprefiltering {
553 | get {
554 | return this.enableprefilteringField;
555 | }
556 | set {
557 | this.enableprefilteringField = value;
558 | }
559 | }
560 |
561 | ///
562 | [System.Xml.Serialization.XmlIgnoreAttribute()]
563 | public bool enableprefilteringSpecified {
564 | get {
565 | return this.enableprefilteringFieldSpecified;
566 | }
567 | set {
568 | this.enableprefilteringFieldSpecified = value;
569 | }
570 | }
571 |
572 | ///
573 | [System.Xml.Serialization.XmlAttributeAttribute()]
574 | public string prefilterparametername {
575 | get {
576 | return this.prefilterparameternameField;
577 | }
578 | set {
579 | this.prefilterparameternameField = value;
580 | }
581 | }
582 | }
583 |
584 | ///
585 | [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.1055.0")]
586 | [System.SerializableAttribute()]
587 | [System.Diagnostics.DebuggerStepThroughAttribute()]
588 | [System.ComponentModel.DesignerCategoryAttribute("code")]
589 | [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
590 | [System.Xml.Serialization.XmlRootAttribute("all-attributes", Namespace="", IsNullable=false)]
591 | public partial class allattributes {
592 | }
593 |
594 | ///
595 | [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.1055.0")]
596 | [System.SerializableAttribute()]
597 | [System.Diagnostics.DebuggerStepThroughAttribute()]
598 | [System.ComponentModel.DesignerCategoryAttribute("code")]
599 | public partial class FetchAttributeType {
600 |
601 | private string nameField;
602 |
603 | private build buildField;
604 |
605 | private bool buildFieldSpecified;
606 |
607 | private string addedbyField;
608 |
609 | private string aliasField;
610 |
611 | private AggregateType aggregateField;
612 |
613 | private bool aggregateFieldSpecified;
614 |
615 | private FetchBoolType groupbyField;
616 |
617 | private bool groupbyFieldSpecified;
618 |
619 | private DateGroupingType dategroupingField;
620 |
621 | private bool dategroupingFieldSpecified;
622 |
623 | private FetchBoolType usertimezoneField;
624 |
625 | private bool usertimezoneFieldSpecified;
626 |
627 | private FetchBoolType distinctField;
628 |
629 | private bool distinctFieldSpecified;
630 |
631 | ///
632 | [System.Xml.Serialization.XmlAttributeAttribute()]
633 | public string name {
634 | get {
635 | return this.nameField;
636 | }
637 | set {
638 | this.nameField = value;
639 | }
640 | }
641 |
642 | ///
643 | [System.Xml.Serialization.XmlAttributeAttribute()]
644 | public build build {
645 | get {
646 | return this.buildField;
647 | }
648 | set {
649 | this.buildField = value;
650 | }
651 | }
652 |
653 | ///
654 | [System.Xml.Serialization.XmlIgnoreAttribute()]
655 | public bool buildSpecified {
656 | get {
657 | return this.buildFieldSpecified;
658 | }
659 | set {
660 | this.buildFieldSpecified = value;
661 | }
662 | }
663 |
664 | ///
665 | [System.Xml.Serialization.XmlAttributeAttribute()]
666 | public string addedby {
667 | get {
668 | return this.addedbyField;
669 | }
670 | set {
671 | this.addedbyField = value;
672 | }
673 | }
674 |
675 | ///
676 | [System.Xml.Serialization.XmlAttributeAttribute()]
677 | public string alias {
678 | get {
679 | return this.aliasField;
680 | }
681 | set {
682 | this.aliasField = value;
683 | }
684 | }
685 |
686 | ///
687 | [System.Xml.Serialization.XmlAttributeAttribute()]
688 | public AggregateType aggregate {
689 | get {
690 | return this.aggregateField;
691 | }
692 | set {
693 | this.aggregateField = value;
694 | }
695 | }
696 |
697 | ///
698 | [System.Xml.Serialization.XmlIgnoreAttribute()]
699 | public bool aggregateSpecified {
700 | get {
701 | return this.aggregateFieldSpecified;
702 | }
703 | set {
704 | this.aggregateFieldSpecified = value;
705 | }
706 | }
707 |
708 | ///
709 | [System.Xml.Serialization.XmlAttributeAttribute()]
710 | public FetchBoolType groupby {
711 | get {
712 | return this.groupbyField;
713 | }
714 | set {
715 | this.groupbyField = value;
716 | }
717 | }
718 |
719 | ///
720 | [System.Xml.Serialization.XmlIgnoreAttribute()]
721 | public bool groupbySpecified {
722 | get {
723 | return this.groupbyFieldSpecified;
724 | }
725 | set {
726 | this.groupbyFieldSpecified = value;
727 | }
728 | }
729 |
730 | ///
731 | [System.Xml.Serialization.XmlAttributeAttribute()]
732 | public DateGroupingType dategrouping {
733 | get {
734 | return this.dategroupingField;
735 | }
736 | set {
737 | this.dategroupingField = value;
738 | }
739 | }
740 |
741 | ///
742 | [System.Xml.Serialization.XmlIgnoreAttribute()]
743 | public bool dategroupingSpecified {
744 | get {
745 | return this.dategroupingFieldSpecified;
746 | }
747 | set {
748 | this.dategroupingFieldSpecified = value;
749 | }
750 | }
751 |
752 | ///
753 | [System.Xml.Serialization.XmlAttributeAttribute()]
754 | public FetchBoolType usertimezone {
755 | get {
756 | return this.usertimezoneField;
757 | }
758 | set {
759 | this.usertimezoneField = value;
760 | }
761 | }
762 |
763 | ///
764 | [System.Xml.Serialization.XmlIgnoreAttribute()]
765 | public bool usertimezoneSpecified {
766 | get {
767 | return this.usertimezoneFieldSpecified;
768 | }
769 | set {
770 | this.usertimezoneFieldSpecified = value;
771 | }
772 | }
773 |
774 | ///
775 | [System.Xml.Serialization.XmlAttributeAttribute()]
776 | public FetchBoolType distinct {
777 | get {
778 | return this.distinctField;
779 | }
780 | set {
781 | this.distinctField = value;
782 | }
783 | }
784 |
785 | ///
786 | [System.Xml.Serialization.XmlIgnoreAttribute()]
787 | public bool distinctSpecified {
788 | get {
789 | return this.distinctFieldSpecified;
790 | }
791 | set {
792 | this.distinctFieldSpecified = value;
793 | }
794 | }
795 | }
796 |
797 | ///
798 | [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.1055.0")]
799 | [System.SerializableAttribute()]
800 | public enum build {
801 |
802 | ///
803 | [System.Xml.Serialization.XmlEnumAttribute("1.504021")]
804 | Item1504021,
805 |
806 | ///
807 | [System.Xml.Serialization.XmlEnumAttribute("1.003017")]
808 | Item1003017,
809 | }
810 |
811 | ///
812 | [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.1055.0")]
813 | [System.SerializableAttribute()]
814 | public enum AggregateType {
815 |
816 | ///
817 | count,
818 |
819 | ///
820 | countcolumn,
821 |
822 | ///
823 | sum,
824 |
825 | ///
826 | avg,
827 |
828 | ///
829 | min,
830 |
831 | ///
832 | max,
833 | }
834 |
835 | ///
836 | [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.1055.0")]
837 | [System.SerializableAttribute()]
838 | public enum FetchBoolType {
839 |
840 | ///
841 | @true,
842 |
843 | ///
844 | @false,
845 |
846 | ///
847 | [System.Xml.Serialization.XmlEnumAttribute("1")]
848 | Item1,
849 |
850 | ///
851 | [System.Xml.Serialization.XmlEnumAttribute("0")]
852 | Item0,
853 | }
854 |
855 | ///
856 | [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.1055.0")]
857 | [System.SerializableAttribute()]
858 | public enum DateGroupingType {
859 |
860 | ///
861 | day,
862 |
863 | ///
864 | week,
865 |
866 | ///
867 | month,
868 |
869 | ///
870 | quarter,
871 |
872 | ///
873 | year,
874 |
875 | ///
876 | [System.Xml.Serialization.XmlEnumAttribute("fiscal-period")]
877 | fiscalperiod,
878 |
879 | ///
880 | [System.Xml.Serialization.XmlEnumAttribute("fiscal-year")]
881 | fiscalyear,
882 | }
883 |
884 | ///
885 | [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.1055.0")]
886 | [System.SerializableAttribute()]
887 | [System.Diagnostics.DebuggerStepThroughAttribute()]
888 | [System.ComponentModel.DesignerCategoryAttribute("code")]
889 | [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
890 | [System.Xml.Serialization.XmlRootAttribute(Namespace="", IsNullable=false)]
891 | public partial class filter {
892 |
893 | private object[] itemsField;
894 |
895 | private filterType typeField;
896 |
897 | private bool isquickfindfieldsField;
898 |
899 | private bool isquickfindfieldsFieldSpecified;
900 |
901 | public filter() {
902 | this.typeField = filterType.and;
903 | }
904 |
905 | ///
906 | [System.Xml.Serialization.XmlElementAttribute("condition", typeof(condition))]
907 | [System.Xml.Serialization.XmlElementAttribute("filter", typeof(filter))]
908 | public object[] Items {
909 | get {
910 | return this.itemsField;
911 | }
912 | set {
913 | this.itemsField = value;
914 | }
915 | }
916 |
917 | ///
918 | [System.Xml.Serialization.XmlAttributeAttribute()]
919 | [System.ComponentModel.DefaultValueAttribute(filterType.and)]
920 | public filterType type {
921 | get {
922 | return this.typeField;
923 | }
924 | set {
925 | this.typeField = value;
926 | }
927 | }
928 |
929 | ///
930 | [System.Xml.Serialization.XmlAttributeAttribute()]
931 | public bool isquickfindfields {
932 | get {
933 | return this.isquickfindfieldsField;
934 | }
935 | set {
936 | this.isquickfindfieldsField = value;
937 | }
938 | }
939 |
940 | ///
941 | [System.Xml.Serialization.XmlIgnoreAttribute()]
942 | public bool isquickfindfieldsSpecified {
943 | get {
944 | return this.isquickfindfieldsFieldSpecified;
945 | }
946 | set {
947 | this.isquickfindfieldsFieldSpecified = value;
948 | }
949 | }
950 | }
951 |
952 | ///
953 | [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.1055.0")]
954 | [System.SerializableAttribute()]
955 | [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
956 | public enum filterType {
957 |
958 | ///
959 | and,
960 |
961 | ///
962 | or,
963 | }
964 |
965 | ///
966 | [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.1055.0")]
967 | [System.SerializableAttribute()]
968 | [System.Diagnostics.DebuggerStepThroughAttribute()]
969 | [System.ComponentModel.DesignerCategoryAttribute("code")]
970 | public partial class FetchOrderType {
971 |
972 | private object[] itemsField;
973 |
974 | private string attributeField;
975 |
976 | private string aliasField;
977 |
978 | private bool descendingField;
979 |
980 | public FetchOrderType() {
981 | this.descendingField = false;
982 | }
983 |
984 | ///
985 | public object[] Items {
986 | get {
987 | return this.itemsField;
988 | }
989 | set {
990 | this.itemsField = value;
991 | }
992 | }
993 |
994 | ///
995 | [System.Xml.Serialization.XmlAttributeAttribute()]
996 | public string attribute {
997 | get {
998 | return this.attributeField;
999 | }
1000 | set {
1001 | this.attributeField = value;
1002 | }
1003 | }
1004 |
1005 | ///
1006 | [System.Xml.Serialization.XmlAttributeAttribute()]
1007 | public string alias {
1008 | get {
1009 | return this.aliasField;
1010 | }
1011 | set {
1012 | this.aliasField = value;
1013 | }
1014 | }
1015 |
1016 | ///
1017 | [System.Xml.Serialization.XmlAttributeAttribute()]
1018 | [System.ComponentModel.DefaultValueAttribute(false)]
1019 | public bool descending {
1020 | get {
1021 | return this.descendingField;
1022 | }
1023 | set {
1024 | this.descendingField = value;
1025 | }
1026 | }
1027 | }
1028 |
1029 | ///
1030 | [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.1055.0")]
1031 | [System.SerializableAttribute()]
1032 | [System.Diagnostics.DebuggerStepThroughAttribute()]
1033 | [System.ComponentModel.DesignerCategoryAttribute("code")]
1034 | public partial class FetchEntityType {
1035 |
1036 | private object[] itemsField;
1037 |
1038 | private string nameField;
1039 |
1040 | private bool enableprefilteringField;
1041 |
1042 | private bool enableprefilteringFieldSpecified;
1043 |
1044 | private string prefilterparameternameField;
1045 |
1046 | ///
1047 | [System.Xml.Serialization.XmlElementAttribute("all-attributes", typeof(allattributes))]
1048 | [System.Xml.Serialization.XmlElementAttribute("attribute", typeof(FetchAttributeType))]
1049 | [System.Xml.Serialization.XmlElementAttribute("filter", typeof(filter))]
1050 | [System.Xml.Serialization.XmlElementAttribute("link-entity", typeof(FetchLinkEntityType))]
1051 | [System.Xml.Serialization.XmlElementAttribute("order", typeof(FetchOrderType))]
1052 | public object[] Items {
1053 | get {
1054 | return this.itemsField;
1055 | }
1056 | set {
1057 | this.itemsField = value;
1058 | }
1059 | }
1060 |
1061 | ///
1062 | [System.Xml.Serialization.XmlAttributeAttribute()]
1063 | public string name {
1064 | get {
1065 | return this.nameField;
1066 | }
1067 | set {
1068 | this.nameField = value;
1069 | }
1070 | }
1071 |
1072 | ///
1073 | [System.Xml.Serialization.XmlAttributeAttribute()]
1074 | public bool enableprefiltering {
1075 | get {
1076 | return this.enableprefilteringField;
1077 | }
1078 | set {
1079 | this.enableprefilteringField = value;
1080 | }
1081 | }
1082 |
1083 | ///
1084 | [System.Xml.Serialization.XmlIgnoreAttribute()]
1085 | public bool enableprefilteringSpecified {
1086 | get {
1087 | return this.enableprefilteringFieldSpecified;
1088 | }
1089 | set {
1090 | this.enableprefilteringFieldSpecified = value;
1091 | }
1092 | }
1093 |
1094 | ///
1095 | [System.Xml.Serialization.XmlAttributeAttribute()]
1096 | public string prefilterparametername {
1097 | get {
1098 | return this.prefilterparameternameField;
1099 | }
1100 | set {
1101 | this.prefilterparameternameField = value;
1102 | }
1103 | }
1104 | }
1105 |
1106 | ///
1107 | [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.1055.0")]
1108 | [System.SerializableAttribute()]
1109 | public enum @operator {
1110 |
1111 | ///
1112 | eq,
1113 |
1114 | ///
1115 | neq,
1116 |
1117 | ///
1118 | ne,
1119 |
1120 | ///
1121 | gt,
1122 |
1123 | ///
1124 | ge,
1125 |
1126 | ///
1127 | le,
1128 |
1129 | ///
1130 | lt,
1131 |
1132 | ///
1133 | like,
1134 |
1135 | ///
1136 | [System.Xml.Serialization.XmlEnumAttribute("not-like")]
1137 | notlike,
1138 |
1139 | ///
1140 | @in,
1141 |
1142 | ///
1143 | [System.Xml.Serialization.XmlEnumAttribute("not-in")]
1144 | notin,
1145 |
1146 | ///
1147 | between,
1148 |
1149 | ///
1150 | [System.Xml.Serialization.XmlEnumAttribute("not-between")]
1151 | notbetween,
1152 |
1153 | ///
1154 | @null,
1155 |
1156 | ///
1157 | [System.Xml.Serialization.XmlEnumAttribute("not-null")]
1158 | notnull,
1159 |
1160 | ///
1161 | yesterday,
1162 |
1163 | ///
1164 | today,
1165 |
1166 | ///
1167 | tomorrow,
1168 |
1169 | ///
1170 | [System.Xml.Serialization.XmlEnumAttribute("last-seven-days")]
1171 | lastsevendays,
1172 |
1173 | ///
1174 | [System.Xml.Serialization.XmlEnumAttribute("next-seven-days")]
1175 | nextsevendays,
1176 |
1177 | ///
1178 | [System.Xml.Serialization.XmlEnumAttribute("last-week")]
1179 | lastweek,
1180 |
1181 | ///
1182 | [System.Xml.Serialization.XmlEnumAttribute("this-week")]
1183 | thisweek,
1184 |
1185 | ///
1186 | [System.Xml.Serialization.XmlEnumAttribute("next-week")]
1187 | nextweek,
1188 |
1189 | ///
1190 | [System.Xml.Serialization.XmlEnumAttribute("last-month")]
1191 | lastmonth,
1192 |
1193 | ///
1194 | [System.Xml.Serialization.XmlEnumAttribute("this-month")]
1195 | thismonth,
1196 |
1197 | ///
1198 | [System.Xml.Serialization.XmlEnumAttribute("next-month")]
1199 | nextmonth,
1200 |
1201 | ///
1202 | on,
1203 |
1204 | ///
1205 | [System.Xml.Serialization.XmlEnumAttribute("on-or-before")]
1206 | onorbefore,
1207 |
1208 | ///
1209 | [System.Xml.Serialization.XmlEnumAttribute("on-or-after")]
1210 | onorafter,
1211 |
1212 | ///
1213 | [System.Xml.Serialization.XmlEnumAttribute("last-year")]
1214 | lastyear,
1215 |
1216 | ///
1217 | [System.Xml.Serialization.XmlEnumAttribute("this-year")]
1218 | thisyear,
1219 |
1220 | ///
1221 | [System.Xml.Serialization.XmlEnumAttribute("next-year")]
1222 | nextyear,
1223 |
1224 | ///
1225 | [System.Xml.Serialization.XmlEnumAttribute("last-x-hours")]
1226 | lastxhours,
1227 |
1228 | ///
1229 | [System.Xml.Serialization.XmlEnumAttribute("next-x-hours")]
1230 | nextxhours,
1231 |
1232 | ///
1233 | [System.Xml.Serialization.XmlEnumAttribute("last-x-days")]
1234 | lastxdays,
1235 |
1236 | ///
1237 | [System.Xml.Serialization.XmlEnumAttribute("next-x-days")]
1238 | nextxdays,
1239 |
1240 | ///
1241 | [System.Xml.Serialization.XmlEnumAttribute("last-x-weeks")]
1242 | lastxweeks,
1243 |
1244 | ///
1245 | [System.Xml.Serialization.XmlEnumAttribute("next-x-weeks")]
1246 | nextxweeks,
1247 |
1248 | ///
1249 | [System.Xml.Serialization.XmlEnumAttribute("last-x-months")]
1250 | lastxmonths,
1251 |
1252 | ///
1253 | [System.Xml.Serialization.XmlEnumAttribute("next-x-months")]
1254 | nextxmonths,
1255 |
1256 | ///
1257 | [System.Xml.Serialization.XmlEnumAttribute("olderthan-x-months")]
1258 | olderthanxmonths,
1259 |
1260 | ///
1261 | [System.Xml.Serialization.XmlEnumAttribute("olderthan-x-years")]
1262 | olderthanxyears,
1263 |
1264 | ///
1265 | [System.Xml.Serialization.XmlEnumAttribute("olderthan-x-weeks")]
1266 | olderthanxweeks,
1267 |
1268 | ///
1269 | [System.Xml.Serialization.XmlEnumAttribute("olderthan-x-days")]
1270 | olderthanxdays,
1271 |
1272 | ///
1273 | [System.Xml.Serialization.XmlEnumAttribute("olderthan-x-hours")]
1274 | olderthanxhours,
1275 |
1276 | ///
1277 | [System.Xml.Serialization.XmlEnumAttribute("olderthan-x-minutes")]
1278 | olderthanxminutes,
1279 |
1280 | ///
1281 | [System.Xml.Serialization.XmlEnumAttribute("last-x-years")]
1282 | lastxyears,
1283 |
1284 | ///
1285 | [System.Xml.Serialization.XmlEnumAttribute("next-x-years")]
1286 | nextxyears,
1287 |
1288 | ///
1289 | [System.Xml.Serialization.XmlEnumAttribute("eq-userid")]
1290 | equserid,
1291 |
1292 | ///
1293 | [System.Xml.Serialization.XmlEnumAttribute("ne-userid")]
1294 | neuserid,
1295 |
1296 | ///
1297 | [System.Xml.Serialization.XmlEnumAttribute("eq-userteams")]
1298 | equserteams,
1299 |
1300 | ///
1301 | [System.Xml.Serialization.XmlEnumAttribute("eq-useroruserteams")]
1302 | equseroruserteams,
1303 |
1304 | ///
1305 | [System.Xml.Serialization.XmlEnumAttribute("eq-useroruserhierarchy")]
1306 | equseroruserhierarchy,
1307 |
1308 | ///
1309 | [System.Xml.Serialization.XmlEnumAttribute("eq-useroruserhierarchyandteams")]
1310 | equseroruserhierarchyandteams,
1311 |
1312 | ///
1313 | [System.Xml.Serialization.XmlEnumAttribute("eq-businessid")]
1314 | eqbusinessid,
1315 |
1316 | ///
1317 | [System.Xml.Serialization.XmlEnumAttribute("ne-businessid")]
1318 | nebusinessid,
1319 |
1320 | ///
1321 | [System.Xml.Serialization.XmlEnumAttribute("eq-userlanguage")]
1322 | equserlanguage,
1323 |
1324 | ///
1325 | [System.Xml.Serialization.XmlEnumAttribute("this-fiscal-year")]
1326 | thisfiscalyear,
1327 |
1328 | ///
1329 | [System.Xml.Serialization.XmlEnumAttribute("this-fiscal-period")]
1330 | thisfiscalperiod,
1331 |
1332 | ///
1333 | [System.Xml.Serialization.XmlEnumAttribute("next-fiscal-year")]
1334 | nextfiscalyear,
1335 |
1336 | ///
1337 | [System.Xml.Serialization.XmlEnumAttribute("next-fiscal-period")]
1338 | nextfiscalperiod,
1339 |
1340 | ///
1341 | [System.Xml.Serialization.XmlEnumAttribute("last-fiscal-year")]
1342 | lastfiscalyear,
1343 |
1344 | ///
1345 | [System.Xml.Serialization.XmlEnumAttribute("last-fiscal-period")]
1346 | lastfiscalperiod,
1347 |
1348 | ///
1349 | [System.Xml.Serialization.XmlEnumAttribute("last-x-fiscal-years")]
1350 | lastxfiscalyears,
1351 |
1352 | ///
1353 | [System.Xml.Serialization.XmlEnumAttribute("last-x-fiscal-periods")]
1354 | lastxfiscalperiods,
1355 |
1356 | ///
1357 | [System.Xml.Serialization.XmlEnumAttribute("next-x-fiscal-years")]
1358 | nextxfiscalyears,
1359 |
1360 | ///
1361 | [System.Xml.Serialization.XmlEnumAttribute("next-x-fiscal-periods")]
1362 | nextxfiscalperiods,
1363 |
1364 | ///
1365 | [System.Xml.Serialization.XmlEnumAttribute("in-fiscal-year")]
1366 | infiscalyear,
1367 |
1368 | ///
1369 | [System.Xml.Serialization.XmlEnumAttribute("in-fiscal-period")]
1370 | infiscalperiod,
1371 |
1372 | ///
1373 | [System.Xml.Serialization.XmlEnumAttribute("in-fiscal-period-and-year")]
1374 | infiscalperiodandyear,
1375 |
1376 | ///
1377 | [System.Xml.Serialization.XmlEnumAttribute("in-or-before-fiscal-period-and-year")]
1378 | inorbeforefiscalperiodandyear,
1379 |
1380 | ///
1381 | [System.Xml.Serialization.XmlEnumAttribute("in-or-after-fiscal-period-and-year")]
1382 | inorafterfiscalperiodandyear,
1383 |
1384 | ///
1385 | [System.Xml.Serialization.XmlEnumAttribute("begins-with")]
1386 | beginswith,
1387 |
1388 | ///
1389 | [System.Xml.Serialization.XmlEnumAttribute("not-begin-with")]
1390 | notbeginwith,
1391 |
1392 | ///
1393 | [System.Xml.Serialization.XmlEnumAttribute("ends-with")]
1394 | endswith,
1395 |
1396 | ///
1397 | [System.Xml.Serialization.XmlEnumAttribute("not-end-with")]
1398 | notendwith,
1399 |
1400 | ///
1401 | under,
1402 |
1403 | ///
1404 | [System.Xml.Serialization.XmlEnumAttribute("eq-or-under")]
1405 | eqorunder,
1406 |
1407 | ///
1408 | [System.Xml.Serialization.XmlEnumAttribute("not-under")]
1409 | notunder,
1410 |
1411 | ///
1412 | above,
1413 |
1414 | ///
1415 | [System.Xml.Serialization.XmlEnumAttribute("eq-or-above")]
1416 | eqorabove,
1417 |
1418 | ///
1419 | [System.Xml.Serialization.XmlEnumAttribute("contain-values")]
1420 | containvalues,
1421 |
1422 | ///
1423 | [System.Xml.Serialization.XmlEnumAttribute("not-contain-values")]
1424 | notcontainvalues,
1425 | }
1426 |
1427 | ///
1428 | [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.1055.0")]
1429 | [System.SerializableAttribute()]
1430 | public enum RowAggregateType {
1431 |
1432 | ///
1433 | countchildren,
1434 | }
1435 |
1436 | ///
1437 | [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.1055.0")]
1438 | [System.SerializableAttribute()]
1439 | [System.Diagnostics.DebuggerStepThroughAttribute()]
1440 | [System.ComponentModel.DesignerCategoryAttribute("code")]
1441 | [System.Xml.Serialization.XmlRootAttribute("fetch", Namespace="", IsNullable=false)]
1442 | public partial class FetchType {
1443 |
1444 | private object[] itemsField;
1445 |
1446 | private string versionField;
1447 |
1448 | private string countField;
1449 |
1450 | private string pageField;
1451 |
1452 | private string pagingcookieField;
1453 |
1454 | private string utcoffsetField;
1455 |
1456 | private bool aggregateField;
1457 |
1458 | private bool aggregateFieldSpecified;
1459 |
1460 | private bool distinctField;
1461 |
1462 | private bool distinctFieldSpecified;
1463 |
1464 | private string topField;
1465 |
1466 | private FetchTypeMapping mappingField;
1467 |
1468 | private bool mappingFieldSpecified;
1469 |
1470 | private bool minactiverowversionField;
1471 |
1472 | private FetchTypeOutputformat outputformatField;
1473 |
1474 | private bool outputformatFieldSpecified;
1475 |
1476 | private bool returntotalrecordcountField;
1477 |
1478 | private bool nolockField;
1479 |
1480 | public FetchType() {
1481 | this.minactiverowversionField = false;
1482 | this.returntotalrecordcountField = false;
1483 | this.nolockField = false;
1484 | }
1485 |
1486 | ///
1487 | [System.Xml.Serialization.XmlElementAttribute("entity", typeof(FetchEntityType))]
1488 | [System.Xml.Serialization.XmlElementAttribute("order", typeof(FetchOrderType))]
1489 | public object[] Items {
1490 | get {
1491 | return this.itemsField;
1492 | }
1493 | set {
1494 | this.itemsField = value;
1495 | }
1496 | }
1497 |
1498 | ///
1499 | [System.Xml.Serialization.XmlAttributeAttribute()]
1500 | public string version {
1501 | get {
1502 | return this.versionField;
1503 | }
1504 | set {
1505 | this.versionField = value;
1506 | }
1507 | }
1508 |
1509 | ///
1510 | [System.Xml.Serialization.XmlAttributeAttribute(DataType="integer")]
1511 | public string count {
1512 | get {
1513 | return this.countField;
1514 | }
1515 | set {
1516 | this.countField = value;
1517 | }
1518 | }
1519 |
1520 | ///
1521 | [System.Xml.Serialization.XmlAttributeAttribute(DataType="integer")]
1522 | public string page {
1523 | get {
1524 | return this.pageField;
1525 | }
1526 | set {
1527 | this.pageField = value;
1528 | }
1529 | }
1530 |
1531 | ///
1532 | [System.Xml.Serialization.XmlAttributeAttribute("paging-cookie")]
1533 | public string pagingcookie {
1534 | get {
1535 | return this.pagingcookieField;
1536 | }
1537 | set {
1538 | this.pagingcookieField = value;
1539 | }
1540 | }
1541 |
1542 | ///
1543 | [System.Xml.Serialization.XmlAttributeAttribute("utc-offset")]
1544 | public string utcoffset {
1545 | get {
1546 | return this.utcoffsetField;
1547 | }
1548 | set {
1549 | this.utcoffsetField = value;
1550 | }
1551 | }
1552 |
1553 | ///
1554 | [System.Xml.Serialization.XmlAttributeAttribute()]
1555 | public bool aggregate {
1556 | get {
1557 | return this.aggregateField;
1558 | }
1559 | set {
1560 | this.aggregateField = value;
1561 | }
1562 | }
1563 |
1564 | ///
1565 | [System.Xml.Serialization.XmlIgnoreAttribute()]
1566 | public bool aggregateSpecified {
1567 | get {
1568 | return this.aggregateFieldSpecified;
1569 | }
1570 | set {
1571 | this.aggregateFieldSpecified = value;
1572 | }
1573 | }
1574 |
1575 | ///
1576 | [System.Xml.Serialization.XmlAttributeAttribute()]
1577 | public bool distinct {
1578 | get {
1579 | return this.distinctField;
1580 | }
1581 | set {
1582 | this.distinctField = value;
1583 | }
1584 | }
1585 |
1586 | ///
1587 | [System.Xml.Serialization.XmlIgnoreAttribute()]
1588 | public bool distinctSpecified {
1589 | get {
1590 | return this.distinctFieldSpecified;
1591 | }
1592 | set {
1593 | this.distinctFieldSpecified = value;
1594 | }
1595 | }
1596 |
1597 | ///
1598 | [System.Xml.Serialization.XmlAttributeAttribute(DataType="integer")]
1599 | public string top {
1600 | get {
1601 | return this.topField;
1602 | }
1603 | set {
1604 | this.topField = value;
1605 | }
1606 | }
1607 |
1608 | ///
1609 | [System.Xml.Serialization.XmlAttributeAttribute()]
1610 | public FetchTypeMapping mapping {
1611 | get {
1612 | return this.mappingField;
1613 | }
1614 | set {
1615 | this.mappingField = value;
1616 | }
1617 | }
1618 |
1619 | ///
1620 | [System.Xml.Serialization.XmlIgnoreAttribute()]
1621 | public bool mappingSpecified {
1622 | get {
1623 | return this.mappingFieldSpecified;
1624 | }
1625 | set {
1626 | this.mappingFieldSpecified = value;
1627 | }
1628 | }
1629 |
1630 | ///
1631 | [System.Xml.Serialization.XmlAttributeAttribute("min-active-row-version")]
1632 | [System.ComponentModel.DefaultValueAttribute(false)]
1633 | public bool minactiverowversion {
1634 | get {
1635 | return this.minactiverowversionField;
1636 | }
1637 | set {
1638 | this.minactiverowversionField = value;
1639 | }
1640 | }
1641 |
1642 | ///
1643 | [System.Xml.Serialization.XmlAttributeAttribute("output-format")]
1644 | public FetchTypeOutputformat outputformat {
1645 | get {
1646 | return this.outputformatField;
1647 | }
1648 | set {
1649 | this.outputformatField = value;
1650 | }
1651 | }
1652 |
1653 | ///
1654 | [System.Xml.Serialization.XmlIgnoreAttribute()]
1655 | public bool outputformatSpecified {
1656 | get {
1657 | return this.outputformatFieldSpecified;
1658 | }
1659 | set {
1660 | this.outputformatFieldSpecified = value;
1661 | }
1662 | }
1663 |
1664 | ///
1665 | [System.Xml.Serialization.XmlAttributeAttribute()]
1666 | [System.ComponentModel.DefaultValueAttribute(false)]
1667 | public bool returntotalrecordcount {
1668 | get {
1669 | return this.returntotalrecordcountField;
1670 | }
1671 | set {
1672 | this.returntotalrecordcountField = value;
1673 | }
1674 | }
1675 |
1676 | ///
1677 | [System.Xml.Serialization.XmlAttributeAttribute("no-lock")]
1678 | [System.ComponentModel.DefaultValueAttribute(false)]
1679 | public bool nolock {
1680 | get {
1681 | return this.nolockField;
1682 | }
1683 | set {
1684 | this.nolockField = value;
1685 | }
1686 | }
1687 | }
1688 |
1689 | ///
1690 | [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.1055.0")]
1691 | [System.SerializableAttribute()]
1692 | [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
1693 | public enum FetchTypeMapping {
1694 |
1695 | ///
1696 | @internal,
1697 |
1698 | ///
1699 | logical,
1700 | }
1701 |
1702 | ///
1703 | [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.1055.0")]
1704 | [System.SerializableAttribute()]
1705 | [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
1706 | public enum FetchTypeOutputformat {
1707 |
1708 | ///
1709 | [System.Xml.Serialization.XmlEnumAttribute("xml-ado")]
1710 | xmlado,
1711 |
1712 | ///
1713 | [System.Xml.Serialization.XmlEnumAttribute("xml-auto")]
1714 | xmlauto,
1715 |
1716 | ///
1717 | [System.Xml.Serialization.XmlEnumAttribute("xml-elements")]
1718 | xmlelements,
1719 |
1720 | ///
1721 | [System.Xml.Serialization.XmlEnumAttribute("xml-raw")]
1722 | xmlraw,
1723 |
1724 | ///
1725 | [System.Xml.Serialization.XmlEnumAttribute("xml-platform")]
1726 | xmlplatform,
1727 | }
1728 |
1729 | ///
1730 | [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.1055.0")]
1731 | [System.SerializableAttribute()]
1732 | [System.Diagnostics.DebuggerStepThroughAttribute()]
1733 | [System.ComponentModel.DesignerCategoryAttribute("code")]
1734 | [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
1735 | [System.Xml.Serialization.XmlRootAttribute(Namespace="", IsNullable=false)]
1736 | public partial class savedquery {
1737 |
1738 | private string nameField;
1739 |
1740 | private string savedqueryidField;
1741 |
1742 | private SerializedInteger returnedtypecodeField;
1743 |
1744 | private string descriptionField;
1745 |
1746 | private SerializedInteger querytypeField;
1747 |
1748 | private SerializedTrueFalse01Type isCustomizableField;
1749 |
1750 | private SerializedTrueFalse01Type canBeDeletedField;
1751 |
1752 | private string introducedVersionField;
1753 |
1754 | private SerializedTrueFalse01Type isquickfindqueryField;
1755 |
1756 | private SerializedTrueFalse01Type isuserdefinedField;
1757 |
1758 | private SerializedTrueFalse01Type isdefaultField;
1759 |
1760 | private bool isprivateField;
1761 |
1762 | private bool isprivateFieldSpecified;
1763 |
1764 | private string queryapiField;
1765 |
1766 | private savedqueryFetchxml fetchxmlField;
1767 |
1768 | private savedqueryColumnsetxml columnsetxmlField;
1769 |
1770 | private savedqueryLayoutxml layoutxmlField;
1771 |
1772 | private string donotuseinLCIDField;
1773 |
1774 | private string useinLCIDField;
1775 |
1776 | ///
1777 | public string name {
1778 | get {
1779 | return this.nameField;
1780 | }
1781 | set {
1782 | this.nameField = value;
1783 | }
1784 | }
1785 |
1786 | ///
1787 | public string savedqueryid {
1788 | get {
1789 | return this.savedqueryidField;
1790 | }
1791 | set {
1792 | this.savedqueryidField = value;
1793 | }
1794 | }
1795 |
1796 | ///
1797 | public SerializedInteger returnedtypecode {
1798 | get {
1799 | return this.returnedtypecodeField;
1800 | }
1801 | set {
1802 | this.returnedtypecodeField = value;
1803 | }
1804 | }
1805 |
1806 | ///
1807 | public string description {
1808 | get {
1809 | return this.descriptionField;
1810 | }
1811 | set {
1812 | this.descriptionField = value;
1813 | }
1814 | }
1815 |
1816 | ///
1817 | public SerializedInteger querytype {
1818 | get {
1819 | return this.querytypeField;
1820 | }
1821 | set {
1822 | this.querytypeField = value;
1823 | }
1824 | }
1825 |
1826 | ///
1827 | public SerializedTrueFalse01Type IsCustomizable {
1828 | get {
1829 | return this.isCustomizableField;
1830 | }
1831 | set {
1832 | this.isCustomizableField = value;
1833 | }
1834 | }
1835 |
1836 | ///
1837 | public SerializedTrueFalse01Type CanBeDeleted {
1838 | get {
1839 | return this.canBeDeletedField;
1840 | }
1841 | set {
1842 | this.canBeDeletedField = value;
1843 | }
1844 | }
1845 |
1846 | ///
1847 | public string IntroducedVersion {
1848 | get {
1849 | return this.introducedVersionField;
1850 | }
1851 | set {
1852 | this.introducedVersionField = value;
1853 | }
1854 | }
1855 |
1856 | ///
1857 | public SerializedTrueFalse01Type isquickfindquery {
1858 | get {
1859 | return this.isquickfindqueryField;
1860 | }
1861 | set {
1862 | this.isquickfindqueryField = value;
1863 | }
1864 | }
1865 |
1866 | ///
1867 | public SerializedTrueFalse01Type isuserdefined {
1868 | get {
1869 | return this.isuserdefinedField;
1870 | }
1871 | set {
1872 | this.isuserdefinedField = value;
1873 | }
1874 | }
1875 |
1876 | ///
1877 | public SerializedTrueFalse01Type isdefault {
1878 | get {
1879 | return this.isdefaultField;
1880 | }
1881 | set {
1882 | this.isdefaultField = value;
1883 | }
1884 | }
1885 |
1886 | ///
1887 | public bool isprivate {
1888 | get {
1889 | return this.isprivateField;
1890 | }
1891 | set {
1892 | this.isprivateField = value;
1893 | }
1894 | }
1895 |
1896 | ///
1897 | [System.Xml.Serialization.XmlIgnoreAttribute()]
1898 | public bool isprivateSpecified {
1899 | get {
1900 | return this.isprivateFieldSpecified;
1901 | }
1902 | set {
1903 | this.isprivateFieldSpecified = value;
1904 | }
1905 | }
1906 |
1907 | ///
1908 | public string queryapi {
1909 | get {
1910 | return this.queryapiField;
1911 | }
1912 | set {
1913 | this.queryapiField = value;
1914 | }
1915 | }
1916 |
1917 | ///
1918 | public savedqueryFetchxml fetchxml {
1919 | get {
1920 | return this.fetchxmlField;
1921 | }
1922 | set {
1923 | this.fetchxmlField = value;
1924 | }
1925 | }
1926 |
1927 | ///
1928 | public savedqueryColumnsetxml columnsetxml {
1929 | get {
1930 | return this.columnsetxmlField;
1931 | }
1932 | set {
1933 | this.columnsetxmlField = value;
1934 | }
1935 | }
1936 |
1937 | ///
1938 | public savedqueryLayoutxml layoutxml {
1939 | get {
1940 | return this.layoutxmlField;
1941 | }
1942 | set {
1943 | this.layoutxmlField = value;
1944 | }
1945 | }
1946 |
1947 | ///
1948 | [System.Xml.Serialization.XmlAttributeAttribute()]
1949 | public string donotuseinLCID {
1950 | get {
1951 | return this.donotuseinLCIDField;
1952 | }
1953 | set {
1954 | this.donotuseinLCIDField = value;
1955 | }
1956 | }
1957 |
1958 | ///
1959 | [System.Xml.Serialization.XmlAttributeAttribute()]
1960 | public string useinLCID {
1961 | get {
1962 | return this.useinLCIDField;
1963 | }
1964 | set {
1965 | this.useinLCIDField = value;
1966 | }
1967 | }
1968 | }
1969 |
1970 | ///
1971 | [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.1055.0")]
1972 | [System.SerializableAttribute()]
1973 | [System.Diagnostics.DebuggerStepThroughAttribute()]
1974 | [System.ComponentModel.DesignerCategoryAttribute("code")]
1975 | [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
1976 | public partial class savedqueryFetchxml {
1977 |
1978 | private FetchType fetchField;
1979 |
1980 | ///
1981 | public FetchType fetch {
1982 | get {
1983 | return this.fetchField;
1984 | }
1985 | set {
1986 | this.fetchField = value;
1987 | }
1988 | }
1989 | }
1990 |
1991 | ///
1992 | [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.1055.0")]
1993 | [System.SerializableAttribute()]
1994 | [System.Diagnostics.DebuggerStepThroughAttribute()]
1995 | [System.ComponentModel.DesignerCategoryAttribute("code")]
1996 | [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
1997 | public partial class savedqueryColumnsetxml {
1998 |
1999 | private savedqueryColumnsetxmlColumnset columnsetField;
2000 |
2001 | ///
2002 | public savedqueryColumnsetxmlColumnset columnset {
2003 | get {
2004 | return this.columnsetField;
2005 | }
2006 | set {
2007 | this.columnsetField = value;
2008 | }
2009 | }
2010 | }
2011 |
2012 | ///
2013 | [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.1055.0")]
2014 | [System.SerializableAttribute()]
2015 | [System.Diagnostics.DebuggerStepThroughAttribute()]
2016 | [System.ComponentModel.DesignerCategoryAttribute("code")]
2017 | [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
2018 | public partial class savedqueryColumnsetxmlColumnset {
2019 |
2020 | private object[] itemsField;
2021 |
2022 | private ItemsChoiceType[] itemsElementNameField;
2023 |
2024 | private string versionField;
2025 |
2026 | private bool distinctField;
2027 |
2028 | private bool distinctFieldSpecified;
2029 |
2030 | ///
2031 | [System.Xml.Serialization.XmlElementAttribute("ascend", typeof(object))]
2032 | [System.Xml.Serialization.XmlElementAttribute("column", typeof(savedqueryColumnsetxmlColumnsetColumn))]
2033 | [System.Xml.Serialization.XmlElementAttribute("descend", typeof(object))]
2034 | [System.Xml.Serialization.XmlElementAttribute("filter", typeof(savedqueryColumnsetxmlColumnsetFilter))]
2035 | [System.Xml.Serialization.XmlChoiceIdentifierAttribute("ItemsElementName")]
2036 | public object[] Items {
2037 | get {
2038 | return this.itemsField;
2039 | }
2040 | set {
2041 | this.itemsField = value;
2042 | }
2043 | }
2044 |
2045 | ///
2046 | [System.Xml.Serialization.XmlElementAttribute("ItemsElementName")]
2047 | [System.Xml.Serialization.XmlIgnoreAttribute()]
2048 | public ItemsChoiceType[] ItemsElementName {
2049 | get {
2050 | return this.itemsElementNameField;
2051 | }
2052 | set {
2053 | this.itemsElementNameField = value;
2054 | }
2055 | }
2056 |
2057 | ///
2058 | [System.Xml.Serialization.XmlAttributeAttribute()]
2059 | public string version {
2060 | get {
2061 | return this.versionField;
2062 | }
2063 | set {
2064 | this.versionField = value;
2065 | }
2066 | }
2067 |
2068 | ///
2069 | [System.Xml.Serialization.XmlAttributeAttribute()]
2070 | public bool distinct {
2071 | get {
2072 | return this.distinctField;
2073 | }
2074 | set {
2075 | this.distinctField = value;
2076 | }
2077 | }
2078 |
2079 | ///
2080 | [System.Xml.Serialization.XmlIgnoreAttribute()]
2081 | public bool distinctSpecified {
2082 | get {
2083 | return this.distinctFieldSpecified;
2084 | }
2085 | set {
2086 | this.distinctFieldSpecified = value;
2087 | }
2088 | }
2089 | }
2090 |
2091 | ///
2092 | [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.1055.0")]
2093 | [System.SerializableAttribute()]
2094 | [System.Diagnostics.DebuggerStepThroughAttribute()]
2095 | [System.ComponentModel.DesignerCategoryAttribute("code")]
2096 | [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
2097 | public partial class savedqueryColumnsetxmlColumnsetColumn {
2098 |
2099 | private build buildField;
2100 |
2101 | private bool buildFieldSpecified;
2102 |
2103 | private string addedbyField;
2104 |
2105 | private string valueField;
2106 |
2107 | ///
2108 | [System.Xml.Serialization.XmlAttributeAttribute()]
2109 | public build build {
2110 | get {
2111 | return this.buildField;
2112 | }
2113 | set {
2114 | this.buildField = value;
2115 | }
2116 | }
2117 |
2118 | ///
2119 | [System.Xml.Serialization.XmlIgnoreAttribute()]
2120 | public bool buildSpecified {
2121 | get {
2122 | return this.buildFieldSpecified;
2123 | }
2124 | set {
2125 | this.buildFieldSpecified = value;
2126 | }
2127 | }
2128 |
2129 | ///
2130 | [System.Xml.Serialization.XmlAttributeAttribute()]
2131 | public string addedby {
2132 | get {
2133 | return this.addedbyField;
2134 | }
2135 | set {
2136 | this.addedbyField = value;
2137 | }
2138 | }
2139 |
2140 | ///
2141 | [System.Xml.Serialization.XmlTextAttribute()]
2142 | public string Value {
2143 | get {
2144 | return this.valueField;
2145 | }
2146 | set {
2147 | this.valueField = value;
2148 | }
2149 | }
2150 | }
2151 |
2152 | ///
2153 | [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.1055.0")]
2154 | [System.SerializableAttribute()]
2155 | [System.Diagnostics.DebuggerStepThroughAttribute()]
2156 | [System.ComponentModel.DesignerCategoryAttribute("code")]
2157 | [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
2158 | public partial class savedqueryColumnsetxmlColumnsetFilter {
2159 |
2160 | private savedqueryColumnsetxmlColumnsetFilterCondition[] conditionField;
2161 |
2162 | private string columnField;
2163 |
2164 | private @operator operatorField;
2165 |
2166 | private bool operatorFieldSpecified;
2167 |
2168 | private string valueField;
2169 |
2170 | private string typeField;
2171 |
2172 | ///
2173 | [System.Xml.Serialization.XmlElementAttribute("condition")]
2174 | public savedqueryColumnsetxmlColumnsetFilterCondition[] condition {
2175 | get {
2176 | return this.conditionField;
2177 | }
2178 | set {
2179 | this.conditionField = value;
2180 | }
2181 | }
2182 |
2183 | ///
2184 | [System.Xml.Serialization.XmlAttributeAttribute()]
2185 | public string column {
2186 | get {
2187 | return this.columnField;
2188 | }
2189 | set {
2190 | this.columnField = value;
2191 | }
2192 | }
2193 |
2194 | ///
2195 | [System.Xml.Serialization.XmlAttributeAttribute()]
2196 | public @operator @operator {
2197 | get {
2198 | return this.operatorField;
2199 | }
2200 | set {
2201 | this.operatorField = value;
2202 | }
2203 | }
2204 |
2205 | ///
2206 | [System.Xml.Serialization.XmlIgnoreAttribute()]
2207 | public bool operatorSpecified {
2208 | get {
2209 | return this.operatorFieldSpecified;
2210 | }
2211 | set {
2212 | this.operatorFieldSpecified = value;
2213 | }
2214 | }
2215 |
2216 | ///
2217 | [System.Xml.Serialization.XmlAttributeAttribute()]
2218 | public string value {
2219 | get {
2220 | return this.valueField;
2221 | }
2222 | set {
2223 | this.valueField = value;
2224 | }
2225 | }
2226 |
2227 | ///
2228 | [System.Xml.Serialization.XmlAttributeAttribute()]
2229 | public string type {
2230 | get {
2231 | return this.typeField;
2232 | }
2233 | set {
2234 | this.typeField = value;
2235 | }
2236 | }
2237 | }
2238 |
2239 | ///
2240 | [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.1055.0")]
2241 | [System.SerializableAttribute()]
2242 | [System.Diagnostics.DebuggerStepThroughAttribute()]
2243 | [System.ComponentModel.DesignerCategoryAttribute("code")]
2244 | [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
2245 | public partial class savedqueryColumnsetxmlColumnsetFilterCondition {
2246 |
2247 | private string columnField;
2248 |
2249 | private @operator operatorField;
2250 |
2251 | private bool operatorFieldSpecified;
2252 |
2253 | private string valueField;
2254 |
2255 | ///
2256 | [System.Xml.Serialization.XmlAttributeAttribute()]
2257 | public string column {
2258 | get {
2259 | return this.columnField;
2260 | }
2261 | set {
2262 | this.columnField = value;
2263 | }
2264 | }
2265 |
2266 | ///
2267 | [System.Xml.Serialization.XmlAttributeAttribute()]
2268 | public @operator @operator {
2269 | get {
2270 | return this.operatorField;
2271 | }
2272 | set {
2273 | this.operatorField = value;
2274 | }
2275 | }
2276 |
2277 | ///
2278 | [System.Xml.Serialization.XmlIgnoreAttribute()]
2279 | public bool operatorSpecified {
2280 | get {
2281 | return this.operatorFieldSpecified;
2282 | }
2283 | set {
2284 | this.operatorFieldSpecified = value;
2285 | }
2286 | }
2287 |
2288 | ///
2289 | [System.Xml.Serialization.XmlAttributeAttribute()]
2290 | public string value {
2291 | get {
2292 | return this.valueField;
2293 | }
2294 | set {
2295 | this.valueField = value;
2296 | }
2297 | }
2298 | }
2299 |
2300 | ///
2301 | [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.1055.0")]
2302 | [System.SerializableAttribute()]
2303 | [System.Xml.Serialization.XmlTypeAttribute(IncludeInSchema=false)]
2304 | public enum ItemsChoiceType {
2305 |
2306 | ///
2307 | ascend,
2308 |
2309 | ///
2310 | column,
2311 |
2312 | ///
2313 | descend,
2314 |
2315 | ///
2316 | filter,
2317 | }
2318 |
2319 | ///
2320 | [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.1055.0")]
2321 | [System.SerializableAttribute()]
2322 | [System.Diagnostics.DebuggerStepThroughAttribute()]
2323 | [System.ComponentModel.DesignerCategoryAttribute("code")]
2324 | [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
2325 | public partial class savedqueryLayoutxml {
2326 |
2327 | private savedqueryLayoutxmlGrid gridField;
2328 |
2329 | ///
2330 | public savedqueryLayoutxmlGrid grid {
2331 | get {
2332 | return this.gridField;
2333 | }
2334 | set {
2335 | this.gridField = value;
2336 | }
2337 | }
2338 | }
2339 |
2340 | ///
2341 | [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.1055.0")]
2342 | [System.SerializableAttribute()]
2343 | [System.Diagnostics.DebuggerStepThroughAttribute()]
2344 | [System.ComponentModel.DesignerCategoryAttribute("code")]
2345 | [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
2346 | public partial class savedqueryLayoutxmlGrid {
2347 |
2348 | private savedqueryLayoutxmlGridRow rowField;
2349 |
2350 | private string nameField;
2351 |
2352 | private bool selectField;
2353 |
2354 | private string previewField;
2355 |
2356 | private string iconField;
2357 |
2358 | private string jumpField;
2359 |
2360 | private string objectField;
2361 |
2362 | private string disableInlineEditingField;
2363 |
2364 | private string iconrendererField;
2365 |
2366 | private string multilinerowsField;
2367 |
2368 | ///
2369 | public savedqueryLayoutxmlGridRow row {
2370 | get {
2371 | return this.rowField;
2372 | }
2373 | set {
2374 | this.rowField = value;
2375 | }
2376 | }
2377 |
2378 | ///
2379 | [System.Xml.Serialization.XmlAttributeAttribute()]
2380 | public string name {
2381 | get {
2382 | return this.nameField;
2383 | }
2384 | set {
2385 | this.nameField = value;
2386 | }
2387 | }
2388 |
2389 | ///
2390 | [System.Xml.Serialization.XmlAttributeAttribute()]
2391 | public bool select {
2392 | get {
2393 | return this.selectField;
2394 | }
2395 | set {
2396 | this.selectField = value;
2397 | }
2398 | }
2399 |
2400 | ///
2401 | [System.Xml.Serialization.XmlAttributeAttribute()]
2402 | public string preview {
2403 | get {
2404 | return this.previewField;
2405 | }
2406 | set {
2407 | this.previewField = value;
2408 | }
2409 | }
2410 |
2411 | ///
2412 | [System.Xml.Serialization.XmlAttributeAttribute()]
2413 | public string icon {
2414 | get {
2415 | return this.iconField;
2416 | }
2417 | set {
2418 | this.iconField = value;
2419 | }
2420 | }
2421 |
2422 | ///
2423 | [System.Xml.Serialization.XmlAttributeAttribute()]
2424 | public string jump {
2425 | get {
2426 | return this.jumpField;
2427 | }
2428 | set {
2429 | this.jumpField = value;
2430 | }
2431 | }
2432 |
2433 | ///
2434 | [System.Xml.Serialization.XmlAttributeAttribute(DataType="integer")]
2435 | public string @object {
2436 | get {
2437 | return this.objectField;
2438 | }
2439 | set {
2440 | this.objectField = value;
2441 | }
2442 | }
2443 |
2444 | ///
2445 | [System.Xml.Serialization.XmlAttributeAttribute(DataType="integer")]
2446 | public string disableInlineEditing {
2447 | get {
2448 | return this.disableInlineEditingField;
2449 | }
2450 | set {
2451 | this.disableInlineEditingField = value;
2452 | }
2453 | }
2454 |
2455 | ///
2456 | [System.Xml.Serialization.XmlAttributeAttribute()]
2457 | public string iconrenderer {
2458 | get {
2459 | return this.iconrendererField;
2460 | }
2461 | set {
2462 | this.iconrendererField = value;
2463 | }
2464 | }
2465 |
2466 | ///
2467 | [System.Xml.Serialization.XmlAttributeAttribute()]
2468 | public string multilinerows {
2469 | get {
2470 | return this.multilinerowsField;
2471 | }
2472 | set {
2473 | this.multilinerowsField = value;
2474 | }
2475 | }
2476 | }
2477 |
2478 | ///
2479 | [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.1055.0")]
2480 | [System.SerializableAttribute()]
2481 | [System.Diagnostics.DebuggerStepThroughAttribute()]
2482 | [System.ComponentModel.DesignerCategoryAttribute("code")]
2483 | [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
2484 | public partial class savedqueryLayoutxmlGridRow {
2485 |
2486 | private savedqueryLayoutxmlGridRowCell[] cellField;
2487 |
2488 | private string nameField;
2489 |
2490 | private string idField;
2491 |
2492 | private string multiobjectidfieldField;
2493 |
2494 | private string layoutstyleField;
2495 |
2496 | ///
2497 | [System.Xml.Serialization.XmlElementAttribute("cell")]
2498 | public savedqueryLayoutxmlGridRowCell[] cell {
2499 | get {
2500 | return this.cellField;
2501 | }
2502 | set {
2503 | this.cellField = value;
2504 | }
2505 | }
2506 |
2507 | ///
2508 | [System.Xml.Serialization.XmlAttributeAttribute()]
2509 | public string name {
2510 | get {
2511 | return this.nameField;
2512 | }
2513 | set {
2514 | this.nameField = value;
2515 | }
2516 | }
2517 |
2518 | ///
2519 | [System.Xml.Serialization.XmlAttributeAttribute()]
2520 | public string id {
2521 | get {
2522 | return this.idField;
2523 | }
2524 | set {
2525 | this.idField = value;
2526 | }
2527 | }
2528 |
2529 | ///
2530 | [System.Xml.Serialization.XmlAttributeAttribute()]
2531 | public string multiobjectidfield {
2532 | get {
2533 | return this.multiobjectidfieldField;
2534 | }
2535 | set {
2536 | this.multiobjectidfieldField = value;
2537 | }
2538 | }
2539 |
2540 | ///
2541 | [System.Xml.Serialization.XmlAttributeAttribute()]
2542 | public string layoutstyle {
2543 | get {
2544 | return this.layoutstyleField;
2545 | }
2546 | set {
2547 | this.layoutstyleField = value;
2548 | }
2549 | }
2550 | }
2551 |
2552 | ///
2553 | [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.1055.0")]
2554 | [System.SerializableAttribute()]
2555 | [System.Diagnostics.DebuggerStepThroughAttribute()]
2556 | [System.ComponentModel.DesignerCategoryAttribute("code")]
2557 | [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
2558 | public partial class savedqueryLayoutxmlGridRowCell {
2559 |
2560 | private string nameField;
2561 |
2562 | private string widthField;
2563 |
2564 | private string labelIdField;
2565 |
2566 | private string labelField;
2567 |
2568 | private string descField;
2569 |
2570 | private string ishiddenField;
2571 |
2572 | private string disableSortingField;
2573 |
2574 | private string disableMetaDataBindingField;
2575 |
2576 | private string cellTypeField;
2577 |
2578 | private string imageproviderwebresourceField;
2579 |
2580 | private string imageproviderfunctionnameField;
2581 |
2582 | ///
2583 | [System.Xml.Serialization.XmlAttributeAttribute()]
2584 | public string name {
2585 | get {
2586 | return this.nameField;
2587 | }
2588 | set {
2589 | this.nameField = value;
2590 | }
2591 | }
2592 |
2593 | ///
2594 | [System.Xml.Serialization.XmlAttributeAttribute(DataType="integer")]
2595 | public string width {
2596 | get {
2597 | return this.widthField;
2598 | }
2599 | set {
2600 | this.widthField = value;
2601 | }
2602 | }
2603 |
2604 | ///
2605 | [System.Xml.Serialization.XmlAttributeAttribute()]
2606 | public string LabelId {
2607 | get {
2608 | return this.labelIdField;
2609 | }
2610 | set {
2611 | this.labelIdField = value;
2612 | }
2613 | }
2614 |
2615 | ///
2616 | [System.Xml.Serialization.XmlAttributeAttribute()]
2617 | public string label {
2618 | get {
2619 | return this.labelField;
2620 | }
2621 | set {
2622 | this.labelField = value;
2623 | }
2624 | }
2625 |
2626 | ///
2627 | [System.Xml.Serialization.XmlAttributeAttribute()]
2628 | public string desc {
2629 | get {
2630 | return this.descField;
2631 | }
2632 | set {
2633 | this.descField = value;
2634 | }
2635 | }
2636 |
2637 | ///
2638 | [System.Xml.Serialization.XmlAttributeAttribute(DataType="integer")]
2639 | public string ishidden {
2640 | get {
2641 | return this.ishiddenField;
2642 | }
2643 | set {
2644 | this.ishiddenField = value;
2645 | }
2646 | }
2647 |
2648 | ///
2649 | [System.Xml.Serialization.XmlAttributeAttribute(DataType="integer")]
2650 | public string disableSorting {
2651 | get {
2652 | return this.disableSortingField;
2653 | }
2654 | set {
2655 | this.disableSortingField = value;
2656 | }
2657 | }
2658 |
2659 | ///
2660 | [System.Xml.Serialization.XmlAttributeAttribute(DataType="integer")]
2661 | public string disableMetaDataBinding {
2662 | get {
2663 | return this.disableMetaDataBindingField;
2664 | }
2665 | set {
2666 | this.disableMetaDataBindingField = value;
2667 | }
2668 | }
2669 |
2670 | ///
2671 | [System.Xml.Serialization.XmlAttributeAttribute()]
2672 | public string cellType {
2673 | get {
2674 | return this.cellTypeField;
2675 | }
2676 | set {
2677 | this.cellTypeField = value;
2678 | }
2679 | }
2680 |
2681 | ///
2682 | [System.Xml.Serialization.XmlAttributeAttribute()]
2683 | public string imageproviderwebresource {
2684 | get {
2685 | return this.imageproviderwebresourceField;
2686 | }
2687 | set {
2688 | this.imageproviderwebresourceField = value;
2689 | }
2690 | }
2691 |
2692 | ///
2693 | [System.Xml.Serialization.XmlAttributeAttribute()]
2694 | public string imageproviderfunctionname {
2695 | get {
2696 | return this.imageproviderfunctionnameField;
2697 | }
2698 | set {
2699 | this.imageproviderfunctionnameField = value;
2700 | }
2701 | }
2702 | }
2703 | }
2704 |
--------------------------------------------------------------------------------
/SqlVirtualEntityDataProvider/App_Packages/MarkMpn.Sql4Cds.Engine/IAttributeMetadataCache.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Xrm.Sdk.Metadata;
2 |
3 | namespace MarkMpn.Sql4Cds.Engine
4 | {
5 | ///
6 | /// Provides metadata for SQL <-> FetchXML conversion
7 | ///
8 | ///
9 | /// Use the for a standard implementation, or provide your own if you already
10 | /// have a source of metadata available to improve the performance of query conversion
11 | ///
12 | public interface IAttributeMetadataCache
13 | {
14 | ///
15 | /// Retrieves the metadata for an entity
16 | ///
17 | /// The logical name of the entity to get the metadata for
18 | /// The metadata for the requested entity
19 | EntityMetadata this[string name] { get; }
20 |
21 | ///
22 | /// Gets the metadata for an entity if it's already available in the cache
23 | ///
24 | /// The logical name of the entity to get the metadata for
25 | /// The cached view of the metadata for the requested entity
26 | /// true if the metadata was available in the cache, or false otherwise
27 | ///
28 | /// If the data is not available in the cache, this method will return false and the
29 | /// parameter will be set to null . It will also start a background task to load the metadata so it may be available
30 | /// on later attempts
31 | ///
32 | bool TryGetValue(string logicalName, out EntityMetadata metadata);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/SqlVirtualEntityDataProvider/App_Packages/MarkMpn.Sql4Cds.Engine/ScriptDom.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | ///
8 | /// Basic shims for ScriptDom classes required to build a SQL statement from FetchXml
9 | /// if the full ScriptDom assembly is not available
10 | ///
11 | namespace Microsoft.SqlServer.TransactSql.ScriptDom
12 | {
13 | class SelectStatement
14 | {
15 | public QueryExpression QueryExpression { get; set; }
16 |
17 | public WithCtesAndXmlNamespaces WithCtesAndXmlNamespaces { get; set; }
18 |
19 | public void Accept(TSqlFragmentVisitor visitor)
20 | {
21 | visitor.ExplicitVisit(this);
22 | QueryExpression?.Accept(visitor);
23 | WithCtesAndXmlNamespaces?.Accept(visitor);
24 | }
25 |
26 | public void ToString(StringBuilder buf, int indent)
27 | {
28 | WithCtesAndXmlNamespaces?.ToString(buf, indent);
29 | QueryExpression?.ToString(buf, indent);
30 | }
31 | }
32 |
33 | abstract class QueryExpression
34 | {
35 | public abstract void Accept(TSqlFragmentVisitor visitor);
36 |
37 | public abstract void ToString(StringBuilder buf, int indent);
38 | }
39 |
40 | class QuerySpecification : QueryExpression
41 | {
42 | public TopRowFilter TopRowFilter { get; set; }
43 |
44 | public UniqueRowFilter UniqueRowFilter { get; set; }
45 |
46 | public List SelectElements { get; } = new List();
47 |
48 | public FromClause FromClause { get; set; }
49 |
50 | public WhereClause WhereClause { get; set; }
51 |
52 | public GroupByClause GroupByClause { get; set; }
53 |
54 | public OrderByClause OrderByClause { get; set; }
55 |
56 | public OffsetClause OffsetClause { get; set; }
57 |
58 | public override void Accept(TSqlFragmentVisitor visitor)
59 | {
60 | visitor.ExplicitVisit(this);
61 | TopRowFilter?.Accept(visitor);
62 |
63 | foreach (var element in SelectElements)
64 | element.Accept(visitor);
65 |
66 | FromClause?.Accept(visitor);
67 | OffsetClause?.Accept(visitor);
68 | WhereClause?.Accept(visitor);
69 | GroupByClause?.Accept(visitor);
70 | OrderByClause?.Accept(visitor);
71 | }
72 |
73 | public override void ToString(StringBuilder buf, int indent)
74 | {
75 | buf.Append(' ', indent);
76 |
77 | var longestClause = "SELECT";
78 | if (GroupByClause != null)
79 | longestClause = "GROUP BY";
80 | else if (OrderByClause != null)
81 | longestClause = "ORDER BY";
82 |
83 | buf.Append("SELECT");
84 |
85 | buf.Append(' ', longestClause.Length - "SELECT".Length + 1);
86 |
87 | if (UniqueRowFilter == UniqueRowFilter.Distinct)
88 | buf.Append("DISTINCT ");
89 |
90 | TopRowFilter?.ToString(buf, indent);
91 |
92 | var selectIndent = Sql150ScriptGenerator.GetCurrentIndent(buf);
93 |
94 | for (var i = 0; i < SelectElements.Count; i++)
95 | {
96 | if (i > 0)
97 | {
98 | buf.Append(",\r\n");
99 | buf.Append(' ', selectIndent);
100 | }
101 |
102 | SelectElements[i].ToString(buf, selectIndent);
103 | }
104 |
105 | buf.Append("\r\n");
106 |
107 | FromClause?.ToString(buf, indent, longestClause.Length);
108 | WhereClause?.ToString(buf, indent, longestClause.Length);
109 | GroupByClause?.ToString(buf, indent, longestClause.Length);
110 | OrderByClause?.ToString(buf, indent, longestClause.Length);
111 | OffsetClause?.ToString(buf, indent, longestClause.Length);
112 | }
113 | }
114 |
115 | class BinaryQueryExpression : QueryExpression
116 | {
117 | public QueryExpression FirstQueryExpression { get; set; }
118 |
119 | public BinaryQueryExpressionType BinaryQueryExpressionType { get; set; }
120 |
121 | public bool All { get; set; }
122 |
123 | public QueryExpression SecondQueryExpression { get; set; }
124 |
125 | public override void Accept(TSqlFragmentVisitor visitor)
126 | {
127 | visitor.ExplicitVisit(this);
128 |
129 | FirstQueryExpression?.Accept(visitor);
130 | SecondQueryExpression?.Accept(visitor);
131 | }
132 |
133 | public override void ToString(StringBuilder buf, int indent)
134 | {
135 | FirstQueryExpression.ToString(buf, indent);
136 |
137 | switch (BinaryQueryExpressionType)
138 | {
139 | case BinaryQueryExpressionType.Union:
140 | buf.Append("\r\n");
141 | buf.Append(' ', indent);
142 | buf.Append("UNION");
143 | break;
144 |
145 | default:
146 | throw new NotSupportedException();
147 | }
148 |
149 | if (All)
150 | buf.Append(" ALL");
151 |
152 | buf.Append("\r\n");
153 |
154 | SecondQueryExpression.ToString(buf, indent);
155 | }
156 | }
157 |
158 | enum BinaryQueryExpressionType
159 | {
160 | Union
161 | }
162 |
163 | class TopRowFilter
164 | {
165 | public Expression Expression { get; set; }
166 |
167 | public void Accept(TSqlFragmentVisitor visitor)
168 | {
169 | visitor.ExplicitVisit(this);
170 | Expression?.Accept(visitor);
171 | }
172 |
173 | public void ToString(StringBuilder buf, int indent)
174 | {
175 | buf.Append("TOP ");
176 | Expression?.ToString(buf, indent);
177 | buf.Append(" ");
178 | }
179 | }
180 |
181 | abstract class Expression
182 | {
183 | public abstract void Accept(TSqlFragmentVisitor visitor);
184 |
185 | public abstract void ToString(StringBuilder buf, int indent);
186 | }
187 |
188 | abstract class Literal : ScalarExpression
189 | {
190 | public string Value { get; set; }
191 |
192 | public override void ToString(StringBuilder buf, int indent)
193 | {
194 | buf.Append(Value);
195 | }
196 | }
197 |
198 | class IntegerLiteral : Literal
199 | {
200 | public override void Accept(TSqlFragmentVisitor visitor)
201 | {
202 | visitor.ExplicitVisit(this);
203 | }
204 | }
205 |
206 | class StringLiteral : Literal
207 | {
208 | public override void Accept(TSqlFragmentVisitor visitor)
209 | {
210 | visitor.ExplicitVisit(this);
211 | }
212 |
213 | public override void ToString(StringBuilder buf, int indent)
214 | {
215 | buf.Append("'");
216 | buf.Append(Value.Replace("'", "''"));
217 | buf.Append("'");
218 | }
219 | }
220 |
221 | class BinaryLiteral : Literal
222 | {
223 | public override void Accept(TSqlFragmentVisitor visitor)
224 | {
225 | visitor.ExplicitVisit(this);
226 | }
227 | }
228 |
229 | class NumericLiteral : Literal
230 | {
231 | public override void Accept(TSqlFragmentVisitor visitor)
232 | {
233 | visitor.ExplicitVisit(this);
234 | }
235 | }
236 |
237 | class MoneyLiteral : Literal
238 | {
239 | public override void Accept(TSqlFragmentVisitor visitor)
240 | {
241 | visitor.ExplicitVisit(this);
242 | }
243 | }
244 |
245 | class VariableReference : ScalarExpression
246 | {
247 | public string Name { get; set; }
248 |
249 | public override void Accept(TSqlFragmentVisitor visitor)
250 | {
251 | visitor.ExplicitVisit(this);
252 | }
253 |
254 | public override void ToString(StringBuilder buf, int indent)
255 | {
256 | buf.Append(Name);
257 | }
258 | }
259 |
260 | enum UniqueRowFilter
261 | {
262 | None,
263 | Distinct
264 | }
265 |
266 | class FromClause
267 | {
268 | public List TableReferences { get; } = new List();
269 |
270 | public void Accept(TSqlFragmentVisitor visitor)
271 | {
272 | visitor.ExplicitVisit(this);
273 |
274 | foreach (var table in TableReferences)
275 | table.Accept(visitor);
276 | }
277 |
278 | public void ToString(StringBuilder buf, int indent, int longestClauseLength)
279 | {
280 | buf.Append(' ', indent);
281 | buf.Append("FROM");
282 | buf.Append(' ', longestClauseLength - "FROM".Length + 1);
283 |
284 | for (var i = 0; i < TableReferences.Count; i++)
285 | {
286 | if (i > 0)
287 | {
288 | buf.Append(",\r\n");
289 | buf.Append(' ', indent + longestClauseLength + 1);
290 | }
291 |
292 | TableReferences[i].ToString(buf, indent + longestClauseLength + 1);
293 | }
294 |
295 | buf.Append("\r\n");
296 | }
297 | }
298 |
299 | abstract class TableReference
300 | {
301 | public abstract void Accept(TSqlFragmentVisitor visitor);
302 |
303 | public abstract void ToString(StringBuilder buf, int indent);
304 | }
305 |
306 | class NamedTableReference : TableReference
307 | {
308 | public SchemaObjectName SchemaObject { get; set; }
309 |
310 | public List TableHints { get; } = new List();
311 |
312 | public Identifier Alias { get; set; }
313 |
314 | public override void Accept(TSqlFragmentVisitor visitor)
315 | {
316 | visitor.ExplicitVisit(this);
317 |
318 | SchemaObject?.Accept(visitor);
319 |
320 | foreach (var hint in TableHints)
321 | hint.Accept(visitor);
322 |
323 | Alias?.Accept(visitor);
324 | }
325 |
326 | public override void ToString(StringBuilder buf, int indent)
327 | {
328 | SchemaObject.ToString(buf, indent);
329 |
330 | if (Alias != null)
331 | {
332 | buf.Append(" AS ");
333 | Alias.ToString(buf);
334 | }
335 |
336 | if (TableHints.Count > 0)
337 | {
338 | buf.Append(" WITH (");
339 |
340 | for (var i = 0; i < TableHints.Count; i++)
341 | {
342 | if (i > 0)
343 | buf.Append(", ");
344 |
345 | TableHints[i].ToString(buf);
346 | }
347 |
348 | buf.Append(") ");
349 | }
350 | }
351 | }
352 |
353 | class QualifiedJoin : TableReference
354 | {
355 | public TableReference FirstTableReference { get; set; }
356 |
357 | public TableReference SecondTableReference { get; set; }
358 |
359 | public QualifiedJoinType QualifiedJoinType { get; set; }
360 |
361 | public BooleanExpression SearchCondition { get; set; }
362 |
363 | public override void Accept(TSqlFragmentVisitor visitor)
364 | {
365 | visitor.ExplicitVisit(this);
366 |
367 | FirstTableReference?.Accept(visitor);
368 | SecondTableReference?.Accept(visitor);
369 | SearchCondition?.Accept(visitor);
370 | }
371 |
372 | public override void ToString(StringBuilder buf, int indent)
373 | {
374 | FirstTableReference.ToString(buf, indent);
375 |
376 | buf.Append("\r\n");
377 | buf.Append(' ', indent);
378 |
379 | if (QualifiedJoinType == QualifiedJoinType.Inner)
380 | buf.Append("INNER JOIN");
381 | else
382 | buf.Append("LEFT OUTER JOIN");
383 |
384 | buf.Append("\r\n");
385 | buf.Append(' ', indent);
386 |
387 | SecondTableReference.ToString(buf, indent);
388 |
389 | buf.Append("\r\n");
390 | buf.Append(' ', indent);
391 |
392 | buf.Append("ON ");
393 |
394 | SearchCondition.ToString(buf, indent + 3);
395 | }
396 | }
397 |
398 | enum QualifiedJoinType
399 | {
400 | Inner,
401 | LeftOuter
402 | }
403 |
404 | class SchemaObjectName : MultiPartIdentifier
405 | {
406 | public override void Accept(TSqlFragmentVisitor visitor)
407 | {
408 | visitor.ExplicitVisit(this);
409 |
410 | foreach (var identifier in Identifiers)
411 | identifier.Accept(visitor);
412 | }
413 | }
414 |
415 | class Identifier
416 | {
417 | public string Value { get; set; }
418 |
419 | public QuoteType QuoteType { get; set; }
420 |
421 | public void Accept(TSqlFragmentVisitor visitor)
422 | {
423 | visitor.ExplicitVisit(this);
424 | }
425 |
426 | public void ToString(StringBuilder buf)
427 | {
428 | if (QuoteType == QuoteType.SquareBracket)
429 | buf.Append("[");
430 |
431 | buf.Append(Value);
432 |
433 | if (QuoteType == QuoteType.SquareBracket)
434 | buf.Append("]");
435 | }
436 | }
437 |
438 | enum QuoteType
439 | {
440 | SquareBracket,
441 | NotQuoted
442 | }
443 |
444 | class MultiPartIdentifier
445 | {
446 | public List Identifiers { get; } = new List();
447 |
448 | public virtual void Accept(TSqlFragmentVisitor visitor)
449 | {
450 | visitor.ExplicitVisit(this);
451 |
452 | foreach (var identifier in Identifiers)
453 | identifier.Accept(visitor);
454 | }
455 |
456 | public void ToString(StringBuilder buf, int indent)
457 | {
458 | for (var i = 0; i < Identifiers.Count; i++)
459 | {
460 | if (i > 0)
461 | buf.Append(".");
462 |
463 | Identifiers[i].ToString(buf);
464 | }
465 | }
466 | }
467 |
468 | class TableHint
469 | {
470 | public TableHintKind HintKind { get; set; }
471 |
472 | public void Accept(TSqlFragmentVisitor visitor)
473 | {
474 | visitor.ExplicitVisit(this);
475 | }
476 |
477 | public void ToString(StringBuilder buf)
478 | {
479 | switch (HintKind)
480 | {
481 | case TableHintKind.NoLock:
482 | buf.Append("NOLOCK");
483 | break;
484 |
485 | default:
486 | throw new NotImplementedException();
487 | }
488 | }
489 | }
490 |
491 | enum TableHintKind
492 | {
493 | None,
494 | NoLock
495 | }
496 |
497 | class OffsetClause
498 | {
499 | public Literal OffsetExpression { get; set; }
500 |
501 | public Literal FetchExpression { get; set; }
502 |
503 | public void Accept(TSqlFragmentVisitor visitor)
504 | {
505 | visitor.ExplicitVisit(this);
506 |
507 | OffsetExpression?.Accept(visitor);
508 | FetchExpression?.Accept(visitor);
509 | }
510 |
511 | public void ToString(StringBuilder buf, int indent, int longestClauseLength)
512 | {
513 | buf.Append(' ', indent);
514 | buf.Append("OFFSET");
515 | buf.Append(' ', longestClauseLength - "OFFSET".Length + 1);
516 | OffsetExpression.ToString(buf, indent);
517 | buf.Append(" ROWS FETCH NEXT ");
518 | FetchExpression.ToString(buf, indent);
519 | buf.Append(" ROWS ONLY\r\n");
520 | }
521 | }
522 |
523 | class WhereClause
524 | {
525 | public BooleanExpression SearchCondition { get; set; }
526 |
527 | public void Accept(TSqlFragmentVisitor visitor)
528 | {
529 | visitor.ExplicitVisit(this);
530 |
531 | SearchCondition?.Accept(visitor);
532 | }
533 |
534 | public void ToString(StringBuilder buf, int indent, int longestClauseLength)
535 | {
536 | buf.Append(' ', indent);
537 | buf.Append("WHERE");
538 | buf.Append(' ', longestClauseLength - "WHERE".Length + 1);
539 | SearchCondition.ToString(buf, indent + longestClauseLength + 1);
540 | buf.Append("\r\n");
541 | }
542 | }
543 |
544 | abstract class SelectElement
545 | {
546 | public abstract void Accept(TSqlFragmentVisitor visitor);
547 |
548 | public abstract void ToString(StringBuilder buf, int indent);
549 | }
550 |
551 | class SelectStarExpression : SelectElement
552 | {
553 | public MultiPartIdentifier Qualifier { get; set; }
554 |
555 | public override void Accept(TSqlFragmentVisitor visitor)
556 | {
557 | visitor.ExplicitVisit(this);
558 |
559 | Qualifier?.Accept(visitor);
560 | }
561 |
562 | public override void ToString(StringBuilder buf, int indent)
563 | {
564 | if (Qualifier != null)
565 | {
566 | Qualifier.ToString(buf, indent);
567 | buf.Append(".");
568 | }
569 |
570 | buf.Append("*");
571 | }
572 | }
573 |
574 | class SelectScalarExpression : SelectElement
575 | {
576 | public ScalarExpression Expression { get; set; }
577 |
578 | public IdentifierOrValueExpression ColumnName { get; set; }
579 |
580 | public override void Accept(TSqlFragmentVisitor visitor)
581 | {
582 | visitor.ExplicitVisit(this);
583 |
584 | Expression?.Accept(visitor);
585 | ColumnName?.Accept(visitor);
586 | }
587 |
588 | public override void ToString(StringBuilder buf, int indent)
589 | {
590 | Expression.ToString(buf, indent);
591 |
592 | if (ColumnName != null)
593 | {
594 | buf.Append(" AS ");
595 | ColumnName.ToString(buf);
596 | }
597 | }
598 | }
599 |
600 | abstract class ScalarExpression : Expression
601 | {
602 | }
603 |
604 | class ColumnReferenceExpression : ScalarExpression
605 | {
606 | public MultiPartIdentifier MultiPartIdentifier { get; set; }
607 |
608 | public override void Accept(TSqlFragmentVisitor visitor)
609 | {
610 | visitor.ExplicitVisit(this);
611 |
612 | MultiPartIdentifier?.Accept(visitor);
613 | }
614 |
615 | public override void ToString(StringBuilder buf, int indent)
616 | {
617 | MultiPartIdentifier.ToString(buf, indent);
618 | }
619 | }
620 |
621 | class FunctionCall : ScalarExpression
622 | {
623 | public Identifier FunctionName { get; set; }
624 |
625 | public List Parameters { get; } = new List();
626 |
627 | public UniqueRowFilter UniqueRowFilter { get; set; }
628 |
629 | public override void Accept(TSqlFragmentVisitor visitor)
630 | {
631 | visitor.ExplicitVisit(this);
632 |
633 | FunctionName?.Accept(visitor);
634 |
635 | foreach (var param in Parameters)
636 | param.Accept(visitor);
637 | }
638 |
639 | public override void ToString(StringBuilder buf, int indent)
640 | {
641 | FunctionName.ToString(buf);
642 | buf.Append("(");
643 |
644 | if (UniqueRowFilter == UniqueRowFilter.Distinct)
645 | buf.Append("DISTINCT ");
646 |
647 | for (var i = 0; i < Parameters.Count; i++)
648 | {
649 | if (i > 0)
650 | buf.Append(", ");
651 |
652 | Parameters[i].ToString(buf, indent);
653 | }
654 |
655 | buf.Append(")");
656 | }
657 | }
658 |
659 | class ConvertCall : ScalarExpression
660 | {
661 | public SqlDataTypeReference DataType { get; set; }
662 |
663 | public ScalarExpression Parameter { get; set; }
664 |
665 | public override void Accept(TSqlFragmentVisitor visitor)
666 | {
667 | visitor.ExplicitVisit(this);
668 |
669 | DataType?.Accept(visitor);
670 | Parameter?.Accept(visitor);
671 | }
672 |
673 | public override void ToString(StringBuilder buf, int indent)
674 | {
675 | buf.Append("CONVERT(");
676 | DataType.ToString(buf, indent);
677 | buf.Append(", ");
678 | Parameter.ToString(buf, indent);
679 | buf.Append(")");
680 | }
681 | }
682 |
683 | class SqlDataTypeReference
684 | {
685 | public SchemaObjectName Name { get; set; }
686 |
687 | public void Accept(TSqlFragmentVisitor visitor)
688 | {
689 | visitor.ExplicitVisit(this);
690 |
691 | Name?.Accept(visitor);
692 | }
693 |
694 | public void ToString(StringBuilder buf, int indent)
695 | {
696 | Name.ToString(buf, indent);
697 | }
698 | }
699 |
700 | class IdentifierOrValueExpression
701 | {
702 | public Identifier Identifier { get; set; }
703 |
704 | public void Accept(TSqlFragmentVisitor visitor)
705 | {
706 | visitor.ExplicitVisit(this);
707 |
708 | Identifier?.Accept(visitor);
709 | }
710 |
711 | public void ToString(StringBuilder buf)
712 | {
713 | Identifier.ToString(buf);
714 | }
715 | }
716 |
717 | class GroupByClause
718 | {
719 | public List GroupingSpecifications { get; } = new List();
720 |
721 | public void Accept(TSqlFragmentVisitor visitor)
722 | {
723 | visitor.ExplicitVisit(this);
724 |
725 | foreach (var group in GroupingSpecifications)
726 | group.Accept(visitor);
727 | }
728 |
729 | public void ToString(StringBuilder buf, int indent, int longestClauseLength)
730 | {
731 | buf.Append(' ', indent);
732 | buf.Append("GROUP BY");
733 | buf.Append(' ', longestClauseLength - "GROUP BY".Length + 1);
734 |
735 | for (var i = 0; i < GroupingSpecifications.Count; i++)
736 | {
737 | if (i > 0)
738 | {
739 | buf.Append(",\r\n");
740 | buf.Append(' ', indent + longestClauseLength + 1);
741 | }
742 |
743 | GroupingSpecifications[i].ToString(buf, indent);
744 | }
745 |
746 | buf.Append("\r\n");
747 | }
748 | }
749 |
750 | class ExpressionGroupingSpecification
751 | {
752 | public ScalarExpression Expression { get; set; }
753 |
754 | public void Accept(TSqlFragmentVisitor visitor)
755 | {
756 | visitor.ExplicitVisit(this);
757 |
758 | Expression?.Accept(visitor);
759 | }
760 |
761 | public void ToString(StringBuilder buf, int indent)
762 | {
763 | Expression.ToString(buf, indent);
764 | }
765 | }
766 |
767 | abstract class BooleanExpression : Expression
768 | {
769 | }
770 |
771 | class BooleanComparisonExpression : BooleanExpression
772 | {
773 | public Expression FirstExpression { get; set; }
774 | public Expression SecondExpression { get; set; }
775 | public BooleanComparisonType ComparisonType { get; set; }
776 |
777 | public override void Accept(TSqlFragmentVisitor visitor)
778 | {
779 | visitor.ExplicitVisit(this);
780 |
781 | FirstExpression?.Accept(visitor);
782 | SecondExpression?.Accept(visitor);
783 | }
784 |
785 | public override void ToString(StringBuilder buf, int indent)
786 | {
787 | FirstExpression.ToString(buf, indent);
788 |
789 | switch (ComparisonType)
790 | {
791 | case BooleanComparisonType.Equals:
792 | buf.Append(" = ");
793 | break;
794 |
795 | case BooleanComparisonType.GreaterThan:
796 | buf.Append(" > ");
797 | break;
798 |
799 | case BooleanComparisonType.GreaterThanOrEqualTo:
800 | buf.Append(" >= ");
801 | break;
802 |
803 | case BooleanComparisonType.LessThan:
804 | buf.Append(" < ");
805 | break;
806 |
807 | case BooleanComparisonType.LessThanOrEqualTo:
808 | buf.Append(" <= ");
809 | break;
810 |
811 | case BooleanComparisonType.NotEqualToBrackets:
812 | buf.Append(" <> ");
813 | break;
814 |
815 | default:
816 | throw new NotImplementedException();
817 | }
818 |
819 | SecondExpression.ToString(buf, indent);
820 | }
821 | }
822 |
823 | enum BooleanComparisonType
824 | {
825 | Equals,
826 | GreaterThanOrEqualTo,
827 | GreaterThan,
828 | LessThanOrEqualTo,
829 | LessThan,
830 | NotEqualToBrackets
831 | }
832 |
833 | class BooleanParenthesisExpression : BooleanExpression
834 | {
835 | public BooleanExpression Expression { get; set; }
836 |
837 | public override void Accept(TSqlFragmentVisitor visitor)
838 | {
839 | visitor.ExplicitVisit(this);
840 |
841 | Expression?.Accept(visitor);
842 | }
843 |
844 | public override void ToString(StringBuilder buf, int indent)
845 | {
846 | buf.Append("(");
847 | Expression.ToString(buf, Sql150ScriptGenerator.GetCurrentIndent(buf));
848 | buf.Append(")");
849 | }
850 | }
851 |
852 | class BooleanBinaryExpression : BooleanExpression
853 | {
854 | public BooleanExpression FirstExpression { get; set; }
855 | public BooleanExpression SecondExpression { get; set; }
856 | public BooleanBinaryExpressionType BinaryExpressionType { get; set; }
857 |
858 | public override void Accept(TSqlFragmentVisitor visitor)
859 | {
860 | visitor.ExplicitVisit(this);
861 |
862 | FirstExpression?.Accept(visitor);
863 | SecondExpression?.Accept(visitor);
864 | }
865 |
866 | public override void ToString(StringBuilder buf, int indent)
867 | {
868 | FirstExpression.ToString(buf, indent);
869 |
870 | buf.Append("\r\n");
871 | buf.Append(' ', indent);
872 |
873 | switch (BinaryExpressionType)
874 | {
875 | case BooleanBinaryExpressionType.And:
876 | buf.Append("AND ");
877 | break;
878 |
879 | case BooleanBinaryExpressionType.Or:
880 | buf.Append("OR ");
881 | break;
882 |
883 | default:
884 | throw new NotImplementedException();
885 | }
886 |
887 | SecondExpression.ToString(buf, indent);
888 | }
889 | }
890 |
891 | enum BooleanBinaryExpressionType
892 | {
893 | And,
894 | Or
895 | }
896 |
897 | class LikePredicate : BooleanExpression
898 | {
899 | public Expression FirstExpression { get; set; }
900 | public Expression SecondExpression { get; set; }
901 | public bool NotDefined { get; set; }
902 |
903 | public override void Accept(TSqlFragmentVisitor visitor)
904 | {
905 | visitor.ExplicitVisit(this);
906 |
907 | FirstExpression?.Accept(visitor);
908 | SecondExpression?.Accept(visitor);
909 | }
910 |
911 | public override void ToString(StringBuilder buf, int indent)
912 | {
913 | FirstExpression.ToString(buf, indent);
914 |
915 | if (NotDefined)
916 | buf.Append(" NOT LIKE ");
917 | else
918 | buf.Append(" LIKE ");
919 |
920 | SecondExpression.ToString(buf, indent);
921 | }
922 | }
923 |
924 | class BooleanTernaryExpression : BooleanExpression
925 | {
926 | public Expression FirstExpression { get; set; }
927 | public Expression SecondExpression { get; set; }
928 | public Expression ThirdExpression { get; set; }
929 | public BooleanTernaryExpressionType TernaryExpressionType { get; set; }
930 |
931 | public override void Accept(TSqlFragmentVisitor visitor)
932 | {
933 | visitor.ExplicitVisit(this);
934 |
935 | FirstExpression?.Accept(visitor);
936 | SecondExpression?.Accept(visitor);
937 | ThirdExpression?.Accept(visitor);
938 | }
939 |
940 | public override void ToString(StringBuilder buf, int indent)
941 | {
942 | FirstExpression.ToString(buf, indent);
943 |
944 | switch (TernaryExpressionType)
945 | {
946 | case BooleanTernaryExpressionType.Between:
947 | buf.Append(" BETWEEN ");
948 | break;
949 |
950 | case BooleanTernaryExpressionType.NotBetween:
951 | buf.Append(" NOT BETWEEN ");
952 | break;
953 |
954 | default:
955 | throw new NotImplementedException();
956 | }
957 |
958 | SecondExpression.ToString(buf, indent);
959 | buf.Append(" AND ");
960 | ThirdExpression.ToString(buf, indent);
961 | }
962 | }
963 |
964 | enum BooleanTernaryExpressionType
965 | {
966 | Between,
967 | NotBetween
968 | }
969 |
970 | class InPredicate : BooleanExpression
971 | {
972 | public Expression Expression { get; set; }
973 | public bool NotDefined { get; set; }
974 | public List Values { get; } = new List();
975 | public ScalarSubquery Subquery { get; set; }
976 |
977 | public override void Accept(TSqlFragmentVisitor visitor)
978 | {
979 | visitor.ExplicitVisit(this);
980 |
981 | Expression?.Accept(visitor);
982 |
983 | foreach (var value in Values)
984 | value.Accept(visitor);
985 |
986 | Subquery?.Accept(visitor);
987 | }
988 |
989 | public override void ToString(StringBuilder buf, int indent)
990 | {
991 | Expression.ToString(buf, indent);
992 |
993 | if (NotDefined)
994 | buf.Append(" NOT IN (");
995 | else
996 | buf.Append(" IN (");
997 |
998 | if (Subquery != null)
999 | {
1000 | Subquery.ToString(buf, Sql150ScriptGenerator.GetCurrentIndent(buf));
1001 | }
1002 | else
1003 | {
1004 | for (var i = 0; i < Values.Count; i++)
1005 | {
1006 | if (i > 0)
1007 | buf.Append(", ");
1008 |
1009 | Values[i].ToString(buf, indent);
1010 | }
1011 | }
1012 |
1013 | buf.Append(")");
1014 | }
1015 | }
1016 |
1017 | class FullTextPredicate : BooleanExpression
1018 | {
1019 | public List Columns { get; } = new List();
1020 |
1021 | public FullTextFunctionType FullTextFunctionType { get; set; }
1022 |
1023 | public StringLiteral Value { get; set; }
1024 |
1025 | public override void Accept(TSqlFragmentVisitor visitor)
1026 | {
1027 | visitor.ExplicitVisit(this);
1028 |
1029 | foreach (var col in Columns)
1030 | col.Accept(visitor);
1031 |
1032 | Value?.Accept(visitor);
1033 | }
1034 |
1035 | public override void ToString(StringBuilder buf, int indent)
1036 | {
1037 | switch (FullTextFunctionType)
1038 | {
1039 | case FullTextFunctionType.Contains:
1040 | buf.Append("CONTAINS ");
1041 | break;
1042 |
1043 | default:
1044 | throw new NotSupportedException();
1045 | }
1046 |
1047 | buf.Append("((");
1048 |
1049 | foreach (var col in Columns)
1050 | col.ToString(buf, indent);
1051 |
1052 | buf.Append("), ");
1053 | Value.ToString(buf, indent);
1054 | buf.Append(")");
1055 | }
1056 | }
1057 |
1058 | enum FullTextFunctionType
1059 | {
1060 | Contains
1061 | }
1062 |
1063 | class BooleanNotExpression : BooleanExpression
1064 | {
1065 | public BooleanExpression Expression { get; set; }
1066 |
1067 | public override void Accept(TSqlFragmentVisitor visitor)
1068 | {
1069 | visitor.ExplicitVisit(this);
1070 |
1071 | Expression?.Accept(visitor);
1072 | }
1073 |
1074 | public override void ToString(StringBuilder buf, int indent)
1075 | {
1076 | buf.Append("NOT ");
1077 | Expression.ToString(buf, indent);
1078 | }
1079 | }
1080 |
1081 | class BinaryExpression : ScalarExpression
1082 | {
1083 | public ScalarExpression FirstExpression { get; set; }
1084 |
1085 | public BinaryExpressionType BinaryExpressionType { get; set; }
1086 |
1087 | public ScalarExpression SecondExpression { get; set; }
1088 |
1089 | public override void Accept(TSqlFragmentVisitor visitor)
1090 | {
1091 | visitor.ExplicitVisit(this);
1092 |
1093 | FirstExpression?.Accept(visitor);
1094 | SecondExpression?.Accept(visitor);
1095 | }
1096 |
1097 | public override void ToString(StringBuilder buf, int indent)
1098 | {
1099 | FirstExpression.ToString(buf, indent);
1100 |
1101 | switch (BinaryExpressionType)
1102 | {
1103 | case BinaryExpressionType.Add:
1104 | buf.Append(" + ");
1105 | break;
1106 |
1107 | default:
1108 | throw new NotSupportedException();
1109 | }
1110 |
1111 | SecondExpression.ToString(buf, indent);
1112 | }
1113 | }
1114 |
1115 | enum BinaryExpressionType
1116 | {
1117 | Add
1118 | }
1119 |
1120 | class ScalarSubquery
1121 | {
1122 | public QueryExpression QueryExpression { get; set; }
1123 |
1124 | public void Accept(TSqlFragmentVisitor visitor)
1125 | {
1126 | visitor.ExplicitVisit(this);
1127 |
1128 | QueryExpression?.Accept(visitor);
1129 | }
1130 |
1131 | public void ToString(StringBuilder buf, int indent)
1132 | {
1133 | QueryExpression.ToString(buf, indent);
1134 | }
1135 | }
1136 |
1137 | class BooleanIsNullExpression : BooleanExpression
1138 | {
1139 | public Expression Expression { get; set; }
1140 | public bool IsNot { get; set; }
1141 |
1142 | public override void Accept(TSqlFragmentVisitor visitor)
1143 | {
1144 | visitor.ExplicitVisit(this);
1145 |
1146 | Expression?.Accept(visitor);
1147 | }
1148 |
1149 | public override void ToString(StringBuilder buf, int indent)
1150 | {
1151 | Expression.ToString(buf, indent);
1152 |
1153 | if (IsNot)
1154 | buf.Append(" IS NOT NULL");
1155 | else
1156 | buf.Append(" IS NULL");
1157 | }
1158 | }
1159 |
1160 | class OrderByClause
1161 | {
1162 | public List OrderByElements { get; } = new List();
1163 |
1164 | public void Accept(TSqlFragmentVisitor visitor)
1165 | {
1166 | visitor.ExplicitVisit(this);
1167 |
1168 | foreach (var order in OrderByElements)
1169 | order.Accept(visitor);
1170 | }
1171 |
1172 | public void ToString(StringBuilder buf, int indent, int longestClauseLength)
1173 | {
1174 | buf.Append(' ', indent);
1175 | buf.Append("ORDER BY");
1176 | buf.Append(' ', longestClauseLength - "ORDER BY".Length + 1);
1177 |
1178 | for (var i = 0; i < OrderByElements.Count; i++)
1179 | {
1180 | if (i > 0)
1181 | {
1182 | buf.Append(",\r\n");
1183 | buf.Append(' ', indent + longestClauseLength + 1);
1184 | }
1185 |
1186 | OrderByElements[i].ToString(buf, indent + longestClauseLength + 1);
1187 | }
1188 |
1189 | buf.Append("\r\n");
1190 | }
1191 | }
1192 |
1193 | class ExpressionWithSortOrder
1194 | {
1195 | public Expression Expression { get; set; }
1196 |
1197 | public SortOrder SortOrder { get; set; }
1198 |
1199 | public void Accept(TSqlFragmentVisitor visitor)
1200 | {
1201 | visitor.ExplicitVisit(this);
1202 |
1203 | Expression?.Accept(visitor);
1204 | }
1205 |
1206 | public void ToString(StringBuilder buf, int indent)
1207 | {
1208 | Expression.ToString(buf, indent);
1209 |
1210 | switch (SortOrder)
1211 | {
1212 | case SortOrder.Ascending:
1213 | buf.Append(" ASC");
1214 | break;
1215 |
1216 | case SortOrder.Descending:
1217 | buf.Append(" DESC");
1218 | break;
1219 |
1220 | default:
1221 | throw new NotImplementedException();
1222 | }
1223 | }
1224 | }
1225 |
1226 | class WithCtesAndXmlNamespaces
1227 | {
1228 | public List CommonTableExpressions { get; } = new List();
1229 |
1230 | public void Accept(TSqlFragmentVisitor visitor)
1231 | {
1232 | visitor.ExplicitVisit(this);
1233 |
1234 | foreach (var cte in CommonTableExpressions)
1235 | cte.Accept(visitor);
1236 | }
1237 |
1238 | public void ToString(StringBuilder buf, int indent)
1239 | {
1240 | buf.Append(' ', indent);
1241 | buf.Append("WITH ");
1242 |
1243 | for (var i = 0; i < CommonTableExpressions.Count; i++)
1244 | {
1245 | if (i > 0)
1246 | {
1247 | buf.Append(",\r\n");
1248 | buf.Append(' ', indent + 5);
1249 | }
1250 |
1251 | CommonTableExpressions[i].ToString(buf, indent + 5);
1252 | }
1253 |
1254 | buf.Append(" ");
1255 | }
1256 | }
1257 |
1258 | class CommonTableExpression
1259 | {
1260 | public Identifier ExpressionName { get; set; }
1261 |
1262 | public List Columns { get; } = new List();
1263 |
1264 | public QueryExpression QueryExpression { get; set; }
1265 |
1266 | public void Accept(TSqlFragmentVisitor visitor)
1267 | {
1268 | visitor.ExplicitVisit(this);
1269 |
1270 | ExpressionName?.Accept(visitor);
1271 |
1272 | foreach (var col in Columns)
1273 | col.Accept(visitor);
1274 |
1275 | QueryExpression?.Accept(visitor);
1276 | }
1277 |
1278 | public void ToString(StringBuilder buf, int indent)
1279 | {
1280 | ExpressionName.ToString(buf);
1281 | buf.Append("(");
1282 |
1283 | for (var i = 0; i < Columns.Count; i++)
1284 | {
1285 | if (i > 0)
1286 | buf.Append(", ");
1287 |
1288 | Columns[i].ToString(buf);
1289 | }
1290 |
1291 | buf.Append(") AS (\r\n");
1292 | QueryExpression.ToString(buf, indent);
1293 | buf.Append(")");
1294 | }
1295 | }
1296 |
1297 | enum SortOrder
1298 | {
1299 | Ascending,
1300 | Descending
1301 | }
1302 |
1303 | class TSqlFragmentVisitor
1304 | {
1305 | public virtual void ExplicitVisit(SelectStatement node)
1306 | {
1307 | }
1308 |
1309 | public virtual void ExplicitVisit(MultiPartIdentifier node)
1310 | {
1311 | }
1312 |
1313 | public virtual void ExplicitVisit(Identifier node)
1314 | {
1315 | }
1316 |
1317 | public virtual void ExplicitVisit(QuerySpecification querySpecification)
1318 | {
1319 | }
1320 |
1321 | public virtual void ExplicitVisit(TopRowFilter topRowFilter)
1322 | {
1323 | }
1324 |
1325 | public virtual void ExplicitVisit(IntegerLiteral integerLiteral)
1326 | {
1327 | }
1328 |
1329 | public virtual void ExplicitVisit(StringLiteral stringLiteral)
1330 | {
1331 | }
1332 |
1333 | public virtual void ExplicitVisit(BinaryLiteral binaryLiteral)
1334 | {
1335 | }
1336 |
1337 | public virtual void ExplicitVisit(NumericLiteral numericLiteral)
1338 | {
1339 | }
1340 |
1341 | public virtual void ExplicitVisit(MoneyLiteral moneyLiteral)
1342 | {
1343 | }
1344 |
1345 | public virtual void ExplicitVisit(FromClause fromClause)
1346 | {
1347 | }
1348 |
1349 | public virtual void ExplicitVisit(NamedTableReference namedTableReference)
1350 | {
1351 | }
1352 |
1353 | public virtual void ExplicitVisit(QualifiedJoin qualifiedJoin)
1354 | {
1355 | }
1356 |
1357 | public virtual void ExplicitVisit(SchemaObjectName schemaObjectName)
1358 | {
1359 | }
1360 |
1361 | public virtual void ExplicitVisit(OffsetClause offsetClause)
1362 | {
1363 | }
1364 |
1365 | public virtual void ExplicitVisit(WhereClause whereClause)
1366 | {
1367 | }
1368 |
1369 | public virtual void ExplicitVisit(SelectStarExpression selectStarExpression)
1370 | {
1371 | }
1372 |
1373 | public virtual void ExplicitVisit(SelectScalarExpression selectScalarExpression)
1374 | {
1375 | }
1376 |
1377 | public virtual void ExplicitVisit(ColumnReferenceExpression columnReferenceExpression)
1378 | {
1379 | }
1380 |
1381 | public virtual void ExplicitVisit(FunctionCall functionCall)
1382 | {
1383 | }
1384 |
1385 | public virtual void ExplicitVisit(IdentifierOrValueExpression identifierOrValueExpression)
1386 | {
1387 | }
1388 |
1389 | public virtual void ExplicitVisit(GroupByClause groupByClause)
1390 | {
1391 | }
1392 |
1393 | public virtual void ExplicitVisit(ExpressionGroupingSpecification expressionGroupingSpecification)
1394 | {
1395 | }
1396 |
1397 | public virtual void ExplicitVisit(BooleanComparisonExpression booleanComparisonExpression)
1398 | {
1399 | }
1400 |
1401 | public virtual void ExplicitVisit(BooleanBinaryExpression booleanBinaryExpression)
1402 | {
1403 | }
1404 |
1405 | public virtual void ExplicitVisit(LikePredicate likePredicate)
1406 | {
1407 | }
1408 |
1409 | public virtual void ExplicitVisit(BooleanTernaryExpression booleanTernaryExpression)
1410 | {
1411 | }
1412 |
1413 | public virtual void ExplicitVisit(InPredicate inPredicate)
1414 | {
1415 | }
1416 |
1417 | public virtual void ExplicitVisit(BooleanIsNullExpression booleanIsNullExpression)
1418 | {
1419 | }
1420 |
1421 | public virtual void ExplicitVisit(OrderByClause orderByClause)
1422 | {
1423 | }
1424 |
1425 | public virtual void ExplicitVisit(ExpressionWithSortOrder expressionWithSortOrder)
1426 | {
1427 | }
1428 |
1429 | public virtual void ExplicitVisit(TableHint tableHint)
1430 | {
1431 | }
1432 |
1433 | internal void ExplicitVisit(ConvertCall convertCall)
1434 | {
1435 | }
1436 |
1437 | internal void ExplicitVisit(SqlDataTypeReference sqlDataTypeReference)
1438 | {
1439 | }
1440 |
1441 | internal void ExplicitVisit(VariableReference variableReference)
1442 | {
1443 | }
1444 |
1445 | internal void ExplicitVisit(BooleanParenthesisExpression booleanParenthesisExpression)
1446 | {
1447 | }
1448 |
1449 | internal void ExplicitVisit(WithCtesAndXmlNamespaces withCtesAndXmlNamespaces)
1450 | {
1451 | }
1452 |
1453 | internal void ExplicitVisit(CommonTableExpression commonTableExpression)
1454 | {
1455 | }
1456 |
1457 | internal void ExplicitVisit(ScalarSubquery scalarSubquery)
1458 | {
1459 | }
1460 |
1461 | internal void ExplicitVisit(BinaryQueryExpression binaryQueryExpression)
1462 | {
1463 | }
1464 |
1465 | internal void ExplicitVisit(BinaryExpression binaryExpression)
1466 | {
1467 | }
1468 |
1469 | internal void ExplicitVisit(FullTextPredicate fullTextPredicate)
1470 | {
1471 | }
1472 |
1473 | internal void ExplicitVisit(BooleanNotExpression notExpression)
1474 | {
1475 | }
1476 | }
1477 |
1478 | class Sql150ScriptGenerator
1479 | {
1480 | public void GenerateScript(SelectStatement statement, out string sql)
1481 | {
1482 | var buf = new StringBuilder();
1483 | statement.ToString(buf, 0);
1484 | sql = buf.ToString().Trim();
1485 | }
1486 |
1487 | internal static int GetCurrentIndent(StringBuilder buf)
1488 | {
1489 | var indent = 0;
1490 |
1491 | while (indent < buf.Length && buf[buf.Length - indent - 1] != '\n')
1492 | indent++;
1493 |
1494 | return indent;
1495 | }
1496 | }
1497 | }
1498 |
--------------------------------------------------------------------------------
/SqlVirtualEntityDataProvider/BaseExecutionContext.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Xrm.Sdk;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 |
6 | namespace MikeFactorial.Xrm.Plugins.DataProviders
7 | {
8 | public abstract class BaseExecutionContext
9 | {
10 | public IOrganizationService Service { get; protected set; }
11 |
12 | public ITracingService TracingService { get; protected set; }
13 |
14 | public IServiceProvider ServiceProvider { get; protected set; }
15 |
16 | public Entity TargetEntity
17 | {
18 | get
19 | {
20 | if (Context != null)
21 | {
22 | if (Context.InputParameters != null &&
23 | Context.InputParameters.Contains("Target") &&
24 | Context.InputParameters["Target"] is Entity)
25 | {
26 | return (Entity)Context.InputParameters["Target"];
27 | }
28 | else if (Context.PreEntityImages != null &&
29 | Context.PreEntityImages.Count > 0)
30 | {
31 | return Context.PreEntityImages.Values.FirstOrDefault();
32 | }
33 | else if (Context.PostEntityImages != null &&
34 | Context.PostEntityImages.Count > 0)
35 | {
36 | return Context.PostEntityImages.Values.FirstOrDefault();
37 | }
38 | }
39 |
40 | return null;
41 | }
42 |
43 | set
44 | {
45 | Context.InputParameters["Target"] = value;
46 | }
47 | }
48 |
49 |
50 | protected IExecutionContext Context { get; set; }
51 |
52 | public void Trace(string format, params object[] args)
53 | {
54 | TracingService.Trace(format, args);
55 | }
56 |
57 | internal void XrmTrace(string format, params object[] args)
58 | {
59 | Trace("[XrmTrace] " + format, args);
60 | }
61 |
62 | protected void Init()
63 | {
64 | LogTheContext(Context);
65 | }
66 |
67 | private void LogTheContext(IExecutionContext context)
68 | {
69 | if (context == null)
70 | {
71 | return;
72 | }
73 |
74 | var contextDetails = new List
75 | {
76 | "Context details: " +
77 | "Step: " + GetStep(context),
78 | "Msg: " + context.MessageName,
79 | "Mode: " + context.Mode,
80 | "Depth: " + context.Depth,
81 | "Corr: " + context.CorrelationId,
82 | "Type: " + context.PrimaryEntityName,
83 | "Id: " + context.PrimaryEntityId,
84 | "User: " + context.UserId,
85 | "IUser: " + context.InitiatingUserId
86 | };
87 |
88 | //Insert 'Stage' after 'Step' if it is a Plugin Context
89 | if (context is IPluginExecutionContext pluginContext)
90 | {
91 | contextDetails.Insert(2, "Stage: " + pluginContext.Stage);
92 | }
93 |
94 | XrmTrace(string.Join(Environment.NewLine, contextDetails));
95 | }
96 |
97 | private string GetStep(IExecutionContext context)
98 | {
99 | if (context.OwningExtension == null)
100 | {
101 | return "not defined";
102 | }
103 | else if (!string.IsNullOrEmpty(context.OwningExtension.Name))
104 | {
105 | return context.OwningExtension.Name;
106 | }
107 | else
108 | {
109 | return context.OwningExtension.Id.ToString();
110 | }
111 | }
112 | }
113 | }
114 |
--------------------------------------------------------------------------------
/SqlVirtualEntityDataProvider/EnvironmentSpecificExtensions.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Xrm.Sdk;
2 |
3 | namespace MikeFactorial.Xrm.Plugins.DataProviders
4 | {
5 | public static class EnvironmentSpecificExtensions
6 | {
7 | private const string dataSourceSqlConnectionStringAttribute = "mf_sqlconnectionstring";
8 | public static string GetSqlConnectionString(this PluginExecutionContext context)
9 | {
10 | var retrieverService = (IEntityDataSourceRetrieverService)context.ServiceProvider.GetService(typeof(IEntityDataSourceRetrieverService));
11 | var sourceEntity = retrieverService.RetrieveEntityDataSource();
12 | return sourceEntity[dataSourceSqlConnectionStringAttribute].ToString();
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/SqlVirtualEntityDataProvider/Mappers/GenericMapper.cs:
--------------------------------------------------------------------------------
1 | using MarkMpn.Sql4Cds.Engine.FetchXml;
2 | using Microsoft.Xrm.Sdk;
3 | using Microsoft.Xrm.Sdk.Messages;
4 | using Microsoft.Xrm.Sdk.Metadata;
5 | using Microsoft.Xrm.Sdk.Query;
6 | using System;
7 | using System.Collections.Generic;
8 | using System.Data;
9 | using System.Linq;
10 | using System.Text;
11 | using System.Threading.Tasks;
12 |
13 | namespace MikeFactorial.Xrm.Plugins.DataProviders.Mappers
14 | {
15 | public class GenericMapper
16 | {
17 | protected PluginExecutionContext context { get; set; }
18 | private EntityMetadata primaryEntityMetadata = null;
19 |
20 | public GenericMapper(PluginExecutionContext context)
21 | {
22 | this.context = context;
23 | }
24 | public EntityMetadata PrimaryEntityMetadata
25 | {
26 | get
27 | {
28 | if(primaryEntityMetadata == null)
29 | {
30 | //Create RetrieveEntityRequest
31 | RetrieveEntityRequest retrievesEntityRequest = new RetrieveEntityRequest
32 | {
33 | EntityFilters = EntityFilters.Entity | EntityFilters.Attributes,
34 | LogicalName = context.PluginContext.PrimaryEntityName
35 | };
36 |
37 | //Execute Request
38 | RetrieveEntityResponse retrieveEntityResponse = (RetrieveEntityResponse)context.Service.Execute(retrievesEntityRequest);
39 | primaryEntityMetadata = retrieveEntityResponse.EntityMetadata;
40 | }
41 |
42 | return primaryEntityMetadata;
43 | }
44 | }
45 |
46 | public virtual void MapFetchXml(object fetch)
47 | {
48 | if (fetch is condition cond)
49 | {
50 | if(!string.IsNullOrEmpty(cond.value))
51 | {
52 | cond.value = MapToVirtualEntityValue(cond.attribute, cond.value).ToString();
53 | }
54 | else if (cond.Items.Length > 0)
55 | {
56 | for (int i = 0; i < cond.Items.Length; i++)
57 | {
58 | context.Trace($"PreConvert: {cond.Items[i].Value}");
59 | cond.Items[i].Value = MapToVirtualEntityValue(cond.attribute, cond.Items[i].Value).ToString();
60 | context.Trace($"PostConvert: {cond.Items[i].Value}");
61 | }
62 | }
63 | }
64 |
65 | if (fetch is FetchType ft)
66 | {
67 | for (int i = 0; i < ft.Items.Length; i++)
68 | {
69 | object item = ft.Items[i];
70 | MapFetchXml(item);
71 | }
72 | }
73 | else if (fetch is FetchEntityType fet)
74 | {
75 | for (int i = 0; i < fet.Items.Length; i++)
76 | {
77 | object item = fet.Items[i];
78 | MapFetchXml(item);
79 | }
80 | }
81 | else if (fetch is FetchLinkEntityType felt)
82 | {
83 | for (int i = 0; i < felt.Items.Length; i++)
84 | {
85 | object item = felt.Items[i];
86 | MapFetchXml(item);
87 | }
88 | }
89 | else if (fetch is filter filt)
90 | {
91 | for (int i = 0; i < filt.Items.Length; i++)
92 | {
93 | object item = filt.Items[i];
94 | MapFetchXml(item);
95 | }
96 | }
97 |
98 | }
99 |
100 | public virtual string MapVirtualEntityAttributes(string sql)
101 | {
102 | var iEnum = this.GetCustomMappings().GetEnumerator();
103 | while (iEnum.MoveNext())
104 | {
105 | sql = sql.Replace(iEnum.Current.Key, iEnum.Current.Value);
106 | }
107 |
108 | return sql;
109 | }
110 |
111 | public virtual EntityCollection CreateEntities(DataSet dataSet, int pageSize, int pageNumber)
112 | {
113 | var collection = new EntityCollection();
114 | collection.TotalRecordCount = dataSet.Tables[0].Rows.Count;
115 | collection.MoreRecords = (collection.TotalRecordCount > (pageSize * pageNumber)) || pageSize == -1;
116 | if(dataSet != null && dataSet.Tables.Count > 0)
117 | {
118 | var rows = (pageSize > -1) ? dataSet.Tables[0].AsEnumerable().Skip(pageSize * (pageNumber - 1)).Take(pageSize) : dataSet.Tables[0].AsEnumerable();
119 | foreach (DataRow row in rows)
120 | {
121 | Entity entity = new Entity(context.PluginContext.PrimaryEntityName);
122 | foreach(DataColumn col in dataSet.Tables[0].Columns)
123 | {
124 | if(row[col] != null && row[col] != DBNull.Value)
125 | {
126 | var entityAttribute = this.PrimaryEntityMetadata.Attributes.FirstOrDefault(a => a.ExternalName == col.ColumnName);
127 | if(entityAttribute != null)
128 | {
129 | entity[entityAttribute.LogicalName] = MapToVirtualEntityValue(entityAttribute, row[col]);
130 | }
131 | }
132 | }
133 | collection.Entities.Add(entity);
134 | }
135 | }
136 | return collection;
137 | }
138 |
139 | public virtual Dictionary GetCustomMappings()
140 | {
141 | Dictionary mappings = new Dictionary();
142 |
143 | foreach (var att in PrimaryEntityMetadata.Attributes)
144 | {
145 | if(!string.IsNullOrEmpty(att.ExternalName))
146 | {
147 | mappings.Add(att.LogicalName, att.ExternalName);
148 | }
149 | }
150 | mappings.Add(PrimaryEntityMetadata.LogicalName, PrimaryEntityMetadata.ExternalName);
151 |
152 | return mappings;
153 | }
154 |
155 | public virtual object MapToVirtualEntityValue(string attributeName, object value)
156 | {
157 | var att = this.PrimaryEntityMetadata.Attributes.FirstOrDefault(a => a.LogicalName == attributeName);
158 | return MapToVirtualEntityValue(att, value);
159 | }
160 |
161 | public virtual object MapToVirtualEntityValue(AttributeMetadata entityAttribute, object value)
162 | {
163 | if (value == null || value == DBNull.Value)
164 | {
165 | return null;
166 | }
167 | else if(entityAttribute.LogicalName == this.PrimaryEntityMetadata.PrimaryIdAttribute && Int32.TryParse(value.ToString(), out int keyInt))
168 | {
169 | //This is a generic method of creating a guid from an int value if no guid is available in the database
170 | return new Guid(keyInt.ToString().PadLeft(32, 'a'));
171 | }
172 | else if (entityAttribute is LookupAttributeMetadata lookupAttr && Int32.TryParse(value.ToString(), out int lookupInt))
173 | {
174 | var lookup = new EntityReference(lookupAttr.Targets[0], new Guid(lookupInt.ToString().PadLeft(32, 'a')));
175 | return lookup;
176 | }
177 | else if ((entityAttribute is StatusAttributeMetadata || entityAttribute is StateAttributeMetadata || entityAttribute is PicklistAttributeMetadata) && Int32.TryParse(value.ToString(), out int picklistInt))
178 | {
179 | return new OptionSetValue(picklistInt);
180 | }
181 | else if (Int32.TryParse(value.ToString().Replace("{", string.Empty).Replace("}", string.Empty).Replace("a", string.Empty).Replace("A", string.Empty).Replace("-", string.Empty), out int intValue))
182 | {
183 | //This converts the generated guid back to an int.
184 | return intValue.ToString();
185 | }
186 | else
187 | {
188 | return value;
189 | }
190 | }
191 | }
192 | }
193 |
--------------------------------------------------------------------------------
/SqlVirtualEntityDataProvider/MikeFactorial.Xrm.Plugins.DataProviders.Key.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikefactorial/SqlVirtualEntityDataProvider/9e6b5fe4ca6b136d78971a8fd46d90cf4e7e83cd/SqlVirtualEntityDataProvider/MikeFactorial.Xrm.Plugins.DataProviders.Key.snk
--------------------------------------------------------------------------------
/SqlVirtualEntityDataProvider/PluginBase.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Xrm.Sdk;
2 | using System;
3 | using System.Diagnostics.CodeAnalysis;
4 |
5 | namespace MikeFactorial.Xrm.Plugins.DataProviders
6 | {
7 | ///
8 | /// The stage of a plugin.
9 | ///
10 | public enum PluginStages
11 | {
12 | ///
13 | /// Occurs prior to validation of the entity.
14 | ///
15 | PreValidation = 10,
16 |
17 | ///
18 | /// Occurs prior to the operation in the system.
19 | ///
20 | PreOperation = 20,
21 |
22 | ///
23 | /// Occurs during the main operation.
24 | ///
25 | MainOperation = 30,
26 |
27 | ///
28 | /// Occurs after the main operation.
29 | ///
30 | PostOperation = 40
31 | }
32 |
33 | ///
34 | /// Plugin Mode either Sync or Async
35 | ///
36 | public enum PluginMode
37 | {
38 | ///
39 | /// Synchronous Plugin
40 | ///
41 | Sync = 0,
42 |
43 | ///
44 | /// Asynchronous Plugin
45 | ///
46 | Async = 1
47 | }
48 |
49 | public abstract class PluginBase : IPlugin
50 | {
51 | protected PluginBase()
52 | {
53 | }
54 |
55 | public virtual void Execute(IServiceProvider serviceProvider)
56 | {
57 | try
58 | {
59 | PluginExecutionContext context = new PluginExecutionContext(serviceProvider);
60 |
61 | switch (context.PluginContext.MessageName)
62 | {
63 | case "Create":
64 | ExecuteCreate(context);
65 |
66 | break;
67 | case "Delete":
68 | ExecuteDelete(context);
69 |
70 | break;
71 | case "Retrieve":
72 | ExecuteRetrieve(context);
73 |
74 | break;
75 | case "RetrieveMultiple":
76 | ExecuteRetrieveMultiple(context);
77 |
78 | break;
79 | case "Update":
80 | ExecuteUpdate(context);
81 |
82 | break;
83 | case "Associate":
84 | ExecuteAssociate(context);
85 |
86 | break;
87 | case "Disassociate":
88 | ExecuteDisassociate(context);
89 | break;
90 | default:
91 | throw new NotImplementedException($"The message: {context.PluginContext.MessageName} is not supported");
92 | }
93 | }
94 | catch (Exception e)
95 | {
96 | throw new InvalidPluginExecutionException(e.Message, e);
97 | }
98 | }
99 |
100 | ///
101 | /// Handles the entity pre create message.
102 | ///
103 | /// The plugin execution context.
104 | public virtual void HandlePreCreateMessage(PluginExecutionContext context)
105 | {
106 | }
107 |
108 | ///
109 | /// Handles the entity post create message.
110 | ///
111 | /// The plugin execution context.
112 | public virtual void HandlePostCreateMessage(PluginExecutionContext context)
113 | {
114 | }
115 |
116 | ///
117 | /// Handles the entity post create asynchronous message.
118 | ///
119 | /// The plugin execution context.
120 | public virtual void HandlePostCreateAsyncMessage(PluginExecutionContext context)
121 | {
122 | }
123 |
124 | ///
125 | /// Handles the entity pre delete message.
126 | ///
127 | /// The plugin execution context.
128 | public virtual void HandlePreDeleteMessage(PluginExecutionContext context)
129 | {
130 | }
131 |
132 | ///
133 | /// Handles the entity post delete message.
134 | ///
135 | /// The plugin execution context.
136 | public virtual void HandlePostDeleteMessage(PluginExecutionContext context)
137 | {
138 | }
139 |
140 | ///
141 | /// Handles the entity post delete asynchronous message.
142 | ///
143 | /// The plugin execution context.
144 | public virtual void HandlePostDeleteAsyncMessage(PluginExecutionContext context)
145 | {
146 | }
147 |
148 | ///
149 | /// Handles the entity pre retrieve message.
150 | ///
151 | /// The plugin execution context.
152 | public virtual void HandlePreRetrieveMessage(PluginExecutionContext context)
153 | {
154 | }
155 |
156 | ///
157 | /// Handles the entity post retrieve message.
158 | ///
159 | /// The plugin execution context.
160 | public virtual void HandlePostRetrieveMessage(PluginExecutionContext context)
161 | {
162 | }
163 |
164 | ///
165 | /// Handles the entity post retrieve asynchronous message.
166 | ///
167 | /// The plugin execution context.
168 | public virtual void HandlePostRetrieveAsyncMessage(PluginExecutionContext context)
169 | {
170 | }
171 |
172 | ///
173 | /// Handles the entity retrieve message.
174 | ///
175 | /// The context.
176 | public virtual void HandleRetrieveMessage(PluginExecutionContext context)
177 | {
178 | }
179 |
180 | ///
181 | /// Handles the entity pre retrieve multiple message.
182 | ///
183 | /// The plugin execution context.
184 | public virtual void HandlePreRetrieveMultipleMessage(PluginExecutionContext context)
185 | {
186 | }
187 |
188 | ///
189 | /// Handles the entity post retrieve multiple message.
190 | ///
191 | /// The plugin execution context.
192 | public virtual void HandlePostRetrieveMultipleMessage(PluginExecutionContext context)
193 | {
194 | }
195 |
196 | ///
197 | /// Handles the entity post retrieve multiple asynchronous message.
198 | ///
199 | /// The plugin execution context.
200 | public virtual void HandlePostRetrieveMultipleAsyncMessage(PluginExecutionContext context)
201 | {
202 | }
203 |
204 | ///
205 | /// Handles the entity retrieve multiple message.
206 | ///
207 | /// The context.
208 | public virtual void HandleRetrieveMultipleMessage(PluginExecutionContext context)
209 | {
210 | }
211 |
212 | ///
213 | /// Handles the entity pre update message.
214 | ///
215 | /// The plugin execution context.
216 | public virtual void HandlePreUpdateMessage(PluginExecutionContext context)
217 | {
218 | }
219 |
220 | ///
221 | /// Handles the entity post update message.
222 | ///
223 | /// The plugin execution context.
224 | public virtual void HandlePostUpdateMessage(PluginExecutionContext context)
225 | {
226 | }
227 |
228 | ///
229 | /// Handles the entity post update asynchronous message.
230 | ///
231 | /// The plugin execution context.
232 | public virtual void HandlePostUpdateAsyncMessage(PluginExecutionContext context)
233 | {
234 | }
235 |
236 | ///
237 | /// Handles the entity pre associate message.
238 | ///
239 | /// The plugin execution context.
240 | public virtual void HandlePreAssociateMessage(PluginExecutionContext context)
241 | {
242 | }
243 |
244 | ///
245 | /// Handles the entity post associate message.
246 | ///
247 | /// The plugin execution context.
248 | public virtual void HandlePostAssociateMessage(PluginExecutionContext context)
249 | {
250 | }
251 |
252 | ///
253 | /// Handles the entity post associate asynchronous message.
254 | ///
255 | /// The plugin execution context.
256 | public virtual void HandlePostAssociateAsyncMessage(PluginExecutionContext context)
257 | {
258 | }
259 |
260 | ///
261 | /// Handles the entity pre disassociate message.
262 | ///
263 | /// The plugin execution context.
264 | public virtual void HandlePreDisassociateMessage(PluginExecutionContext context)
265 | {
266 | }
267 |
268 | ///
269 | /// Handles the entity post disassociate message.
270 | ///
271 | /// The plugin execution context.
272 | public virtual void HandlePostDisassociateMessage(PluginExecutionContext context)
273 | {
274 | }
275 |
276 | ///
277 | /// Handles the entity post disassociate asynchronous message.
278 | ///
279 | /// The plugin execution context.
280 | public virtual void HandlePostDisassociateAsyncMessage(PluginExecutionContext context)
281 | {
282 | }
283 |
284 | private void ExecuteCreate(PluginExecutionContext context)
285 | {
286 | if (IsPreOperation(context))
287 | {
288 | HandlePreCreateMessage(context);
289 | }
290 | else if (IsPostOperation(context))
291 | {
292 | if (IsAsyncPlugin(context))
293 | {
294 | HandlePostCreateAsyncMessage(context);
295 | }
296 | else
297 | {
298 | HandlePostCreateMessage(context);
299 | }
300 | }
301 | else
302 | {
303 | ThrowMessageNotFoundException(context.PluginContext.MessageName, context.PluginContext.Stage);
304 | }
305 | }
306 |
307 | private void ExecuteDelete(PluginExecutionContext context)
308 | {
309 | if (IsPreOperation(context))
310 | {
311 | HandlePreDeleteMessage(context);
312 | }
313 | else if (IsPostOperation(context))
314 | {
315 | if (IsAsyncPlugin(context))
316 | {
317 | HandlePostDeleteAsyncMessage(context);
318 | }
319 | else
320 | {
321 | HandlePostDeleteMessage(context);
322 | }
323 | }
324 | else
325 | {
326 | ThrowMessageNotFoundException(context.PluginContext.MessageName, context.PluginContext.Stage);
327 | }
328 | }
329 |
330 | private void ExecuteRetrieve(PluginExecutionContext context)
331 | {
332 | if (IsPreOperation(context))
333 | {
334 | HandlePreRetrieveMessage(context);
335 | }
336 | else if (IsPostOperation(context))
337 | {
338 | if (IsAsyncPlugin(context))
339 | {
340 | HandlePostRetrieveAsyncMessage(context);
341 | }
342 | else
343 | {
344 | HandlePostRetrieveMessage(context);
345 | }
346 | }
347 | else
348 | {
349 | HandleRetrieveMessage(context);
350 | }
351 | }
352 |
353 | private void ExecuteRetrieveMultiple(PluginExecutionContext context)
354 | {
355 | if (IsPreOperation(context))
356 | {
357 | HandlePreRetrieveMultipleMessage(context);
358 | }
359 | else if (IsPostOperation(context))
360 | {
361 | if (IsAsyncPlugin(context))
362 | {
363 | HandlePostRetrieveMultipleAsyncMessage(context);
364 | }
365 | else
366 | {
367 | HandlePostRetrieveMultipleMessage(context);
368 | }
369 | }
370 | else
371 | {
372 | HandleRetrieveMultipleMessage(context);
373 | }
374 | }
375 |
376 | private void ExecuteUpdate(PluginExecutionContext context)
377 | {
378 | if (IsPreOperation(context))
379 | {
380 | HandlePreUpdateMessage(context);
381 | }
382 | else if (IsPostOperation(context))
383 | {
384 | if (IsAsyncPlugin(context))
385 | {
386 | HandlePostUpdateAsyncMessage(context);
387 | }
388 | else
389 | {
390 | HandlePostUpdateMessage(context);
391 | }
392 | }
393 | else
394 | {
395 | ThrowMessageNotFoundException(context.PluginContext.MessageName, context.PluginContext.Stage);
396 | }
397 | }
398 |
399 | private void ExecuteAssociate(PluginExecutionContext context)
400 | {
401 | if (IsPreOperation(context))
402 | {
403 | HandlePreAssociateMessage(context);
404 | }
405 | else if (IsPostOperation(context))
406 | {
407 | if (IsAsyncPlugin(context))
408 | {
409 | HandlePostAssociateAsyncMessage(context);
410 | }
411 | else
412 | {
413 | HandlePostAssociateMessage(context);
414 | }
415 | }
416 | else
417 | {
418 | ThrowMessageNotFoundException(context.PluginContext.MessageName, context.PluginContext.Stage);
419 | }
420 | }
421 |
422 | private void ExecuteDisassociate(PluginExecutionContext context)
423 | {
424 | if (IsPreOperation(context))
425 | {
426 | HandlePreDisassociateMessage(context);
427 | }
428 | else if (IsPostOperation(context))
429 | {
430 | if (IsAsyncPlugin(context))
431 | {
432 | HandlePostDisassociateAsyncMessage(context);
433 | }
434 | else
435 | {
436 | HandlePostDisassociateMessage(context);
437 | }
438 | }
439 | else
440 | {
441 | ThrowMessageNotFoundException(context.PluginContext.MessageName, context.PluginContext.Stage);
442 | }
443 | }
444 |
445 | private bool IsPreOperation(PluginExecutionContext context)
446 | {
447 | return context.PluginContext.Stage == (int)PluginStages.PreValidation || context.PluginContext.Stage == (int)PluginStages.PreOperation;
448 | }
449 |
450 | private bool IsPostOperation(PluginExecutionContext context)
451 | {
452 | return context.PluginContext.Stage == (int)PluginStages.PostOperation;
453 | }
454 |
455 | private bool IsAsyncPlugin(PluginExecutionContext context)
456 | {
457 | return context.PluginContext.Mode == (int)PluginMode.Async;
458 | }
459 |
460 | private void ThrowMessageNotFoundException(string messageName, int stage)
461 | {
462 | throw new InvalidPluginExecutionException($"The message '{messageName}' is not supported in stage {stage}");
463 | }
464 | }
465 | }
466 |
--------------------------------------------------------------------------------
/SqlVirtualEntityDataProvider/PluginExecutionContext.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Xrm.Sdk;
2 | using System;
3 |
4 | namespace MikeFactorial.Xrm.Plugins.DataProviders
5 | {
6 | public sealed class PluginExecutionContext : BaseExecutionContext, IDisposable, ITracingService
7 | {
8 | public PluginExecutionContext(IServiceProvider serviceProvider)
9 | {
10 | ServiceProvider = serviceProvider;
11 | TracingService = (ITracingService)serviceProvider.GetService(typeof(ITracingService));
12 | Context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
13 | var serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
14 | Service = serviceFactory.CreateOrganizationService(Context.InitiatingUserId);
15 | Init();
16 | }
17 |
18 | public IPluginExecutionContext PluginContext => Context as IPluginExecutionContext;
19 |
20 |
21 | public void Dispose()
22 | {
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/SqlVirtualEntityDataProvider/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("SqlVirtualEntityDataProvider")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("SqlVirtualEntityDataProvider")]
13 | [assembly: AssemblyCopyright("Copyright © 2020")]
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("62d2d0a0-395e-4970-824a-12001296cc43")]
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 |
--------------------------------------------------------------------------------
/SqlVirtualEntityDataProvider/Solutions/PreviousVersions/VirtualEntityProvidersSamplebyMike_1_0_0_3.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikefactorial/SqlVirtualEntityDataProvider/9e6b5fe4ca6b136d78971a8fd46d90cf4e7e83cd/SqlVirtualEntityDataProvider/Solutions/PreviousVersions/VirtualEntityProvidersSamplebyMike_1_0_0_3.zip
--------------------------------------------------------------------------------
/SqlVirtualEntityDataProvider/Solutions/PreviousVersions/VirtualEntityProvidersSamplebyMike_1_0_0_3_managed.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikefactorial/SqlVirtualEntityDataProvider/9e6b5fe4ca6b136d78971a8fd46d90cf4e7e83cd/SqlVirtualEntityDataProvider/Solutions/PreviousVersions/VirtualEntityProvidersSamplebyMike_1_0_0_3_managed.zip
--------------------------------------------------------------------------------
/SqlVirtualEntityDataProvider/Solutions/PreviousVersions/VirtualEntityProvidersbyMike_1_0_0_3.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikefactorial/SqlVirtualEntityDataProvider/9e6b5fe4ca6b136d78971a8fd46d90cf4e7e83cd/SqlVirtualEntityDataProvider/Solutions/PreviousVersions/VirtualEntityProvidersbyMike_1_0_0_3.zip
--------------------------------------------------------------------------------
/SqlVirtualEntityDataProvider/Solutions/PreviousVersions/VirtualEntityProvidersbyMike_1_0_0_3_managed.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikefactorial/SqlVirtualEntityDataProvider/9e6b5fe4ca6b136d78971a8fd46d90cf4e7e83cd/SqlVirtualEntityDataProvider/Solutions/PreviousVersions/VirtualEntityProvidersbyMike_1_0_0_3_managed.zip
--------------------------------------------------------------------------------
/SqlVirtualEntityDataProvider/Solutions/VirtualEntityProvidersSamplebyMike_1_0_0_4.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikefactorial/SqlVirtualEntityDataProvider/9e6b5fe4ca6b136d78971a8fd46d90cf4e7e83cd/SqlVirtualEntityDataProvider/Solutions/VirtualEntityProvidersSamplebyMike_1_0_0_4.zip
--------------------------------------------------------------------------------
/SqlVirtualEntityDataProvider/Solutions/VirtualEntityProvidersSamplebyMike_1_0_0_4_managed.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikefactorial/SqlVirtualEntityDataProvider/9e6b5fe4ca6b136d78971a8fd46d90cf4e7e83cd/SqlVirtualEntityDataProvider/Solutions/VirtualEntityProvidersSamplebyMike_1_0_0_4_managed.zip
--------------------------------------------------------------------------------
/SqlVirtualEntityDataProvider/Solutions/VirtualEntityProvidersbyMike_1_0_0_4.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikefactorial/SqlVirtualEntityDataProvider/9e6b5fe4ca6b136d78971a8fd46d90cf4e7e83cd/SqlVirtualEntityDataProvider/Solutions/VirtualEntityProvidersbyMike_1_0_0_4.zip
--------------------------------------------------------------------------------
/SqlVirtualEntityDataProvider/Solutions/VirtualEntityProvidersbyMike_1_0_0_4_managed.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikefactorial/SqlVirtualEntityDataProvider/9e6b5fe4ca6b136d78971a8fd46d90cf4e7e83cd/SqlVirtualEntityDataProvider/Solutions/VirtualEntityProvidersbyMike_1_0_0_4_managed.zip
--------------------------------------------------------------------------------
/SqlVirtualEntityDataProvider/SqlVirtualEntityDataProvider.cs:
--------------------------------------------------------------------------------
1 | using MarkMpn.Sql4Cds.Engine;
2 | using MarkMpn.Sql4Cds.Engine.FetchXml;
3 | using Microsoft.Crm.Sdk.Messages;
4 | using Microsoft.Xrm.Sdk;
5 | using Microsoft.Xrm.Sdk.Query;
6 | using MikeFactorial.Xrm.Plugins.DataProviders.Mappers;
7 | using System;
8 | using System.Data;
9 | using System.Data.SqlClient;
10 | using System.IO;
11 | using System.Xml;
12 | using System.Xml.Serialization;
13 |
14 | namespace MikeFactorial.Xrm.Plugins.DataProviders
15 | {
16 | ///
17 | /// Virtual Entity Data Provider for SQL
18 | ///
19 | public class SqlVirtualEntityDataProvider : PluginBase
20 | {
21 | ///
22 | /// Handles the entity retrieve message.
23 | ///
24 | /// The context.
25 | public override void HandleRetrieveMessage(PluginExecutionContext context)
26 | {
27 | base.HandleRetrieveMessage(context);
28 | var mapper = new GenericMapper(context);
29 | Entity entity = new Entity(context.PluginContext.PrimaryEntityName);
30 |
31 | if (mapper != null)
32 | {
33 | string sql = $"SELECT * FROM {context.PluginContext.PrimaryEntityName} WITH(NOLOCK) WHERE {mapper.PrimaryEntityMetadata.PrimaryIdAttribute} = '{mapper.MapToVirtualEntityValue(mapper.PrimaryEntityMetadata.PrimaryIdAttribute, context.PluginContext.PrimaryEntityId)}'";
34 | sql = mapper.MapVirtualEntityAttributes(sql);
35 |
36 | var entities = this.GetEntitiesFromSql(context, mapper, sql, 1, 1);
37 | if (entities.Entities != null && entities.Entities.Count > 0)
38 | {
39 | entity = entities.Entities[0];
40 | }
41 | }
42 |
43 | // Set output parameter
44 | context.PluginContext.OutputParameters["BusinessEntity"] = entity;
45 | }
46 |
47 | ///
48 | /// Handles the entity retrieve multiple message.
49 | ///
50 | /// The context.
51 | public override void HandleRetrieveMultipleMessage(PluginExecutionContext context)
52 | {
53 | base.HandleRetrieveMultipleMessage(context);
54 |
55 | var query = context.PluginContext.InputParameters["Query"];
56 | if (query != null)
57 | {
58 | var mapper = new GenericMapper(context);
59 |
60 | EntityCollection collection = new EntityCollection();
61 | string fetchXml = string.Empty;
62 | if (query is QueryExpression qe)
63 | {
64 | var convertRequest = new QueryExpressionToFetchXmlRequest();
65 | convertRequest.Query = (QueryExpression)qe;
66 | var response = (QueryExpressionToFetchXmlResponse)context.Service.Execute(convertRequest);
67 | fetchXml = response.FetchXml;
68 | }
69 | else if(query is FetchExpression fe)
70 | {
71 | fetchXml = fe.Query;
72 | }
73 |
74 | if(!string.IsNullOrEmpty(fetchXml))
75 | {
76 | context.Trace($"Pre FetchXML: {fetchXml}");
77 |
78 | var metadata = new AttributeMetadataCache(context.Service);
79 | var fetch = Deserialize(fetchXml);
80 | mapper.MapFetchXml(fetch);
81 |
82 | //Store page info before converting
83 | int page = -1;
84 | int count = -1;
85 | if (!string.IsNullOrEmpty(fetch.page))
86 | {
87 | page = Int32.Parse(fetch.page);
88 | fetch.page = string.Empty;
89 | }
90 |
91 | if (!string.IsNullOrEmpty(fetch.count))
92 | {
93 | count = Int32.Parse(fetch.count);
94 | fetch.count = string.Empty;
95 | }
96 |
97 | var sql = FetchXml2Sql.Convert(context.Service, metadata, fetch, new FetchXml2SqlOptions { PreserveFetchXmlOperatorsAsFunctions = false }, out _);
98 |
99 | sql = mapper.MapVirtualEntityAttributes(sql);
100 | context.Trace($"SQL: {sql}");
101 |
102 | if (page != -1 && count != -1)
103 | {
104 | collection = this.GetEntitiesFromSql(context, mapper, sql, count, page);
105 | }
106 | else
107 | {
108 | collection = this.GetEntitiesFromSql(context, mapper, sql, -1, 1);
109 | }
110 | }
111 | context.Trace($"Records Returned: {collection.Entities.Count}");
112 | context.PluginContext.OutputParameters["BusinessEntityCollection"] = collection;
113 | }
114 | }
115 |
116 | private EntityCollection GetEntitiesFromSql(PluginExecutionContext context, GenericMapper mapper, string sql, int pageSize, int pageNumber)
117 | {
118 | context.Trace($"SQL: {sql}");
119 | EntityCollection collection = new EntityCollection();
120 | using (SqlConnection sqlConnection = new SqlConnection(context.GetSqlConnectionString()))
121 | {
122 | SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sql, sqlConnection);
123 | DataSet dataSet = new DataSet();
124 | sqlConnection.Open();
125 | sqlDataAdapter.Fill(dataSet, "SqlData");
126 | sqlConnection.Close();
127 | context.Trace($"Records Retrieved: {dataSet.Tables[0].Rows.Count}", Array.Empty());
128 | collection = mapper.CreateEntities(dataSet, pageSize, pageNumber);
129 | }
130 |
131 | return collection;
132 | }
133 |
134 | ///
135 | /// Deserializes the fetch XML.
136 | ///
137 | /// The fetch XML.
138 | /// Fetch Object for the FetchXML string
139 | private static FetchType Deserialize(string fetchXml)
140 | {
141 | var serializer = new XmlSerializer(typeof(FetchType));
142 | object result;
143 | using (TextReader reader = new StringReader(fetchXml))
144 | {
145 | result = serializer.Deserialize(reader);
146 | }
147 |
148 | return result as FetchType;
149 | }
150 | }
151 | }
--------------------------------------------------------------------------------
/SqlVirtualEntityDataProvider/SqlVirtualEntityDataProvider.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {62D2D0A0-395E-4970-824A-12001296CC43}
8 | Library
9 | Properties
10 | MikeFactorial.Xrm.Plugins.DataProviders
11 | MikeFactorial.Xrm.Plugins.DataProviders
12 | v4.6.2
13 | 512
14 | true
15 |
16 |
17 |
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 |
26 |
27 | pdbonly
28 | true
29 | bin\Release\
30 | TRACE
31 | prompt
32 | 4
33 |
34 |
35 | true
36 |
37 |
38 | MikeFactorial.Xrm.Plugins.DataProviders.Key.snk
39 |
40 |
41 |
42 | ..\packages\Microsoft.CrmSdk.CoreAssemblies.9.0.2.26\lib\net462\Microsoft.Crm.Sdk.Proxy.dll
43 |
44 |
45 | ..\packages\Microsoft.CrmSdk.CoreAssemblies.9.0.2.26\lib\net462\Microsoft.Xrm.Sdk.dll
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
--------------------------------------------------------------------------------
/SqlVirtualEntityDataProvider/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------