Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DLinq / Dlinq / SqlClient / Query / SqlCrossApplyToCrossJoin.cs / 1305376 / SqlCrossApplyToCrossJoin.cs
using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; namespace System.Data.Linq.SqlClient { using System.Data.Linq; ////// Turn CROSS APPLY into CROSS JOIN when the right side /// of the apply doesn't reference anything on the left side. /// /// Any query which has a CROSS APPLY which cannot be converted to /// a CROSS JOIN is annotated so that we can give a meaningful /// error message later for SQL2K. /// internal class SqlCrossApplyToCrossJoin { internal static SqlNode Reduce(SqlNode node, SqlNodeAnnotations annotations) { Reducer r = new Reducer(); r.Annotations = annotations; return r.Visit(node); } class Reducer : SqlVisitor { internal SqlNodeAnnotations Annotations; internal override SqlSource VisitJoin(SqlJoin join) { if (join.JoinType == SqlJoinType.CrossApply) { // Look down the left side to see what table aliases are produced. HashSetp = SqlGatherProducedAliases.Gather(join.Left); // Look down the right side to see what table aliases are consumed. HashSet c = SqlGatherConsumedAliases.Gather(join.Right); // Look at each consumed alias and see if they are mentioned in produced. if (p.Overlaps(c)) { Annotations.Add(join, new SqlServerCompatibilityAnnotation(Strings.SourceExpressionAnnotation(join.SourceExpression), SqlProvider.ProviderMode.Sql2000)); // Can't reduce because this consumed alias is produced on the left. return base.VisitJoin(join); } // Can turn this into a CROSS JOIN join.JoinType = SqlJoinType.Cross; return VisitJoin(join); } return base.VisitJoin(join); } } } } // 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; using System.Linq.Expressions; namespace System.Data.Linq.SqlClient { using System.Data.Linq; /// /// Turn CROSS APPLY into CROSS JOIN when the right side /// of the apply doesn't reference anything on the left side. /// /// Any query which has a CROSS APPLY which cannot be converted to /// a CROSS JOIN is annotated so that we can give a meaningful /// error message later for SQL2K. /// internal class SqlCrossApplyToCrossJoin { internal static SqlNode Reduce(SqlNode node, SqlNodeAnnotations annotations) { Reducer r = new Reducer(); r.Annotations = annotations; return r.Visit(node); } class Reducer : SqlVisitor { internal SqlNodeAnnotations Annotations; internal override SqlSource VisitJoin(SqlJoin join) { if (join.JoinType == SqlJoinType.CrossApply) { // Look down the left side to see what table aliases are produced. HashSetp = SqlGatherProducedAliases.Gather(join.Left); // Look down the right side to see what table aliases are consumed. HashSet c = SqlGatherConsumedAliases.Gather(join.Right); // Look at each consumed alias and see if they are mentioned in produced. if (p.Overlaps(c)) { Annotations.Add(join, new SqlServerCompatibilityAnnotation(Strings.SourceExpressionAnnotation(join.SourceExpression), SqlProvider.ProviderMode.Sql2000)); // Can't reduce because this consumed alias is produced on the left. return base.VisitJoin(join); } // Can turn this into a CROSS JOIN join.JoinType = SqlJoinType.Cross; return VisitJoin(join); } return base.VisitJoin(join); } } } } // 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
- relpropertyhelper.cs
- DocumentPaginator.cs
- IndependentAnimationStorage.cs
- HtmlLinkAdapter.cs
- ConfigXmlText.cs
- NotImplementedException.cs
- RowType.cs
- ObjectListCommandsPage.cs
- XamlVector3DCollectionSerializer.cs
- CodeTypeDelegate.cs
- ToolStripContentPanel.cs
- StateWorkerRequest.cs
- FileVersion.cs
- RankException.cs
- HtmlElementEventArgs.cs
- InfoCardSymmetricAlgorithm.cs
- NullableIntSumAggregationOperator.cs
- TableProviderWrapper.cs
- StylusButtonCollection.cs
- TextServicesCompartment.cs
- HealthMonitoringSectionHelper.cs
- RadioButtonRenderer.cs
- SqlUserDefinedTypeAttribute.cs
- EntityContainerRelationshipSet.cs
- ManipulationInertiaStartingEventArgs.cs
- DataSourceView.cs
- OpCodes.cs
- DataProtection.cs
- WindowsGraphics.cs
- safesecurityhelperavalon.cs
- MeshGeometry3D.cs
- HttpClientCertificate.cs
- ConfigurationManagerInternalFactory.cs
- ClientTargetSection.cs
- _FtpControlStream.cs
- DesignerProperties.cs
- InputScope.cs
- XmlValidatingReader.cs
- IsolatedStorageException.cs
- Highlights.cs
- ConcurrencyBehavior.cs
- TextViewSelectionProcessor.cs
- XmlCDATASection.cs
- ConversionContext.cs
- StandardTransformFactory.cs
- DocumentViewerBase.cs
- ContentPlaceHolderDesigner.cs
- TemplateControl.cs
- OleDbParameter.cs
- NavigationEventArgs.cs
- XPathDocumentNavigator.cs
- StdValidatorsAndConverters.cs
- CodeGroup.cs
- FieldCollectionEditor.cs
- GridSplitterAutomationPeer.cs
- LinearGradientBrush.cs
- FunctionMappingTranslator.cs
- GestureRecognitionResult.cs
- ParameterToken.cs
- XPathDocumentNavigator.cs
- CornerRadiusConverter.cs
- AccessedThroughPropertyAttribute.cs
- contentDescriptor.cs
- PublisherMembershipCondition.cs
- BaseTemplateCodeDomTreeGenerator.cs
- DoubleLink.cs
- ConnectionPointCookie.cs
- DataGridColumnCollection.cs
- VarRemapper.cs
- MediaElementAutomationPeer.cs
- DataGridParentRows.cs
- SafeHandles.cs
- IriParsingElement.cs
- DeploymentSection.cs
- RolePrincipal.cs
- CodeCompiler.cs
- ClientSettingsSection.cs
- NavigationPropertyEmitter.cs
- WorkflowMarkupSerializationException.cs
- XmlSerializationReader.cs
- TreeIterator.cs
- UnitySerializationHolder.cs
- RemoteWebConfigurationHostServer.cs
- ImagingCache.cs
- ProviderCollection.cs
- PropertyGrid.cs
- ParseHttpDate.cs
- WebAdminConfigurationHelper.cs
- TableCell.cs
- PeerObject.cs
- DocumentXPathNavigator.cs
- DataGridViewComboBoxColumnDesigner.cs
- AnnotationResourceChangedEventArgs.cs
- SQLInt64.cs
- SoapFaultCodes.cs
- ZeroOpNode.cs
- XmlValidatingReader.cs
- ForEachAction.cs
- PieceDirectory.cs
- HMACSHA256.cs