Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DLinq / Dlinq / SqlClient / Query / SqlRewriteScalarSubqueries.cs / 1305376 / 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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- jithelpers.cs
- CapabilitiesState.cs
- GACIdentityPermission.cs
- DrawingGroup.cs
- HwndMouseInputProvider.cs
- Int64Animation.cs
- CodeAssignStatement.cs
- InteropEnvironment.cs
- GeometryDrawing.cs
- WMIGenerator.cs
- WebBrowserNavigatedEventHandler.cs
- SessionEndingCancelEventArgs.cs
- ByteStreamMessageEncodingElement.cs
- ManipulationStartingEventArgs.cs
- X509Certificate2Collection.cs
- ResourceDisplayNameAttribute.cs
- HtmlTable.cs
- DateTimeSerializationSection.cs
- RawStylusInputReport.cs
- ClosableStream.cs
- ContextMenu.cs
- TreeIterator.cs
- BindingNavigator.cs
- NeutralResourcesLanguageAttribute.cs
- CalendarDay.cs
- CachedPathData.cs
- MarginCollapsingState.cs
- ConsoleEntryPoint.cs
- X509Utils.cs
- DeclarationUpdate.cs
- StaticExtensionConverter.cs
- XpsImageSerializationService.cs
- Padding.cs
- JsonDeserializer.cs
- mansign.cs
- SQLBoolean.cs
- RepeatEnumerable.cs
- XmlBaseReader.cs
- JsonMessageEncoderFactory.cs
- RuntimeArgumentHandle.cs
- ConstraintEnumerator.cs
- ImmutableClientRuntime.cs
- Duration.cs
- StorageBasedPackageProperties.cs
- ProtocolReflector.cs
- FontFaceLayoutInfo.cs
- SqlException.cs
- QueryableFilterUserControl.cs
- TextureBrush.cs
- SHA1.cs
- TabItem.cs
- FixedSOMElement.cs
- LabelAutomationPeer.cs
- TextWriter.cs
- BrowserCapabilitiesCodeGenerator.cs
- FontStretches.cs
- CompModSwitches.cs
- ApplicationProxyInternal.cs
- WebPartChrome.cs
- ConfigurationException.cs
- ProcessHostMapPath.cs
- BoundsDrawingContextWalker.cs
- SatelliteContractVersionAttribute.cs
- UidPropertyAttribute.cs
- EventBuilder.cs
- DesignerForm.cs
- DoubleStorage.cs
- UserControlCodeDomTreeGenerator.cs
- ManipulationVelocities.cs
- FillRuleValidation.cs
- EditableLabelControl.cs
- ScriptResourceDefinition.cs
- ValuePatternIdentifiers.cs
- ListCommandEventArgs.cs
- EncryptedType.cs
- ALinqExpressionVisitor.cs
- PtsHost.cs
- SignatureGenerator.cs
- NavigationPropertyEmitter.cs
- QuaternionAnimation.cs
- ServiceModelInstallComponent.cs
- ProfileModule.cs
- FormsAuthenticationUser.cs
- DocumentXmlWriter.cs
- NumberFormatInfo.cs
- Propagator.JoinPropagator.JoinPredicateVisitor.cs
- ManagementPath.cs
- TypeKeyValue.cs
- ComponentCommands.cs
- SingleKeyFrameCollection.cs
- JsonWriter.cs
- TextFormatterImp.cs
- DynamicRenderer.cs
- ParagraphResult.cs
- PasswordPropertyTextAttribute.cs
- CellCreator.cs
- OdbcParameter.cs
- RewritingSimplifier.cs
- EditorAttribute.cs
- GridLength.cs