Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / ndp / fx / src / DLinq / Dlinq / SqlClient / Query / SqlCrossApplyToCrossJoin.cs / 2 / 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
- OleDbParameter.cs
- COM2EnumConverter.cs
- InstanceDataCollectionCollection.cs
- TraceLog.cs
- COM2AboutBoxPropertyDescriptor.cs
- BoolLiteral.cs
- ToolboxCategoryItems.cs
- RegexCompilationInfo.cs
- HttpProfileBase.cs
- Style.cs
- XmlILStorageConverter.cs
- GridViewUpdateEventArgs.cs
- AdPostCacheSubstitution.cs
- HttpStreamFormatter.cs
- RelationshipEnd.cs
- log.cs
- ListBox.cs
- MetadataArtifactLoaderFile.cs
- PropertyMapper.cs
- SyndicationDeserializer.cs
- UnsafeNativeMethodsPenimc.cs
- UIElementParagraph.cs
- XamlReaderHelper.cs
- ValueConversionAttribute.cs
- CryptoApi.cs
- ClientFormsAuthenticationMembershipProvider.cs
- DataGridViewControlCollection.cs
- Transform3D.cs
- KnownBoxes.cs
- ItemContainerProviderWrapper.cs
- XmlQueryContext.cs
- AppDomainInstanceProvider.cs
- MessageBox.cs
- VersionedStream.cs
- PrtCap_Public.cs
- DispatchChannelSink.cs
- Set.cs
- CodeCommentStatementCollection.cs
- DataGridBeginningEditEventArgs.cs
- SessionStateSection.cs
- DummyDataSource.cs
- TableRow.cs
- WebMessageEncodingBindingElement.cs
- Int64Converter.cs
- ProtocolsConfigurationEntry.cs
- QfeChecker.cs
- ProfileEventArgs.cs
- DateTime.cs
- QueryableFilterRepeater.cs
- HostProtectionPermission.cs
- PrimarySelectionAdorner.cs
- SrgsElementFactory.cs
- OraclePermissionAttribute.cs
- CompModSwitches.cs
- CompiledXpathExpr.cs
- QueryGeneratorBase.cs
- ParsedAttributeCollection.cs
- RuntimeCompatibilityAttribute.cs
- HtmlFormParameterReader.cs
- QilVisitor.cs
- ExitEventArgs.cs
- AuthorizationRule.cs
- RepeaterItemCollection.cs
- TableLayoutSettingsTypeConverter.cs
- DictionarySectionHandler.cs
- WindowsGraphicsWrapper.cs
- GeometryGroup.cs
- BitmapImage.cs
- translator.cs
- FrameSecurityDescriptor.cs
- BaseCodeDomTreeGenerator.cs
- RawStylusInput.cs
- TranslateTransform.cs
- Canonicalizers.cs
- Tracking.cs
- _AutoWebProxyScriptHelper.cs
- WebPageTraceListener.cs
- TableLayoutStyle.cs
- RubberbandSelector.cs
- ManagedWndProcTracker.cs
- documentsequencetextcontainer.cs
- SaveFileDialogDesigner.cs
- WebPartConnectionsConfigureVerb.cs
- StructuredTypeEmitter.cs
- ToolBarButtonClickEvent.cs
- ProfileEventArgs.cs
- ActivityCodeDomSerializationManager.cs
- Debug.cs
- GlyphInfoList.cs
- DecimalStorage.cs
- EntityDataSourceWrapperPropertyDescriptor.cs
- DynamicPropertyHolder.cs
- DefaultValidator.cs
- LocalsItemDescription.cs
- CallbackHandler.cs
- XmlTextReader.cs
- IPEndPointCollection.cs
- InvalidPrinterException.cs
- RangeValuePatternIdentifiers.cs
- EnumValidator.cs