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
- AddInDeploymentState.cs
- LineMetrics.cs
- NumberAction.cs
- COM2Enum.cs
- SimpleRecyclingCache.cs
- _AutoWebProxyScriptEngine.cs
- ContextMenuStrip.cs
- Encoding.cs
- HitTestResult.cs
- RetrieveVirtualItemEventArgs.cs
- HttpConfigurationContext.cs
- FormViewDeleteEventArgs.cs
- InvalidDataException.cs
- GeometryDrawing.cs
- DocumentSequence.cs
- SecurityUtils.cs
- PhotoPrintingIntent.cs
- TemplateControlCodeDomTreeGenerator.cs
- CustomCategoryAttribute.cs
- ObjectStorage.cs
- Positioning.cs
- DetailsViewDeleteEventArgs.cs
- DataGridParentRows.cs
- ParameterCollection.cs
- SimpleWebHandlerParser.cs
- WmlControlAdapter.cs
- MissingManifestResourceException.cs
- SerializationInfo.cs
- XmlSchemaImport.cs
- _SslState.cs
- ValuePattern.cs
- httpserverutility.cs
- ISCIIEncoding.cs
- BooleanConverter.cs
- WindowsListViewGroup.cs
- CqlIdentifiers.cs
- OdbcError.cs
- Material.cs
- SamlDoNotCacheCondition.cs
- ToggleProviderWrapper.cs
- ProfilePropertySettingsCollection.cs
- ValidationPropertyAttribute.cs
- Variant.cs
- BrowserDefinitionCollection.cs
- ReadOnlyDataSource.cs
- SvcFileManager.cs
- MenuItem.cs
- PaperSize.cs
- DurableOperationAttribute.cs
- LocalFileSettingsProvider.cs
- CodeFieldReferenceExpression.cs
- RegexCompilationInfo.cs
- RangeValidator.cs
- Int32Collection.cs
- HttpCapabilitiesEvaluator.cs
- ReadOnlyActivityGlyph.cs
- DirtyTextRange.cs
- ObjectDataSource.cs
- InvokePatternIdentifiers.cs
- RawStylusInput.cs
- OdbcConnectionOpen.cs
- DBSqlParserColumn.cs
- RealizationDrawingContextWalker.cs
- ExcCanonicalXml.cs
- LogStore.cs
- URLString.cs
- SecurityCookieModeValidator.cs
- RuleSetBrowserDialog.cs
- ContentPosition.cs
- AttributeData.cs
- AttributeEmitter.cs
- SqlInternalConnectionSmi.cs
- SqlOuterApplyReducer.cs
- JsonDataContract.cs
- ConvertEvent.cs
- TransformValueSerializer.cs
- CategoryAttribute.cs
- LateBoundBitmapDecoder.cs
- InheritanceAttribute.cs
- EntityDataSourceDataSelection.cs
- AlgoModule.cs
- CapiSafeHandles.cs
- TablePatternIdentifiers.cs
- UnknownWrapper.cs
- OverflowException.cs
- ErrorEventArgs.cs
- sqlser.cs
- FixedSOMImage.cs
- XamlDesignerSerializationManager.cs
- HealthMonitoringSectionHelper.cs
- BitmapSource.cs
- Win32Exception.cs
- XmlILModule.cs
- ExecutorLocksHeldException.cs
- CompositeTypefaceMetrics.cs
- FocusWithinProperty.cs
- DbConnectionStringBuilder.cs
- BindingSource.cs
- TableDesigner.cs
- If.cs