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
- HtmlPanelAdapter.cs
- XmlTextReaderImplHelpers.cs
- EncoderParameter.cs
- AddInAdapter.cs
- QuaternionValueSerializer.cs
- DataGridViewHeaderCell.cs
- UriTemplateCompoundPathSegment.cs
- StatusBar.cs
- PeerToPeerException.cs
- Converter.cs
- NameSpaceExtractor.cs
- WorkflowFormatterBehavior.cs
- TraceUtility.cs
- EpmSyndicationContentDeSerializer.cs
- CodeEventReferenceExpression.cs
- BounceEase.cs
- TypeGeneratedEventArgs.cs
- SqlBuffer.cs
- NetDataContractSerializer.cs
- ExceptionValidationRule.cs
- ApplicationFileCodeDomTreeGenerator.cs
- RuleSetDialog.cs
- HttpVersion.cs
- EncodingInfo.cs
- OpenTypeLayoutCache.cs
- MeasureData.cs
- EntityConnection.cs
- TagPrefixAttribute.cs
- CodeExpressionStatement.cs
- DataSvcMapFileSerializer.cs
- BatchParser.cs
- odbcmetadatacolumnnames.cs
- PlanCompiler.cs
- CallSiteOps.cs
- Tracking.cs
- MatrixTransform.cs
- InteropTrackingRecord.cs
- PenContexts.cs
- ChannelSinkStacks.cs
- ChtmlCommandAdapter.cs
- SBCSCodePageEncoding.cs
- CanonicalXml.cs
- ProxyWebPart.cs
- MultiBindingExpression.cs
- XmlAttributes.cs
- TextEncodedRawTextWriter.cs
- Track.cs
- TableItemProviderWrapper.cs
- OracleColumn.cs
- NestedContainer.cs
- Source.cs
- FunctionOverloadResolver.cs
- AnnotationHelper.cs
- OleDbReferenceCollection.cs
- TextViewBase.cs
- CompilationRelaxations.cs
- DataGridViewLayoutData.cs
- MappingItemCollection.cs
- DefaultTextStoreTextComposition.cs
- FileLogRecordStream.cs
- GPRECT.cs
- CultureInfoConverter.cs
- DataGridViewBand.cs
- SpeakCompletedEventArgs.cs
- InputDevice.cs
- BooleanKeyFrameCollection.cs
- RuleSettingsCollection.cs
- RegexMatch.cs
- BulletedListEventArgs.cs
- DesignConnectionCollection.cs
- CompilerGlobalScopeAttribute.cs
- CapabilitiesRule.cs
- GenericIdentity.cs
- LogSwitch.cs
- DesignRelation.cs
- IsolatedStorageFile.cs
- ActivityInstanceMap.cs
- RequiredFieldValidator.cs
- TemplateField.cs
- XmlWhitespace.cs
- TemplateKeyConverter.cs
- DesignerCalendarAdapter.cs
- ButtonFlatAdapter.cs
- PerspectiveCamera.cs
- RenderCapability.cs
- FullTextBreakpoint.cs
- PreservationFileReader.cs
- EventProxy.cs
- ConfigurationElement.cs
- DataListItemEventArgs.cs
- EntityDataSourceConfigureObjectContext.cs
- SplitterPanel.cs
- WebEncodingValidatorAttribute.cs
- NotCondition.cs
- MimeBasePart.cs
- HtmlWindowCollection.cs
- Itemizer.cs
- Style.cs
- sqlpipe.cs
- MenuItemStyleCollectionEditor.cs