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
- SystemInformation.cs
- SHA512.cs
- CanonicalFontFamilyReference.cs
- _BaseOverlappedAsyncResult.cs
- ByteConverter.cs
- UIElementCollection.cs
- Socket.cs
- FrameworkReadOnlyPropertyMetadata.cs
- HttpSocketManager.cs
- ExclusiveTcpTransportManager.cs
- SafeSecurityHelper.cs
- TargetParameterCountException.cs
- XmlArrayItemAttribute.cs
- FileDialog.cs
- LoginName.cs
- ArrayTypeMismatchException.cs
- TreeView.cs
- ActivityFunc.cs
- MonikerSyntaxException.cs
- EntityDataSourceContextCreatedEventArgs.cs
- DictionaryEntry.cs
- ScaleTransform.cs
- PropertyCollection.cs
- DataTablePropertyDescriptor.cs
- StrongNameUtility.cs
- OwnerDrawPropertyBag.cs
- ExpressionHelper.cs
- DrawingAttributesDefaultValueFactory.cs
- MiniModule.cs
- MenuRendererClassic.cs
- XPathParser.cs
- BinaryMethodMessage.cs
- BrushMappingModeValidation.cs
- FileClassifier.cs
- ProcessHostFactoryHelper.cs
- UpDownEvent.cs
- xmlfixedPageInfo.cs
- FontConverter.cs
- XmlArrayItemAttribute.cs
- ServiceMetadataPublishingElement.cs
- ComponentChangingEvent.cs
- TypeToTreeConverter.cs
- recordstate.cs
- SqlBuilder.cs
- StateRuntime.cs
- IteratorAsyncResult.cs
- DataGridViewRow.cs
- Point3D.cs
- View.cs
- UnescapedXmlDiagnosticData.cs
- CellQuery.cs
- SizeAnimation.cs
- COM2ExtendedBrowsingHandler.cs
- TransformerTypeCollection.cs
- __ConsoleStream.cs
- CodeConditionStatement.cs
- Typeface.cs
- TextServicesLoader.cs
- XmlAnyAttributeAttribute.cs
- StorageEntitySetMapping.cs
- RectKeyFrameCollection.cs
- BulletChrome.cs
- FrameworkTextComposition.cs
- UniqueEventHelper.cs
- EdmRelationshipRoleAttribute.cs
- XmlSchemaElement.cs
- FileSecurity.cs
- MouseCaptureWithinProperty.cs
- StaticTextPointer.cs
- AcceptorSessionSymmetricTransportSecurityProtocol.cs
- DecoderReplacementFallback.cs
- SynchronizationFilter.cs
- AppLevelCompilationSectionCache.cs
- CatalogPartChrome.cs
- Content.cs
- _NtlmClient.cs
- XmlSchemaAttributeGroupRef.cs
- SoapExtensionTypeElementCollection.cs
- HtmlTitle.cs
- ActivityCodeDomSerializer.cs
- contentDescriptor.cs
- RectangleGeometry.cs
- ProfileProvider.cs
- InputScopeNameConverter.cs
- ConfigXmlSignificantWhitespace.cs
- ModulesEntry.cs
- FileDetails.cs
- ChangeDirector.cs
- MasterPageParser.cs
- NativeMethods.cs
- basevalidator.cs
- EntityDataSourceWrapperPropertyDescriptor.cs
- ConfigXmlAttribute.cs
- SecurityTokenAuthenticator.cs
- GridViewRowPresenterBase.cs
- TransportConfigurationTypeElement.cs
- PathNode.cs
- SettingsPropertyNotFoundException.cs
- DataContractSerializer.cs
- RMEnrollmentPage2.cs