Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / ndp / fx / src / DLinq / Dlinq / SqlClient / Query / ContainsRowNumberChecker.cs / 1 / ContainsRowNumberChecker.cs
using System; using System.Collections.Generic; using System.Text; namespace System.Data.Linq.SqlClient { internal class SqlRowNumberChecker { Visitor rowNumberVisitor; internal SqlRowNumberChecker() { this.rowNumberVisitor = new Visitor(); } internal bool HasRowNumber(SqlNode node) { this.rowNumberVisitor.Visit(node); return rowNumberVisitor.HasRowNumber; } internal bool HasRowNumber(SqlRow row) { foreach (SqlColumn column in row.Columns) { if (this.HasRowNumber(column)) { return true; } } return false; } internal SqlColumn RowNumberColumn { get { return rowNumberVisitor.HasRowNumber ? rowNumberVisitor.CurrentColumn : null; } } private class Visitor: SqlVisitor { bool hasRowNumber = false; public bool HasRowNumber { get { return hasRowNumber; } } public SqlColumn CurrentColumn { private set; get; } internal override SqlRowNumber VisitRowNumber(SqlRowNumber rowNumber) { this.hasRowNumber = true; return rowNumber; } // shortcuts internal override SqlExpression VisitScalarSubSelect(SqlSubSelect ss) { return ss; } internal override SqlExpression VisitSubSelect(SqlSubSelect ss) { return ss; } internal override SqlRow VisitRow(SqlRow row) { for (int i = 0, n = row.Columns.Count; i < n; i++) { row.Columns[i].Expression = this.VisitExpression(row.Columns[i].Expression); if (this.hasRowNumber) { this.CurrentColumn = row.Columns[i]; break; } } return row; } internal override SqlSelect VisitSelect(SqlSelect select) { this.Visit(select.Row); this.Visit(select.Where); return select; } } } } // 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.Text; namespace System.Data.Linq.SqlClient { internal class SqlRowNumberChecker { Visitor rowNumberVisitor; internal SqlRowNumberChecker() { this.rowNumberVisitor = new Visitor(); } internal bool HasRowNumber(SqlNode node) { this.rowNumberVisitor.Visit(node); return rowNumberVisitor.HasRowNumber; } internal bool HasRowNumber(SqlRow row) { foreach (SqlColumn column in row.Columns) { if (this.HasRowNumber(column)) { return true; } } return false; } internal SqlColumn RowNumberColumn { get { return rowNumberVisitor.HasRowNumber ? rowNumberVisitor.CurrentColumn : null; } } private class Visitor: SqlVisitor { bool hasRowNumber = false; public bool HasRowNumber { get { return hasRowNumber; } } public SqlColumn CurrentColumn { private set; get; } internal override SqlRowNumber VisitRowNumber(SqlRowNumber rowNumber) { this.hasRowNumber = true; return rowNumber; } // shortcuts internal override SqlExpression VisitScalarSubSelect(SqlSubSelect ss) { return ss; } internal override SqlExpression VisitSubSelect(SqlSubSelect ss) { return ss; } internal override SqlRow VisitRow(SqlRow row) { for (int i = 0, n = row.Columns.Count; i < n; i++) { row.Columns[i].Expression = this.VisitExpression(row.Columns[i].Expression); if (this.hasRowNumber) { this.CurrentColumn = row.Columns[i]; break; } } return row; } internal override SqlSelect VisitSelect(SqlSelect select) { this.Visit(select.Row); this.Visit(select.Where); return select; } } } } // 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
- ObjectItemCollection.cs
- DesignerActionPropertyItem.cs
- TraceHandler.cs
- MemberRelationshipService.cs
- TreeViewItemAutomationPeer.cs
- WMIInterop.cs
- HtmlLink.cs
- XmlSchemaGroupRef.cs
- InvalidOperationException.cs
- BinaryFormatter.cs
- LowerCaseStringConverter.cs
- DataGridViewCellMouseEventArgs.cs
- PatternMatcher.cs
- ListViewHitTestInfo.cs
- OdbcFactory.cs
- PropertyConverter.cs
- precedingsibling.cs
- DoubleKeyFrameCollection.cs
- CatalogPart.cs
- _IPv6Address.cs
- ConfigXmlText.cs
- PathFigureCollectionConverter.cs
- CatchDesigner.xaml.cs
- M3DUtil.cs
- FileNotFoundException.cs
- SessionEndedEventArgs.cs
- SplineQuaternionKeyFrame.cs
- ImportCatalogPart.cs
- ColumnReorderedEventArgs.cs
- SqlDataSourceStatusEventArgs.cs
- DesignerRegionCollection.cs
- TextPenaltyModule.cs
- invalidudtexception.cs
- Section.cs
- SpinLock.cs
- XmlElementAttribute.cs
- WhitespaceSignificantCollectionAttribute.cs
- TypeDescriptionProviderAttribute.cs
- SoapIncludeAttribute.cs
- TitleStyle.cs
- RotateTransform.cs
- EtwTrace.cs
- Query.cs
- IIS7WorkerRequest.cs
- DocumentOrderComparer.cs
- RemoteHelper.cs
- XsltContext.cs
- KeyConstraint.cs
- AssemblyInfo.cs
- Stack.cs
- AttributeCollection.cs
- PropertyValue.cs
- ForeignConstraint.cs
- WebPartCollection.cs
- GraphicsState.cs
- MasterPage.cs
- XamlInt32CollectionSerializer.cs
- GenericEnumerator.cs
- PeerNeighborManager.cs
- ProfessionalColorTable.cs
- ItemCheckedEvent.cs
- DataGridPagerStyle.cs
- X509Certificate2Collection.cs
- DecoderFallback.cs
- SerializationSectionGroup.cs
- If.cs
- TypeSystem.cs
- HttpRequestTraceRecord.cs
- RequestResizeEvent.cs
- PageSetupDialog.cs
- IChannel.cs
- CodeExporter.cs
- ExecutionContext.cs
- ResolvedKeyFrameEntry.cs
- UnaryExpressionHelper.cs
- SqlCacheDependencyDatabase.cs
- FrameworkContextData.cs
- Pkcs7Signer.cs
- XmlRootAttribute.cs
- ScriptingRoleServiceSection.cs
- TdsEnums.cs
- PackWebResponse.cs
- HostExecutionContextManager.cs
- FieldToken.cs
- ResolveNameEventArgs.cs
- WindowCollection.cs
- CapabilitiesPattern.cs
- TreeIterator.cs
- contentDescriptor.cs
- StorageMappingFragment.cs
- HttpCapabilitiesEvaluator.cs
- EndpointDiscoveryMetadataCD1.cs
- NonSerializedAttribute.cs
- RadialGradientBrush.cs
- ProcessInfo.cs
- ThreadNeutralSemaphore.cs
- CalendarBlackoutDatesCollection.cs
- SubpageParaClient.cs
- KeyEventArgs.cs
- LineUtil.cs