File: BasicExpressionVisitor.cs

package info (click to toggle)
mono 6.14.1%2Bds2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,282,732 kB
  • sloc: cs: 11,182,461; xml: 2,850,281; ansic: 699,123; cpp: 122,919; perl: 58,604; javascript: 30,841; asm: 21,845; makefile: 19,602; sh: 10,973; python: 4,772; pascal: 925; sql: 859; sed: 16; php: 1
file content (748 lines) | stat: -rw-r--r-- 36,059 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
//---------------------------------------------------------------------
// <copyright file="BasicExpressionVisitor.cs" company="Microsoft">
//      Copyright (c) Microsoft Corporation.  All rights reserved.
// </copyright>
//
// @owner  Microsoft
// @backupOwner Microsoft
//---------------------------------------------------------------------

namespace System.Data.Common.CommandTrees
{
    using System.Collections.Generic;
    using System.Diagnostics;

    /// <summary>
    /// An abstract base type for types that implement the IExpressionVisitor interface to derive from.
    /// </summary>
    /*CQT_PUBLIC_API(*/internal/*)*/ abstract class BasicExpressionVisitor : DbExpressionVisitor
    {
        #region protected API, may be overridden to add functionality at specific points in the traversal

        /// <summary>
        /// Convenience method to visit the specified <see cref="DbUnaryExpression"/>.
        /// </summary>
        /// <param name="expression">The DbUnaryExpression to visit.</param>
        /// <exception cref="ArgumentNullException"><paramref name="expression"/> is null</exception>
        protected virtual void VisitUnaryExpression(DbUnaryExpression expression)
        {
            VisitExpression(EntityUtil.CheckArgumentNull(expression, "expression").Argument);
        }

        /// <summary>
        /// Convenience method to visit the specified <see cref="DbBinaryExpression"/>.
        /// </summary>
        /// <param name="expression">The DbBinaryExpression to visit.</param>
        /// <exception cref="ArgumentNullException"><paramref name="expression"/> is null</exception>
        protected virtual void VisitBinaryExpression(DbBinaryExpression expression)
        {
            EntityUtil.CheckArgumentNull(expression, "expression");

            VisitExpression(expression.Left);
            VisitExpression(expression.Right);
        }
                
        /// <summary>
        /// Convenience method to visit the specified <see cref="DbExpressionBinding"/>.
        /// </summary>
        /// <param name="binding">The DbExpressionBinding to visit.</param>
        /// <exception cref="ArgumentNullException"><paramref name="binding"/> is null</exception>
        protected virtual void VisitExpressionBindingPre(DbExpressionBinding binding)
        {
            EntityUtil.CheckArgumentNull(binding, "binding");
            VisitExpression(binding.Expression);
        }

        /// <summary>
        /// Convenience method for post-processing after a DbExpressionBinding has been visited.
        /// </summary>
        /// <param name="binding">The previously visited DbExpressionBinding.</param>
        protected virtual void VisitExpressionBindingPost(DbExpressionBinding binding)
        {
        }

        /// <summary>
        /// Convenience method to visit the specified <see cref="DbGroupExpressionBinding"/>.
        /// </summary>
        /// <param name="binding">The DbGroupExpressionBinding to visit.</param>
        /// <exception cref="ArgumentNullException"><paramref name="binding"/> is null</exception>
        protected virtual void VisitGroupExpressionBindingPre(DbGroupExpressionBinding binding)
        {
            EntityUtil.CheckArgumentNull(binding, "binding");
            VisitExpression(binding.Expression);
        }

        /// <summary>
        /// Convenience method indicating that the grouping keys of a <see cref="DbGroupByExpression"/> have been visited and the aggregates are now about to be visited.
        /// </summary>
        /// <param name="binding">The DbGroupExpressionBinding of the DbGroupByExpression</param>
        protected virtual void VisitGroupExpressionBindingMid(DbGroupExpressionBinding binding)
        {
        }

        /// <summary>
        /// Convenience method for post-processing after a DbGroupExpressionBinding has been visited.
        /// </summary>
        /// <param name="binding">The previously visited DbGroupExpressionBinding.</param>
        protected virtual void VisitGroupExpressionBindingPost(DbGroupExpressionBinding binding)
        {
        }

        /// <summary>
        /// Convenience method indicating that the body of a Lambda <see cref="DbFunctionExpression"/> is now about to be visited.
        /// </summary>
        /// <param name="lambda">The DbLambda that is about to be visited</param>
        /// <exception cref="ArgumentNullException"><paramref name="lambda"/> is null</exception>
        protected virtual void VisitLambdaPre(DbLambda lambda)
        {
            EntityUtil.CheckArgumentNull(lambda, "lambda");
        }

        /// <summary>
        /// Convenience method for post-processing after a DbLambda has been visited.
        /// </summary>
        /// <param name="lambda">The previously visited DbLambda.</param>
        protected virtual void VisitLambdaPost(DbLambda lambda)
        {
        }

        #endregion

        #region public convenience API

        /// <summary>
        /// Convenience method to visit the specified <see cref="DbExpression"/>, if non-null.
        /// </summary>
        /// <param name="expression">The expression to visit.</param>
        /// <exception cref="ArgumentNullException"><paramref name="expression"/> is null</exception>
        public virtual void VisitExpression(DbExpression expression)
        {
            // #433613: PreSharp warning 56506: Parameter 'expression' to this public method must be validated: A null-dereference can occur here.
            EntityUtil.CheckArgumentNull(expression, "expression").Accept(this);
        }

        /// <summary>
        /// Convenience method to visit each <see cref="DbExpression"/> in the given list, if the list is non-null.
        /// </summary>
        /// <param name="expressionList">The list of expressions to visit.</param>
        /// <exception cref="ArgumentNullException"><paramref name="expressionList"/> is null</exception>
        public virtual void VisitExpressionList(IList<DbExpression> expressionList)
        {
            EntityUtil.CheckArgumentNull(expressionList, "expressionList");
            for(int idx = 0; idx < expressionList.Count; idx++)
            {
                VisitExpression(expressionList[idx]);
            }
        }

        /// <summary>
        /// Convenience method to visit each <see cref="DbAggregate"/> in the list, if the list is non-null.
        /// </summary>
        /// <param name="aggregates">The list of aggregates to visit.</param>
        /// <exception cref="ArgumentNullException"><paramref name="aggregates"/> is null</exception>
        public virtual void VisitAggregateList(IList<DbAggregate> aggregates)
        {
            EntityUtil.CheckArgumentNull(aggregates, "aggregates");
            for(int idx = 0; idx < aggregates.Count; idx++)
            {
                VisitAggregate(aggregates[idx]);
            }
        }

        /// <summary>
        /// Convenience method to visit the specified <see cref="DbAggregate"/>.
        /// </summary>
        /// <param name="aggregate">The aggregate to visit.</param>
        /// <exception cref="ArgumentNullException"><paramref name="aggregate"/> is null</exception>
        public virtual void VisitAggregate(DbAggregate aggregate)
        {
            // #433613: PreSharp warning 56506: Parameter 'aggregate' to this public method must be validated: A null-dereference can occur here.
            VisitExpressionList(EntityUtil.CheckArgumentNull(aggregate, "aggregate").Arguments);
        }

        internal virtual void VisitRelatedEntityReferenceList(IList<DbRelatedEntityRef> relatedEntityReferences)
        {
            for (int idx = 0; idx < relatedEntityReferences.Count; idx++)
            {
                this.VisitRelatedEntityReference(relatedEntityReferences[idx]);
            }
        }
        
        internal virtual void VisitRelatedEntityReference(DbRelatedEntityRef relatedEntityRef)
        {
            VisitExpression(relatedEntityRef.TargetEntityReference);
        }

        #endregion

        #region DbExpressionVisitor Members

        /// <summary>
        /// Called when an <see cref="DbExpression"/> of an otherwise unrecognized type is encountered.
        /// </summary>
        /// <param name="expression">The expression</param>
        /// <exception cref="ArgumentNullException"><paramref name="expression"/> is null</exception>
        /// <exception cref="NotSupportedException">Always thrown if this method is called, since it indicates that <paramref name="expression"/> is of an unsupported type</exception>
        public override void Visit(DbExpression expression)
        {
            // #433613: PreSharp warning 56506: Parameter 'expression' to this public method must be validated: A null-dereference can occur here.
            EntityUtil.CheckArgumentNull(expression, "expression");

            throw EntityUtil.NotSupported(System.Data.Entity.Strings.Cqt_General_UnsupportedExpression(expression.GetType().FullName));
        }

        /// <summary>
        /// Visitor pattern method for <see cref="DbConstantExpression"/>.
        /// </summary>
        /// <param name="expression">The DbConstantExpression that is being visited.</param>
        /// <exception cref="ArgumentNullException"><paramref name="expression"/> is null</exception>
        public override void Visit(DbConstantExpression expression)
        {
            // #433613: PreSharp warning 56506: Parameter 'expression' to this public method must be validated: A null-dereference can occur here.
            EntityUtil.CheckArgumentNull(expression, "expression");
        }

        /// <summary>
        /// Visitor pattern method for <see cref="DbNullExpression"/>.
        /// </summary>
        /// <param name="expression">The DbNullExpression that is being visited.</param>
        /// <exception cref="ArgumentNullException"><paramref name="expression"/> is null</exception>
        public override void Visit(DbNullExpression expression)
        {
            // #433613: PreSharp warning 56506: Parameter 'expression' to this public method must be validated: A null-dereference can occur here.
            EntityUtil.CheckArgumentNull(expression, "expression");
        }

        /// <summary>
        /// Visitor pattern method for <see cref="DbVariableReferenceExpression"/>.
        /// </summary>
        /// <param name="expression">The DbVariableReferenceExpression that is being visited.</param>
        /// <exception cref="ArgumentNullException"><paramref name="expression"/> is null</exception>
        public override void Visit(DbVariableReferenceExpression expression)
        {
            // #433613: PreSharp warning 56506: Parameter 'expression' to this public method must be validated: A null-dereference can occur here.
            EntityUtil.CheckArgumentNull(expression, "expression");
        }

        /// <summary>
        /// Visitor pattern method for <see cref="DbParameterReferenceExpression"/>.
        /// </summary>
        /// <param name="expression">The DbParameterReferenceExpression that is being visited.</param>
        /// <exception cref="ArgumentNullException"><paramref name="expression"/> is null</exception>
        public override void Visit(DbParameterReferenceExpression expression)
        {
            // #433613: PreSharp warning 56506: Parameter 'expression' to this public method must be validated: A null-dereference can occur here.
            EntityUtil.CheckArgumentNull(expression, "expression");
        }

        /// <summary>
        /// Visitor pattern method for <see cref="DbFunctionExpression"/>.
        /// </summary>
        /// <param name="expression">The DbFunctionExpression that is being visited.</param>
        /// <exception cref="ArgumentNullException"><paramref name="expression"/> is null</exception>
        public override void Visit(DbFunctionExpression expression)
        {
            // #433613: PreSharp warning 56506: Parameter 'expression' to this public method must be validated: A null-dereference can occur here.
            EntityUtil.CheckArgumentNull(expression, "expression");

            VisitExpressionList(expression.Arguments);
        }

        /// <summary>
        /// Visitor pattern method for <see cref="DbLambdaExpression"/>.
        /// </summary>
        /// <param name="expression">The DbLambdaExpression that is being visited.</param>
        /// <exception cref="ArgumentNullException"><paramref name="expression"/> is null</exception>
        public override void Visit(DbLambdaExpression expression)
        {
            // #433613: PreSharp warning 56506: Parameter 'expression' to this public method must be validated: A null-dereference can occur here.
            EntityUtil.CheckArgumentNull(expression, "expression");

            VisitExpressionList(expression.Arguments);

            VisitLambdaPre(expression.Lambda);
            VisitExpression(expression.Lambda.Body);
            VisitLambdaPost(expression.Lambda);
        }

#if METHOD_EXPRESSION
        /// <summary>
        /// Visitor pattern method for <see cref="MethodExpression"/>.
        /// </summary>
        /// <param name="expression">The MethodExpression that is being visited.</param>
        /// <exception cref="ArgumentNullException"><paramref name="expression"/> is null</exception>
        public override void Visit(MethodExpression expression)
        {
            // #433613: PreSharp warning 56506: Parameter 'expression' to this public method must be validated: A null-dereference can occur here.
            EntityUtil.CheckArgumentNull(expression, "expression");

            if (expression.Instance != null)
            {
                VisitExpression(expression.Instance);
            }
            VisitExpressionList(expression.Arguments);
        }
#endif

        /// <summary>
        /// Visitor pattern method for <see cref="DbPropertyExpression"/>.
        /// </summary>
        /// <param name="expression">The DbPropertyExpression that is being visited.</param>
        /// <exception cref="ArgumentNullException"><paramref name="expression"/> is null</exception>
        public override void Visit(DbPropertyExpression expression)
        {
            // #433613: PreSharp warning 56506: Parameter 'expression' to this public method must be validated: A null-dereference can occur here.
            EntityUtil.CheckArgumentNull(expression, "expression");
            
            if(expression.Instance != null)
            {
                VisitExpression(expression.Instance);
            }
        }

        /// <summary>
        /// Visitor pattern method for <see cref="DbComparisonExpression"/>.
        /// </summary>
        /// <param name="expression">The DbComparisonExpression that is being visited.</param>
        /// <exception cref="ArgumentNullException"><paramref name="expression"/> is null</exception>
        public override void Visit(DbComparisonExpression expression)
        {
            VisitBinaryExpression(expression);
        }

        /// <summary>
        /// Visitor pattern method for <see cref="DbLikeExpression"/>.
        /// </summary>
        /// <param name="expression">The DbLikeExpression that is being visited.</param>
        /// <exception cref="ArgumentNullException"><paramref name="expression"/> is null</exception>
        public override void Visit(DbLikeExpression expression)
        {
            // #433613: PreSharp warning 56506: Parameter 'expression' to this public method must be validated: A null-dereference can occur here.
            EntityUtil.CheckArgumentNull(expression, "expression");

            VisitExpression(expression.Argument);
            VisitExpression(expression.Pattern);
            VisitExpression(expression.Escape);
        }

        /// <summary>
        /// Visitor pattern method for <see cref="DbLimitExpression"/>.
        /// </summary>
        /// <param name="expression">The DbLimitExpression that is being visited.</param>
        /// <exception cref="ArgumentNullException"><paramref name="expression"/> is null</exception>
        public override void Visit(DbLimitExpression expression)
        {
            // #433613: PreSharp warning 56506: Parameter 'expression' to this public method must be validated: A null-dereference can occur here.
            EntityUtil.CheckArgumentNull(expression, "expression");

            VisitExpression(expression.Argument);
            VisitExpression(expression.Limit);
        }

        /// <summary>
        /// Visitor pattern method for <see cref="DbIsNullExpression"/>.
        /// </summary>
        /// <param name="expression">The DbIsNullExpression that is being visited.</param>
        /// <exception cref="ArgumentNullException"><paramref name="expression"/> is null</exception>
        public override void Visit(DbIsNullExpression expression)
        {
            VisitUnaryExpression(expression);
        }

        /// <summary>
        /// Visitor pattern method for <see cref="DbArithmeticExpression"/>.
        /// </summary>
        /// <param name="expression">The DbArithmeticExpression that is being visited.</param>
        /// <exception cref="ArgumentNullException"><paramref name="expression"/> is null</exception>
        public override void Visit(DbArithmeticExpression expression)
        {
            VisitExpressionList(EntityUtil.CheckArgumentNull(expression, "expression").Arguments);
        }

        /// <summary>
        /// Visitor pattern method for <see cref="DbAndExpression"/>.
        /// </summary>
        /// <param name="expression">The DbAndExpression that is being visited.</param>
        /// <exception cref="ArgumentNullException"><paramref name="expression"/> is null</exception>
        public override void Visit(DbAndExpression expression)
        {
            VisitBinaryExpression(expression);
        }

        /// <summary>
        /// Visitor pattern method for <see cref="DbOrExpression"/>.
        /// </summary>
        /// <param name="expression">The DbOrExpression that is being visited.</param>
        /// <exception cref="ArgumentNullException"><paramref name="expression"/> is null</exception>
        public override void Visit(DbOrExpression expression)
        {
            VisitBinaryExpression(expression);
        }

        /// <summary>
        /// Visitor pattern method for <see cref="DbNotExpression"/>.
        /// </summary>
        /// <param name="expression">The DbNotExpression that is being visited.</param>
        /// <exception cref="ArgumentNullException"><paramref name="expression"/> is null</exception>
        public override void Visit(DbNotExpression expression)
        {
            VisitUnaryExpression(expression);
        }

        /// <summary>
        /// Visitor pattern method for <see cref="DbDistinctExpression"/>.
        /// </summary>
        /// <param name="expression">The DbDistinctExpression that is being visited.</param>
        /// <exception cref="ArgumentNullException"><paramref name="expression"/> is null</exception>
        public override void Visit(DbDistinctExpression expression)
        {
            VisitUnaryExpression(expression);
        }

        /// <summary>
        /// Visitor pattern method for <see cref="DbElementExpression"/>.
        /// </summary>
        /// <param name="expression">The DbElementExpression that is being visited.</param>
        /// <exception cref="ArgumentNullException"><paramref name="expression"/> is null</exception>
        public override void Visit(DbElementExpression expression)
        {
            VisitUnaryExpression(expression);
        }

        /// <summary>
        /// Visitor pattern method for <see cref="DbIsEmptyExpression"/>.
        /// </summary>
        /// <param name="expression">The DbIsEmptyExpression that is being visited.</param>
        /// <exception cref="ArgumentNullException"><paramref name="expression"/> is null</exception>
        public override void Visit(DbIsEmptyExpression expression)
        {
            VisitUnaryExpression(expression);
        }

        /// <summary>
        /// Visitor pattern method for <see cref="DbUnionAllExpression"/>.
        /// </summary>
        /// <param name="expression">The DbUnionAllExpression that is being visited.</param>
        /// <exception cref="ArgumentNullException"><paramref name="expression"/> is null</exception>
        public override void Visit(DbUnionAllExpression expression)
        {
            VisitBinaryExpression(expression);
        }

        /// <summary>
        /// Visitor pattern method for <see cref="DbIntersectExpression"/>.
        /// </summary>
        /// <param name="expression">The DbIntersectExpression that is being visited.</param>
        /// <exception cref="ArgumentNullException"><paramref name="expression"/> is null</exception>
        public override void Visit(DbIntersectExpression expression)
        {
            VisitBinaryExpression(expression);
        }

        /// <summary>
        /// Visitor pattern method for <see cref="DbExceptExpression"/>.
        /// </summary>
        /// <param name="expression">The DbExceptExpression that is being visited.</param>
        /// <exception cref="ArgumentNullException"><paramref name="expression"/> is null</exception>
        public override void Visit(DbExceptExpression expression)
        {
            VisitBinaryExpression(expression);
        }

        /// <summary>
        /// Visitor pattern method for <see cref="DbOfTypeExpression"/>.
        /// </summary>
        /// <param name="expression">The DbOfTypeExpression that is being visited.</param>
        /// <exception cref="ArgumentNullException"><paramref name="expression"/> is null</exception>
        public override void Visit(DbOfTypeExpression expression)
        {
            VisitUnaryExpression(expression);
        }

        /// <summary>
        /// Visitor pattern method for <see cref="DbTreatExpression"/>.
        /// </summary>
        /// <param name="expression">The DbTreatExpression that is being visited.</param>
        /// <exception cref="ArgumentNullException"><paramref name="expression"/> is null</exception>
        public override void Visit(DbTreatExpression expression)
        {
            VisitUnaryExpression(expression);
        }

        /// <summary>
        /// Visitor pattern method for <see cref="DbCastExpression"/>.
        /// </summary>
        /// <param name="expression">The DbCastExpression that is being visited.</param>
        /// <exception cref="ArgumentNullException"><paramref name="expression"/> is null</exception>
        public override void Visit(DbCastExpression expression)
        {
            VisitUnaryExpression(expression);
        }

        /// <summary>
        /// Visitor pattern method for <see cref="DbIsOfExpression"/>.
        /// </summary>
        /// <param name="expression">The DbIsOfExpression that is being visited.</param>
        /// <exception cref="ArgumentNullException"><paramref name="expression"/> is null</exception>
        public override void Visit(DbIsOfExpression expression)
        {
            VisitUnaryExpression(expression);
        }

        /// <summary>
        /// Visitor pattern method for <see cref="DbCaseExpression"/>.
        /// </summary>
        /// <param name="expression">The DbCaseExpression that is being visited.</param>
        /// <exception cref="ArgumentNullException"><paramref name="expression"/> is null</exception>
        public override void Visit(DbCaseExpression expression)
        {
            // #433613: PreSharp warning 56506: Parameter 'expression' to this public method must be validated: A null-dereference can occur here.
            EntityUtil.CheckArgumentNull(expression, "expression");
            
            VisitExpressionList(expression.When);
            VisitExpressionList(expression.Then);
            VisitExpression(expression.Else);
        }


        /// <summary>
        /// Visitor pattern method for <see cref="DbNewInstanceExpression"/>.
        /// </summary>
        /// <param name="expression">The DbNewInstanceExpression that is being visited.</param>
        /// <exception cref="ArgumentNullException"><paramref name="expression"/> is null</exception>
        public override void Visit(DbNewInstanceExpression expression)
        {
            // #433613: PreSharp warning 56506: Parameter 'expression' to this public method must be validated: A null-dereference can occur here.
            EntityUtil.CheckArgumentNull(expression, "expression");
            VisitExpressionList(expression.Arguments);
            if (expression.HasRelatedEntityReferences)
            {
                Debug.Assert(expression.RelatedEntityReferences != null, "HasRelatedEntityReferences returned true for null RelatedEntityReferences list?");
                this.VisitRelatedEntityReferenceList(expression.RelatedEntityReferences);
            }
        }

        /// <summary>
        /// Visitor pattern method for <see cref="DbRefExpression"/>.
        /// </summary>
        /// <param name="expression">The DbRefExpression that is being visited.</param>
        /// <exception cref="ArgumentNullException"><paramref name="expression"/> is null</exception>
        public override void Visit(DbRefExpression expression)
        {
            VisitUnaryExpression(expression);
        }

        /// <summary>
        /// Visitor pattern method for <see cref="DbRelationshipNavigationExpression"/>.
        /// </summary>
        /// <param name="expression">The DbRelationshipNavigationExpression that is being visited.</param>
        /// <exception cref="ArgumentNullException"><paramref name="expression"/> is null</exception>
        public override void Visit(DbRelationshipNavigationExpression expression)
        {
            // #433613: PreSharp warning 56506: Parameter 'expression' to this public method must be validated: A null-dereference can occur here.
            VisitExpression(EntityUtil.CheckArgumentNull(expression, "expression").NavigationSource);
        }
        
        /// <summary>
        /// Visitor pattern method for <see cref="DbDerefExpression"/>.
        /// </summary>
        /// <param name="expression">The DeRefExpression that is being visited.</param>
        /// <exception cref="ArgumentNullException"><paramref name="expression"/> is null</exception>
        public override void Visit(DbDerefExpression expression)
        {
            VisitUnaryExpression(expression);
        }

        /// <summary>
        /// Visitor pattern method for <see cref="DbRefKeyExpression"/>.
        /// </summary>
        /// <param name="expression">The DbRefKeyExpression that is being visited.</param>
        /// <exception cref="ArgumentNullException"><paramref name="expression"/> is null</exception>
        public override void Visit(DbRefKeyExpression expression)
        {
            VisitUnaryExpression(expression);
        }

        /// <summary>
        /// Visitor pattern method for <see cref="DbEntityRefExpression"/>.
        /// </summary>
        /// <param name="expression">The DbEntityRefExpression that is being visited.</param>
        /// <exception cref="ArgumentNullException"><paramref name="expression"/> is null</exception>
        public override void Visit(DbEntityRefExpression expression)
        {
            VisitUnaryExpression(expression);
        }

        /// <summary>
        /// Visitor pattern method for <see cref="DbScanExpression"/>.
        /// </summary>
        /// <param name="expression">The DbScanExpression that is being visited.</param>
        /// <exception cref="ArgumentNullException"><paramref name="expression"/> is null</exception>
        public override void Visit(DbScanExpression expression)
        {
            // #433613: PreSharp warning 56506: Parameter 'expression' to this public method must be validated: A null-dereference can occur here.
            EntityUtil.CheckArgumentNull(expression, "expression");
        }
                
        /// <summary>
        /// Visitor pattern method for <see cref="DbFilterExpression"/>.
        /// </summary>
        /// <param name="expression">The DbFilterExpression that is being visited.</param>
        /// <exception cref="ArgumentNullException"><paramref name="expression"/> is null</exception>
        public override void Visit(DbFilterExpression expression)
        {
            // #433613: PreSharp warning 56506: Parameter 'expression' to this public method must be validated: A null-dereference can occur here.
            EntityUtil.CheckArgumentNull(expression, "expression");

            VisitExpressionBindingPre(expression.Input);
            VisitExpression(expression.Predicate);
            VisitExpressionBindingPost(expression.Input);
        }

        /// <summary>
        /// Visitor pattern method for <see cref="DbProjectExpression"/>.
        /// </summary>
        /// <param name="expression">The DbProjectExpression that is being visited.</param>
        /// <exception cref="ArgumentNullException"><paramref name="expression"/> is null</exception>
        public override void Visit(DbProjectExpression expression)
        {
            // #433613: PreSharp warning 56506: Parameter 'expression' to this public method must be validated: A null-dereference can occur here.
            EntityUtil.CheckArgumentNull(expression, "expression");

            VisitExpressionBindingPre(expression.Input);
            VisitExpression(expression.Projection);
            VisitExpressionBindingPost(expression.Input);
        }

        /// <summary>
        /// Visitor pattern method for <see cref="DbCrossJoinExpression"/>.
        /// </summary>
        /// <param name="expression">The DbCrossJoinExpression that is being visited.</param>
        /// <exception cref="ArgumentNullException"><paramref name="expression"/> is null</exception>
        public override void Visit(DbCrossJoinExpression expression)
        {
            // #433613: PreSharp warning 56506: Parameter 'expression' to this public method must be validated: A null-dereference can occur here.
            EntityUtil.CheckArgumentNull(expression, "expression");

            foreach (DbExpressionBinding b in expression.Inputs)
            {
                VisitExpressionBindingPre(b);
            }
            
            foreach (DbExpressionBinding b in expression.Inputs)
            {
                VisitExpressionBindingPost(b);
            }
        }

        /// <summary>
        /// Visitor pattern method for <see cref="DbJoinExpression"/>.
        /// </summary>
        /// <param name="expression">The DbJoinExpression that is being visited.</param>
        /// <exception cref="ArgumentNullException"><paramref name="expression"/> is null</exception>
        public override void Visit(DbJoinExpression expression)
        {
            // #433613: PreSharp warning 56506: Parameter 'expression' to this public method must be validated: A null-dereference can occur here.
            EntityUtil.CheckArgumentNull(expression, "expression");

            VisitExpressionBindingPre(expression.Left);
            VisitExpressionBindingPre(expression.Right);

            VisitExpression(expression.JoinCondition);

            VisitExpressionBindingPost(expression.Left);
            VisitExpressionBindingPost(expression.Right);
        }

        /// <summary>
        /// Visitor pattern method for <see cref="DbApplyExpression"/>.
        /// </summary>
        /// <param name="expression">The DbApplyExpression that is being visited.</param>
        /// <exception cref="ArgumentNullException"><paramref name="expression"/> is null</exception>
        public override void Visit(DbApplyExpression expression)
        {
            // #433613: PreSharp warning 56506: Parameter 'expression' to this public method must be validated: A null-dereference can occur here.
            EntityUtil.CheckArgumentNull(expression, "expression");

            VisitExpressionBindingPre(expression.Input);

            // #433613: PreSharp warning 56506: Parameter 'expression.Apply' to this public method must be validated: A null-dereference can occur here.
            if (expression.Apply != null)
            {
                VisitExpression(expression.Apply.Expression);
            }

            VisitExpressionBindingPost(expression.Input);
        }

        /// <summary>
        /// Visitor pattern method for <see cref="DbGroupByExpression"/>.
        /// </summary>
        /// <param name="expression">The DbExpression that is being visited.</param>
        /// <exception cref="ArgumentNullException"><paramref name="expression"/> is null</exception>
        public override void Visit(DbGroupByExpression expression)
        {
            // #433613: PreSharp warning 56506: Parameter 'expression' to this public method must be validated: A null-dereference can occur here.
            EntityUtil.CheckArgumentNull(expression, "expression");

            VisitGroupExpressionBindingPre(expression.Input);
            VisitExpressionList(expression.Keys);
            VisitGroupExpressionBindingMid(expression.Input);
            VisitAggregateList(expression.Aggregates);
            VisitGroupExpressionBindingPost(expression.Input);            
        }

        /// <summary>
        /// Visitor pattern method for <see cref="DbSkipExpression"/>.
        /// </summary>
        /// <param name="expression">The DbSkipExpression that is being visited.</param>
        /// <exception cref="ArgumentNullException"><paramref name="expression"/> is null</exception>
        public override void Visit(DbSkipExpression expression)
        {
            // #433613: PreSharp warning 56506: Parameter 'expression' to this public method must be validated: A null-dereference can occur here.
            EntityUtil.CheckArgumentNull(expression, "expression");

            VisitExpressionBindingPre(expression.Input);
            foreach (DbSortClause sortKey in expression.SortOrder)
            {
                VisitExpression(sortKey.Expression);
            }
            VisitExpressionBindingPost(expression.Input);
            VisitExpression(expression.Count);
        }

        /// <summary>
        /// Visitor pattern method for <see cref="DbSortExpression"/>.
        /// </summary>
        /// <param name="expression">The DbSortExpression that is being visited.</param>
        /// <exception cref="ArgumentNullException"><paramref name="expression"/> is null</exception>
        public override void Visit(DbSortExpression expression)
        {
            // #433613: PreSharp warning 56506: Parameter 'expression' to this public method must be validated: A null-dereference can occur here.
            EntityUtil.CheckArgumentNull(expression, "expression");

            VisitExpressionBindingPre(expression.Input);
            for(int idx = 0; idx < expression.SortOrder.Count; idx++)
            {
                VisitExpression(expression.SortOrder[idx].Expression);
            }
            VisitExpressionBindingPost(expression.Input);
        }

        /// <summary>
        /// Visitor pattern method for <see cref="DbQuantifierExpression"/>.
        /// </summary>
        /// <param name="expression">The DbQuantifierExpression that is being visited.</param>
        /// <exception cref="ArgumentNullException"><paramref name="expression"/> is null</exception>
        public override void Visit(DbQuantifierExpression expression)
        {
            // #433613: PreSharp warning 56506: Parameter 'expression' to this public method must be validated: A null-dereference can occur here.
            EntityUtil.CheckArgumentNull(expression, "expression");

            VisitExpressionBindingPre(expression.Input);
            VisitExpression(expression.Predicate);
            VisitExpressionBindingPost(expression.Input);
        }
        #endregion
    }
}