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
- XmlSerializerAssemblyAttribute.cs
- ResXResourceWriter.cs
- MetadataItemSerializer.cs
- ResolvePPIDRequest.cs
- BooleanStorage.cs
- SHA384Managed.cs
- storagemappingitemcollection.viewdictionary.cs
- VersionedStream.cs
- NewExpression.cs
- RelationshipSet.cs
- MailMessage.cs
- SecurityAlgorithmSuite.cs
- ComponentCollection.cs
- SetterBaseCollection.cs
- ObfuscateAssemblyAttribute.cs
- GridItemCollection.cs
- MappingItemCollection.cs
- SecurityResources.cs
- XmlDataCollection.cs
- OneOfScalarConst.cs
- CfgSemanticTag.cs
- EventTrigger.cs
- SecurityHeaderElementInferenceEngine.cs
- GradientStop.cs
- _PooledStream.cs
- WebSysDisplayNameAttribute.cs
- DurationConverter.cs
- QueryTask.cs
- GlyphingCache.cs
- TextServicesDisplayAttribute.cs
- Form.cs
- SqlRowUpdatingEvent.cs
- ThreadAbortException.cs
- ObjectDataSourceView.cs
- ExpressionBuilder.cs
- BitStack.cs
- XPathScanner.cs
- FormViewUpdateEventArgs.cs
- TextSearch.cs
- CodeDomDesignerLoader.cs
- TextDecorationCollection.cs
- WindowsSolidBrush.cs
- WebExceptionStatus.cs
- SigningCredentials.cs
- tibetanshape.cs
- ToolStripDropTargetManager.cs
- CanonicalizationDriver.cs
- DynamicExpression.cs
- CatalogPartDesigner.cs
- ToolStripDropDown.cs
- ServicePointManagerElement.cs
- Resources.Designer.cs
- X509ChainPolicy.cs
- PackageStore.cs
- QueryOptionExpression.cs
- SHA384.cs
- CryptoConfig.cs
- ControlTemplate.cs
- CodeExporter.cs
- DataStorage.cs
- _PooledStream.cs
- DirectionalAction.cs
- SolidColorBrush.cs
- SQLResource.cs
- HuffModule.cs
- printdlgexmarshaler.cs
- CodePageUtils.cs
- OverrideMode.cs
- XPathNodeHelper.cs
- GenericUriParser.cs
- SubstitutionResponseElement.cs
- FrameworkName.cs
- Confirm.cs
- ActiveDocumentEvent.cs
- CellCreator.cs
- OleDbSchemaGuid.cs
- DataServiceQueryException.cs
- QueryNode.cs
- XmlSchemaExporter.cs
- PassportAuthenticationModule.cs
- PersonalizablePropertyEntry.cs
- ObjectDataSourceView.cs
- Point3DCollection.cs
- FixedHighlight.cs
- WinEventWrap.cs
- UIElement3D.cs
- CommentAction.cs
- ListBoxItemAutomationPeer.cs
- MultiAsyncResult.cs
- SecurityRuntime.cs
- ToolboxCategoryItems.cs
- HttpRequestCacheValidator.cs
- _SslStream.cs
- PolyLineSegment.cs
- SessionPageStatePersister.cs
- Duration.cs
- IIS7WorkerRequest.cs
- PropertyValue.cs
- VisualTarget.cs
- DelegateBodyWriter.cs