Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DLinq / Dlinq / SqlClient / Query / ContainsRowNumberChecker.cs / 1305376 / 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
- ConstructorNeedsTagAttribute.cs
- Crc32.cs
- GlobalizationAssembly.cs
- DefaultValueTypeConverter.cs
- CryptoStream.cs
- SystemDropShadowChrome.cs
- DataRowCollection.cs
- GlyphShapingProperties.cs
- SslStream.cs
- SiteMapProvider.cs
- DBSchemaRow.cs
- LinkAreaEditor.cs
- TreeViewImageKeyConverter.cs
- VisualBrush.cs
- TraceSource.cs
- PeerObject.cs
- SettingsPropertyValue.cs
- FileDialogCustomPlacesCollection.cs
- FirstQueryOperator.cs
- SqlOuterApplyReducer.cs
- SpotLight.cs
- SAPICategories.cs
- TextSchema.cs
- X509Utils.cs
- ProgressChangedEventArgs.cs
- ClientConfigPaths.cs
- QueueProcessor.cs
- RemoteHelper.cs
- ReflectTypeDescriptionProvider.cs
- EventEntry.cs
- CodeParameterDeclarationExpressionCollection.cs
- StrongNameKeyPair.cs
- LayoutTableCell.cs
- CharStorage.cs
- DoubleLinkListEnumerator.cs
- TextTreeUndoUnit.cs
- FolderNameEditor.cs
- SqlRecordBuffer.cs
- DeviceOverridableAttribute.cs
- KeyGestureValueSerializer.cs
- PopOutPanel.cs
- AutomationEventArgs.cs
- MemoryMappedViewStream.cs
- SqlErrorCollection.cs
- DataTablePropertyDescriptor.cs
- ContextQuery.cs
- RSAOAEPKeyExchangeFormatter.cs
- GridViewCommandEventArgs.cs
- WizardStepBase.cs
- MatrixUtil.cs
- TypeValidationEventArgs.cs
- MemberExpressionHelper.cs
- Attributes.cs
- Normalizer.cs
- DriveNotFoundException.cs
- ListItem.cs
- ColumnHeaderCollectionEditor.cs
- InProcStateClientManager.cs
- AsyncOperation.cs
- ParentUndoUnit.cs
- SymbolEqualComparer.cs
- TextRangeEditLists.cs
- COM2Enum.cs
- AuthenticationModulesSection.cs
- EvidenceBase.cs
- ping.cs
- MDIClient.cs
- ThreadAttributes.cs
- ChangeProcessor.cs
- MessagePartSpecification.cs
- ProjectionPlan.cs
- ApplicationException.cs
- LinkConverter.cs
- TypeExtension.cs
- RequestQueue.cs
- SingleAnimationBase.cs
- FormDocumentDesigner.cs
- FullTrustAssembly.cs
- BlockUIContainer.cs
- Evidence.cs
- ContentPlaceHolder.cs
- AtomicFile.cs
- FieldNameLookup.cs
- remotingproxy.cs
- ClosableStream.cs
- Directory.cs
- StrokeRenderer.cs
- FontDialog.cs
- UriGenerator.cs
- XmlSerializationReader.cs
- UrlPath.cs
- SpellerInterop.cs
- ProviderIncompatibleException.cs
- XmlSchemaAll.cs
- FocusManager.cs
- GeneralTransform3DTo2DTo3D.cs
- ToolStripItem.cs
- SoapUnknownHeader.cs
- Internal.cs
- InvalidOleVariantTypeException.cs