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
- CompiledXpathExpr.cs
- QueryConverter.cs
- XPathNodeInfoAtom.cs
- clipboard.cs
- XmlAutoDetectWriter.cs
- MessageTraceRecord.cs
- RuleCache.cs
- Message.cs
- ProjectionCamera.cs
- HtmlInputRadioButton.cs
- WorkflowMarkupSerializationProvider.cs
- odbcmetadatafactory.cs
- FamilyMap.cs
- SQLCharsStorage.cs
- PersonalizationStateInfo.cs
- XmlCharacterData.cs
- RuntimeTransactionHandle.cs
- UndoManager.cs
- CrossContextChannel.cs
- ServiceModelConfigurationSectionCollection.cs
- ComponentResourceManager.cs
- MenuItem.cs
- XslAst.cs
- ListViewEditEventArgs.cs
- MissingSatelliteAssemblyException.cs
- MethodBuilder.cs
- MappingSource.cs
- XmlSerializationGeneratedCode.cs
- Substitution.cs
- StatusBarItemAutomationPeer.cs
- GridViewColumnCollection.cs
- FileEnumerator.cs
- EncoderFallback.cs
- SiteMapDataSourceView.cs
- BitmapData.cs
- EventLogInternal.cs
- SelectedDatesCollection.cs
- PropertyInfoSet.cs
- DataGridHelper.cs
- Rectangle.cs
- NullableIntAverageAggregationOperator.cs
- HostingEnvironmentException.cs
- AspNetCompatibilityRequirementsMode.cs
- ProfilePropertySettingsCollection.cs
- MdImport.cs
- TagPrefixInfo.cs
- SimpleBitVector32.cs
- SystemFonts.cs
- DesignerTextViewAdapter.cs
- SignatureResourceHelper.cs
- ToolStripSeparatorRenderEventArgs.cs
- MethodCallConverter.cs
- IndentedTextWriter.cs
- ConditionalDesigner.cs
- DataGridDefaultColumnWidthTypeConverter.cs
- CodeBinaryOperatorExpression.cs
- TransferRequestHandler.cs
- WebPartTransformerAttribute.cs
- MobileControlBuilder.cs
- ListControl.cs
- PopupRootAutomationPeer.cs
- basenumberconverter.cs
- HandleCollector.cs
- Calendar.cs
- CodeArgumentReferenceExpression.cs
- MILUtilities.cs
- PlatformNotSupportedException.cs
- BamlReader.cs
- ApplicationException.cs
- ReservationCollection.cs
- EdmEntityTypeAttribute.cs
- RadioButtonBaseAdapter.cs
- ProvidersHelper.cs
- FontFaceLayoutInfo.cs
- DesignerLoader.cs
- DataBindingCollectionEditor.cs
- QuadraticBezierSegment.cs
- Control.cs
- UInt32Storage.cs
- CodeLinePragma.cs
- ForEachAction.cs
- BitmapSourceSafeMILHandle.cs
- ConnectionProviderAttribute.cs
- TabItemAutomationPeer.cs
- WebPartPersonalization.cs
- ReadOnlyAttribute.cs
- UrlAuthFailedErrorFormatter.cs
- InputProviderSite.cs
- BitmapFrameDecode.cs
- handlecollector.cs
- RadioButtonStandardAdapter.cs
- FontSource.cs
- LocalFileSettingsProvider.cs
- AppliedDeviceFiltersDialog.cs
- TransformationRules.cs
- XamlPoint3DCollectionSerializer.cs
- TypeName.cs
- ServiceMoniker.cs
- EventListener.cs
- FusionWrap.cs