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
- MaterialGroup.cs
- RegistrationServices.cs
- CallContext.cs
- Listbox.cs
- ByteKeyFrameCollection.cs
- TemplateLookupAction.cs
- DecimalConverter.cs
- TextDecorations.cs
- OutKeywords.cs
- Random.cs
- FlowLayoutPanel.cs
- ManagementExtension.cs
- CompensableActivity.cs
- SiteMapNodeCollection.cs
- DataGridColumnFloatingHeader.cs
- Subtree.cs
- UIInitializationException.cs
- ApplicationException.cs
- DataGridViewButtonCell.cs
- EnumValAlphaComparer.cs
- AppLevelCompilationSectionCache.cs
- ValueOfAction.cs
- Switch.cs
- NameTable.cs
- StaticFileHandler.cs
- Memoizer.cs
- Matrix3D.cs
- WCFServiceClientProxyGenerator.cs
- Wizard.cs
- Freezable.cs
- InfoCardXmlSerializer.cs
- HyperLinkField.cs
- DataObjectFieldAttribute.cs
- UserMapPath.cs
- AsymmetricKeyExchangeDeformatter.cs
- EditorZone.cs
- LogicalMethodInfo.cs
- UnmanagedMemoryStream.cs
- ClientTargetCollection.cs
- WpfKnownMemberInvoker.cs
- DragCompletedEventArgs.cs
- SplineQuaternionKeyFrame.cs
- InlineCollection.cs
- XsltConvert.cs
- AuthorizationRuleCollection.cs
- DependencyPropertyValueSerializer.cs
- SchemaCollectionPreprocessor.cs
- LinkConverter.cs
- XmlSyndicationContent.cs
- Attributes.cs
- UnsafeNativeMethods.cs
- MobileListItemCollection.cs
- BinHexEncoder.cs
- DynamicScriptObject.cs
- XmlElementAttributes.cs
- WeakReferenceList.cs
- IsolatedStorageFilePermission.cs
- CngKeyBlobFormat.cs
- BitStack.cs
- TimeSpanMinutesOrInfiniteConverter.cs
- SortedSetDebugView.cs
- EventSchemaTraceListener.cs
- Types.cs
- Panel.cs
- MetadataFile.cs
- EntityDataSourceView.cs
- ToolBar.cs
- DragDrop.cs
- COMException.cs
- ReachDocumentReferenceSerializerAsync.cs
- SoapIncludeAttribute.cs
- ChtmlTextBoxAdapter.cs
- CodeCatchClauseCollection.cs
- MobileControlsSection.cs
- HitTestWithPointDrawingContextWalker.cs
- IdnElement.cs
- CalendarTable.cs
- BitmapEffectInputConnector.cs
- WebCodeGenerator.cs
- VersionedStreamOwner.cs
- ApplicationServiceHelper.cs
- WindowsGraphics.cs
- QueryableFilterRepeater.cs
- InternalsVisibleToAttribute.cs
- StringArrayConverter.cs
- ElementFactory.cs
- IfAction.cs
- KnownIds.cs
- SoapHeaderAttribute.cs
- InteropAutomationProvider.cs
- PrincipalPermissionMode.cs
- ModelTreeManager.cs
- XPathDocumentBuilder.cs
- ToolstripProfessionalRenderer.cs
- DataGridViewColumnDividerDoubleClickEventArgs.cs
- SqlGatherProducedAliases.cs
- ScriptMethodAttribute.cs
- PagePropertiesChangingEventArgs.cs
- PenThread.cs
- PropertyTabChangedEvent.cs