Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DLinq / Dlinq / SqlClient / Query / SqlAggregateChecker.cs / 1305376 / SqlAggregateChecker.cs
using System; using System.Collections.Generic; using System.Linq.Expressions; using System.Data.Linq; namespace System.Data.Linq.SqlClient { internal class SqlAggregateChecker { Visitor visitor; internal SqlAggregateChecker() { this.visitor = new Visitor(); } internal bool HasAggregates(SqlNode node) { visitor.hasAggregates = false; visitor.Visit(node); return visitor.hasAggregates; } class Visitor : SqlVisitor { internal bool hasAggregates; internal Visitor() { } internal override SqlExpression VisitSubSelect(SqlSubSelect ss) { return ss; } internal override SqlSource VisitSource(SqlSource source) { return source; } internal override SqlExpression VisitUnaryOperator(SqlUnary uo) { switch (uo.NodeType) { case SqlNodeType.Min: case SqlNodeType.Max: case SqlNodeType.Avg: case SqlNodeType.Sum: case SqlNodeType.Count: case SqlNodeType.LongCount: this.hasAggregates = true; return uo; default: return base.VisitUnaryOperator(uo); } } } } } // 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.Data.Linq; namespace System.Data.Linq.SqlClient { internal class SqlAggregateChecker { Visitor visitor; internal SqlAggregateChecker() { this.visitor = new Visitor(); } internal bool HasAggregates(SqlNode node) { visitor.hasAggregates = false; visitor.Visit(node); return visitor.hasAggregates; } class Visitor : SqlVisitor { internal bool hasAggregates; internal Visitor() { } internal override SqlExpression VisitSubSelect(SqlSubSelect ss) { return ss; } internal override SqlSource VisitSource(SqlSource source) { return source; } internal override SqlExpression VisitUnaryOperator(SqlUnary uo) { switch (uo.NodeType) { case SqlNodeType.Min: case SqlNodeType.Max: case SqlNodeType.Avg: case SqlNodeType.Sum: case SqlNodeType.Count: case SqlNodeType.LongCount: this.hasAggregates = true; return uo; default: return base.VisitUnaryOperator(uo); } } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- EntityDataSourceMemberPath.cs
- MyContact.cs
- ProviderConnectionPointCollection.cs
- AppModelKnownContentFactory.cs
- Pkcs9Attribute.cs
- RoleService.cs
- ConsoleKeyInfo.cs
- SortExpressionBuilder.cs
- AnimatedTypeHelpers.cs
- WindowsSecurityToken.cs
- SqlDependency.cs
- CultureTable.cs
- grammarelement.cs
- HtmlControlPersistable.cs
- DirectionalLight.cs
- SqlRecordBuffer.cs
- OracleNumber.cs
- DataSourceCacheDurationConverter.cs
- Overlapped.cs
- ListItemParagraph.cs
- RotateTransform3D.cs
- Section.cs
- ByteStack.cs
- XmlSerializerAssemblyAttribute.cs
- ExpandSegment.cs
- RangeValuePatternIdentifiers.cs
- CqlGenerator.cs
- IISUnsafeMethods.cs
- NativeMethods.cs
- DocComment.cs
- RuntimeResourceSet.cs
- FormViewDeleteEventArgs.cs
- Calendar.cs
- CapabilitiesAssignment.cs
- TrackBarDesigner.cs
- UnionCqlBlock.cs
- BitmapEffect.cs
- StringSource.cs
- control.ime.cs
- ErrorWrapper.cs
- ConfigXmlText.cs
- PerfService.cs
- XLinq.cs
- ManipulationStartedEventArgs.cs
- TreeNodeCollectionEditorDialog.cs
- XPathSingletonIterator.cs
- XmlSerializer.cs
- SettingsPropertyValue.cs
- ToolStripSettings.cs
- AppDomainGrammarProxy.cs
- XmlSchemaNotation.cs
- DBNull.cs
- RequestCacheManager.cs
- XPathNavigatorReader.cs
- AdapterDictionary.cs
- AppDomainProtocolHandler.cs
- DataTableMappingCollection.cs
- ArrayElementGridEntry.cs
- ResourcesBuildProvider.cs
- WindowsListViewItemCheckBox.cs
- IisTraceWebEventProvider.cs
- ConfigErrorGlyph.cs
- ProjectedSlot.cs
- RotateTransform.cs
- AssemblyEvidenceFactory.cs
- SqlDataSource.cs
- Frame.cs
- UrlParameterReader.cs
- Drawing.cs
- TraceListeners.cs
- Scripts.cs
- ProfileGroupSettings.cs
- SQLChars.cs
- ComplexObject.cs
- SqlTypeSystemProvider.cs
- ColumnReorderedEventArgs.cs
- PenThreadWorker.cs
- RelationshipWrapper.cs
- CompositeTypefaceMetrics.cs
- PasswordRecoveryDesigner.cs
- InvocationExpression.cs
- DetailsViewInsertEventArgs.cs
- RevocationPoint.cs
- ButtonBase.cs
- SafeLibraryHandle.cs
- TileModeValidation.cs
- MsmqHostedTransportManager.cs
- FileSystemInfo.cs
- MetadataItemCollectionFactory.cs
- TypeProvider.cs
- cookieexception.cs
- HuffCodec.cs
- RichTextBoxContextMenu.cs
- TreeNodeStyleCollection.cs
- DictionaryMarkupSerializer.cs
- PeerTransportCredentialType.cs
- TableLayoutSettings.cs
- ServiceBuildProvider.cs
- BamlMapTable.cs
- InternalBufferOverflowException.cs