Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / ndp / fx / src / DLinq / Dlinq / SqlClient / Query / SqlRewriteScalarSubqueries.cs / 1 / SqlRewriteScalarSubqueries.cs
using System; using System.Collections.Generic; using System.Linq.Expressions; using System.Data.Linq; namespace System.Data.Linq.SqlClient { // converts correlated scalar subqueries into outer-applies // must be run after flattener. internal class SqlRewriteScalarSubqueries { Visitor visitor; internal SqlRewriteScalarSubqueries(SqlFactory sqlFactory) { this.visitor = new Visitor(sqlFactory); } internal SqlNode Rewrite(SqlNode node) { return this.visitor.Visit(node); } class Visitor : SqlVisitor { SqlFactory sql; SqlSelect currentSelect; SqlAggregateChecker aggregateChecker; internal Visitor(SqlFactory sqlFactory) { this.sql = sqlFactory; this.aggregateChecker = new SqlAggregateChecker(); } internal override SqlExpression VisitScalarSubSelect(SqlSubSelect ss) { SqlSelect innerSelect = this.VisitSelect(ss.Select); if (!this.aggregateChecker.HasAggregates(innerSelect)) { innerSelect.Top = this.sql.ValueFromObject(1, ss.SourceExpression); } innerSelect.OrderingType = SqlOrderingType.Blocked; SqlAlias alias = new SqlAlias(innerSelect); this.currentSelect.From = new SqlJoin(SqlJoinType.OuterApply, this.currentSelect.From, alias, null, ss.SourceExpression); return new SqlColumnRef(innerSelect.Row.Columns[0]); } internal override SqlSelect VisitSelect(SqlSelect select) { SqlSelect save = this.currentSelect; try { this.currentSelect = select; return base.VisitSelect(select); } finally { this.currentSelect = save; } } } } } // 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 { // converts correlated scalar subqueries into outer-applies // must be run after flattener. internal class SqlRewriteScalarSubqueries { Visitor visitor; internal SqlRewriteScalarSubqueries(SqlFactory sqlFactory) { this.visitor = new Visitor(sqlFactory); } internal SqlNode Rewrite(SqlNode node) { return this.visitor.Visit(node); } class Visitor : SqlVisitor { SqlFactory sql; SqlSelect currentSelect; SqlAggregateChecker aggregateChecker; internal Visitor(SqlFactory sqlFactory) { this.sql = sqlFactory; this.aggregateChecker = new SqlAggregateChecker(); } internal override SqlExpression VisitScalarSubSelect(SqlSubSelect ss) { SqlSelect innerSelect = this.VisitSelect(ss.Select); if (!this.aggregateChecker.HasAggregates(innerSelect)) { innerSelect.Top = this.sql.ValueFromObject(1, ss.SourceExpression); } innerSelect.OrderingType = SqlOrderingType.Blocked; SqlAlias alias = new SqlAlias(innerSelect); this.currentSelect.From = new SqlJoin(SqlJoinType.OuterApply, this.currentSelect.From, alias, null, ss.SourceExpression); return new SqlColumnRef(innerSelect.Row.Columns[0]); } internal override SqlSelect VisitSelect(SqlSelect select) { SqlSelect save = this.currentSelect; try { this.currentSelect = select; return base.VisitSelect(select); } finally { this.currentSelect = save; } } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
![Network programming in C#, Network Programming in VB.NET, Network Programming in .NET](/images/book.jpg)
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DataPagerField.cs
- Cursor.cs
- QilFunction.cs
- DiscreteKeyFrames.cs
- AsymmetricAlgorithm.cs
- ProviderException.cs
- CompoundFileDeflateTransform.cs
- AddInAttribute.cs
- StrokeIntersection.cs
- LineGeometry.cs
- Roles.cs
- StringSource.cs
- CodeTryCatchFinallyStatement.cs
- WindowClosedEventArgs.cs
- ManagementObject.cs
- FunctionQuery.cs
- TreeViewItemAutomationPeer.cs
- UnsafeNativeMethodsPenimc.cs
- AttachedAnnotation.cs
- Property.cs
- XmlSequenceWriter.cs
- BooleanExpr.cs
- XmlElementList.cs
- ErrorRuntimeConfig.cs
- TextPointer.cs
- securestring.cs
- TabPageDesigner.cs
- HttpCapabilitiesSectionHandler.cs
- BatchStream.cs
- ValidationHelper.cs
- RepeatBehaviorConverter.cs
- CodeVariableReferenceExpression.cs
- TemplateControlCodeDomTreeGenerator.cs
- RowVisual.cs
- CodeSnippetExpression.cs
- KnownColorTable.cs
- CngKey.cs
- ConfigurationStrings.cs
- SurrogateEncoder.cs
- DtdParser.cs
- ManifestSignatureInformation.cs
- DrawingAttributeSerializer.cs
- Activator.cs
- LayoutTableCell.cs
- JsonWriter.cs
- SessionStateModule.cs
- GenericPrincipal.cs
- DisableDpiAwarenessAttribute.cs
- CodeDelegateInvokeExpression.cs
- SecondaryViewProvider.cs
- WebEvents.cs
- ClientWindowsAuthenticationMembershipProvider.cs
- WebPartActionVerb.cs
- TextParaLineResult.cs
- EncodingDataItem.cs
- SizeConverter.cs
- FixedSOMPageElement.cs
- Mouse.cs
- FunctionCommandText.cs
- ListParaClient.cs
- WebPartRestoreVerb.cs
- Point.cs
- XmlDataCollection.cs
- SplitterEvent.cs
- ListViewUpdateEventArgs.cs
- COAUTHIDENTITY.cs
- HtmlTable.cs
- ThrowHelper.cs
- ExecutionEngineException.cs
- Viewport3DVisual.cs
- PixelFormats.cs
- LateBoundBitmapDecoder.cs
- CorrelationTokenInvalidatedHandler.cs
- CollectionViewSource.cs
- Executor.cs
- AggregationMinMaxHelpers.cs
- FirstQueryOperator.cs
- BuildManagerHost.cs
- AttributeQuery.cs
- TranslateTransform.cs
- DataSourceControlBuilder.cs
- ContourSegment.cs
- FileAuthorizationModule.cs
- ParsedAttributeCollection.cs
- DefaultValueAttribute.cs
- DynamicValidatorEventArgs.cs
- LocatorManager.cs
- NameValueConfigurationElement.cs
- LayoutSettings.cs
- ResourceCollectionInfo.cs
- PngBitmapEncoder.cs
- XPathPatternBuilder.cs
- SimpleHandlerBuildProvider.cs
- PopupRootAutomationPeer.cs
- StorageInfo.cs
- RequestTimeoutManager.cs
- DispatcherObject.cs
- EventProvider.cs
- TransactionsSectionGroup.cs
- CaseStatementProjectedSlot.cs