Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DLinq / Dlinq / SqlClient / Query / SimpleExpression.cs / 1305376 / SimpleExpression.cs
using System; using System.Collections.Generic; using System.Linq.Expressions; using System.Reflection; using System.Data.Linq; using System.Data.Linq.Mapping; using System.Data.Linq.Provider; using System.Linq; using System.Data.Linq.SqlClient; using System.Diagnostics.CodeAnalysis; namespace System.Data.Linq.SqlClient { ////// Determines whether an expression is simple or not. /// Simple is a scalar expression that contains only functions, operators and column references /// internal static class SimpleExpression { internal static bool IsSimple(SqlExpression expr) { Visitor v = new Visitor(); v.Visit(expr); return v.IsSimple; } class Visitor : SqlVisitor { bool isSimple = true; internal bool IsSimple { get { return this.isSimple; } } [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity", Justification = "These issues are related to our use of if-then and case statements for node types, which adds to the complexity count however when reviewed they are easy to navigate and understand.")] internal override SqlNode Visit(SqlNode node) { if (node == null) { return null; } if (!this.isSimple) { return node; } switch (node.NodeType) { case SqlNodeType.Not: case SqlNodeType.Not2V: case SqlNodeType.Negate: case SqlNodeType.BitNot: case SqlNodeType.IsNull: case SqlNodeType.IsNotNull: case SqlNodeType.ValueOf: case SqlNodeType.OuterJoinedValue: case SqlNodeType.ClrLength: case SqlNodeType.Add: case SqlNodeType.Sub: case SqlNodeType.Mul: case SqlNodeType.Div: case SqlNodeType.Mod: case SqlNodeType.BitAnd: case SqlNodeType.BitOr: case SqlNodeType.BitXor: case SqlNodeType.And: case SqlNodeType.Or: case SqlNodeType.GE: case SqlNodeType.GT: case SqlNodeType.LE: case SqlNodeType.LT: case SqlNodeType.EQ: case SqlNodeType.NE: case SqlNodeType.EQ2V: case SqlNodeType.NE2V: case SqlNodeType.Between: case SqlNodeType.Concat: case SqlNodeType.Convert: case SqlNodeType.Treat: case SqlNodeType.Member: case SqlNodeType.TypeCase: case SqlNodeType.SearchedCase: case SqlNodeType.SimpleCase: case SqlNodeType.Like: case SqlNodeType.FunctionCall: case SqlNodeType.ExprSet: case SqlNodeType.OptionalValue: case SqlNodeType.Parameter: case SqlNodeType.ColumnRef: case SqlNodeType.Value: case SqlNodeType.Variable: return base.Visit(node); case SqlNodeType.Column: case SqlNodeType.ClientCase: case SqlNodeType.DiscriminatedType: case SqlNodeType.Link: case SqlNodeType.Row: case SqlNodeType.UserQuery: case SqlNodeType.StoredProcedureCall: case SqlNodeType.UserRow: case SqlNodeType.UserColumn: case SqlNodeType.Multiset: case SqlNodeType.ScalarSubSelect: case SqlNodeType.Element: case SqlNodeType.Exists: case SqlNodeType.Join: case SqlNodeType.Select: case SqlNodeType.New: case SqlNodeType.ClientQuery: case SqlNodeType.ClientArray: case SqlNodeType.Insert: case SqlNodeType.Update: case SqlNodeType.Delete: case SqlNodeType.MemberAssign: case SqlNodeType.Assign: case SqlNodeType.Block: case SqlNodeType.Union: case SqlNodeType.DoNotVisit: case SqlNodeType.MethodCall: case SqlNodeType.Nop: default: this.isSimple = false; return node; } } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. using System; using System.Collections.Generic; using System.Linq.Expressions; using System.Reflection; using System.Data.Linq; using System.Data.Linq.Mapping; using System.Data.Linq.Provider; using System.Linq; using System.Data.Linq.SqlClient; using System.Diagnostics.CodeAnalysis; namespace System.Data.Linq.SqlClient { ////// Determines whether an expression is simple or not. /// Simple is a scalar expression that contains only functions, operators and column references /// internal static class SimpleExpression { internal static bool IsSimple(SqlExpression expr) { Visitor v = new Visitor(); v.Visit(expr); return v.IsSimple; } class Visitor : SqlVisitor { bool isSimple = true; internal bool IsSimple { get { return this.isSimple; } } [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity", Justification = "These issues are related to our use of if-then and case statements for node types, which adds to the complexity count however when reviewed they are easy to navigate and understand.")] internal override SqlNode Visit(SqlNode node) { if (node == null) { return null; } if (!this.isSimple) { return node; } switch (node.NodeType) { case SqlNodeType.Not: case SqlNodeType.Not2V: case SqlNodeType.Negate: case SqlNodeType.BitNot: case SqlNodeType.IsNull: case SqlNodeType.IsNotNull: case SqlNodeType.ValueOf: case SqlNodeType.OuterJoinedValue: case SqlNodeType.ClrLength: case SqlNodeType.Add: case SqlNodeType.Sub: case SqlNodeType.Mul: case SqlNodeType.Div: case SqlNodeType.Mod: case SqlNodeType.BitAnd: case SqlNodeType.BitOr: case SqlNodeType.BitXor: case SqlNodeType.And: case SqlNodeType.Or: case SqlNodeType.GE: case SqlNodeType.GT: case SqlNodeType.LE: case SqlNodeType.LT: case SqlNodeType.EQ: case SqlNodeType.NE: case SqlNodeType.EQ2V: case SqlNodeType.NE2V: case SqlNodeType.Between: case SqlNodeType.Concat: case SqlNodeType.Convert: case SqlNodeType.Treat: case SqlNodeType.Member: case SqlNodeType.TypeCase: case SqlNodeType.SearchedCase: case SqlNodeType.SimpleCase: case SqlNodeType.Like: case SqlNodeType.FunctionCall: case SqlNodeType.ExprSet: case SqlNodeType.OptionalValue: case SqlNodeType.Parameter: case SqlNodeType.ColumnRef: case SqlNodeType.Value: case SqlNodeType.Variable: return base.Visit(node); case SqlNodeType.Column: case SqlNodeType.ClientCase: case SqlNodeType.DiscriminatedType: case SqlNodeType.Link: case SqlNodeType.Row: case SqlNodeType.UserQuery: case SqlNodeType.StoredProcedureCall: case SqlNodeType.UserRow: case SqlNodeType.UserColumn: case SqlNodeType.Multiset: case SqlNodeType.ScalarSubSelect: case SqlNodeType.Element: case SqlNodeType.Exists: case SqlNodeType.Join: case SqlNodeType.Select: case SqlNodeType.New: case SqlNodeType.ClientQuery: case SqlNodeType.ClientArray: case SqlNodeType.Insert: case SqlNodeType.Update: case SqlNodeType.Delete: case SqlNodeType.MemberAssign: case SqlNodeType.Assign: case SqlNodeType.Block: case SqlNodeType.Union: case SqlNodeType.DoNotVisit: case SqlNodeType.MethodCall: case SqlNodeType.Nop: default: this.isSimple = false; return node; } } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
![Network programming in C#, Network Programming in VB.NET, Network Programming in .NET](/images/book.jpg)
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- PrintPreviewGraphics.cs
- Column.cs
- StyleHelper.cs
- ComponentChangedEvent.cs
- ConditionalAttribute.cs
- Durable.cs
- Marshal.cs
- HtmlInputRadioButton.cs
- LinkedResourceCollection.cs
- StringUtil.cs
- HtmlInputRadioButton.cs
- BitmapImage.cs
- ObjectStateEntryDbUpdatableDataRecord.cs
- CaseInsensitiveComparer.cs
- ProtocolReflector.cs
- VoiceChangeEventArgs.cs
- HtmlHead.cs
- MatrixIndependentAnimationStorage.cs
- UpdateManifestForBrowserApplication.cs
- DatePicker.cs
- SpellCheck.cs
- RichTextBox.cs
- CookieProtection.cs
- InfoCardCryptoHelper.cs
- SharedMemory.cs
- SoapElementAttribute.cs
- SafeLocalMemHandle.cs
- DependencyProperty.cs
- DocumentCollection.cs
- AdRotator.cs
- FontWeights.cs
- ReferentialConstraint.cs
- WindowVisualStateTracker.cs
- TypeHelpers.cs
- shaperfactory.cs
- ReadOnlyDictionary.cs
- MappingMetadataHelper.cs
- WebEvents.cs
- IPipelineRuntime.cs
- FileDialogCustomPlacesCollection.cs
- TaskScheduler.cs
- COM2PictureConverter.cs
- Win32KeyboardDevice.cs
- StateMachineHistory.cs
- ExtenderProvidedPropertyAttribute.cs
- UITypeEditor.cs
- HttpListenerResponse.cs
- _Win32.cs
- StringDictionary.cs
- SchemaImporterExtension.cs
- ControlValuePropertyAttribute.cs
- XmlLinkedNode.cs
- XmlUnspecifiedAttribute.cs
- QueryResult.cs
- AsymmetricCryptoHandle.cs
- CodeThrowExceptionStatement.cs
- CqlErrorHelper.cs
- SQLMembershipProvider.cs
- VariantWrapper.cs
- wgx_render.cs
- DataRelation.cs
- DbInsertCommandTree.cs
- backend.cs
- XmlSchemaChoice.cs
- UnsafeNativeMethodsPenimc.cs
- DataGridViewRowCancelEventArgs.cs
- WebHttpDispatchOperationSelectorData.cs
- ContentTypeSettingDispatchMessageFormatter.cs
- DiscoveryDefaults.cs
- ToolbarAUtomationPeer.cs
- TabletCollection.cs
- UriTemplateVariableQueryValue.cs
- Byte.cs
- PKCS1MaskGenerationMethod.cs
- DataGridViewCellEventArgs.cs
- SamlEvidence.cs
- RoutedUICommand.cs
- DataGridViewCellStyleChangedEventArgs.cs
- Relationship.cs
- TCEAdapterGenerator.cs
- BaseValidator.cs
- WorkflowLayouts.cs
- EntityContainerAssociationSetEnd.cs
- EdmSchemaAttribute.cs
- ClipboardData.cs
- FrameworkContextData.cs
- AppliedDeviceFiltersDialog.cs
- HitTestWithGeometryDrawingContextWalker.cs
- WindowsRegion.cs
- EventDescriptor.cs
- Blend.cs
- InstalledFontCollection.cs
- ObjectStateEntryOriginalDbUpdatableDataRecord.cs
- DocumentXPathNavigator.cs
- RouteValueDictionary.cs
- FileLoadException.cs
- FontWeights.cs
- PageParser.cs
- WindowsEditBox.cs
- Code.cs