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
- RotateTransform.cs
- EntityDataSourceEntitySetNameItem.cs
- XamlSerializerUtil.cs
- OleDbError.cs
- HttpRequestWrapper.cs
- Exceptions.cs
- XpsFilter.cs
- Int32Collection.cs
- ExceptionHandlersDesigner.cs
- TickBar.cs
- _BufferOffsetSize.cs
- EntryIndex.cs
- SafeLocalMemHandle.cs
- TextAdaptor.cs
- SqlFactory.cs
- ClientSettingsSection.cs
- EventLogReader.cs
- BindingValueChangedEventArgs.cs
- X509AsymmetricSecurityKey.cs
- HostSecurityManager.cs
- DataGridRowEventArgs.cs
- WebUtil.cs
- WebPartTransformerCollection.cs
- WebPartsPersonalizationAuthorization.cs
- XsdCachingReader.cs
- TransformerTypeCollection.cs
- Keyboard.cs
- GrabHandleGlyph.cs
- SafeFileMappingHandle.cs
- IOThreadScheduler.cs
- TextDecoration.cs
- DataGridTable.cs
- QueryNode.cs
- ValidationResult.cs
- MtomMessageEncoder.cs
- XsltException.cs
- RequestSecurityTokenResponse.cs
- DispatcherEventArgs.cs
- MetabaseServerConfig.cs
- MapPathBasedVirtualPathProvider.cs
- WindowsScroll.cs
- DataPagerFieldItem.cs
- OdbcConnectionHandle.cs
- ProgressBar.cs
- BitmapEffectState.cs
- Window.cs
- CompositeCollectionView.cs
- Animatable.cs
- HttpSysSettings.cs
- connectionpool.cs
- dataSvcMapFileLoader.cs
- TextRangeBase.cs
- SqlDataSourceView.cs
- SQLSingle.cs
- WorkflowDesigner.cs
- ObfuscateAssemblyAttribute.cs
- ExpressionBuilderCollection.cs
- CompensateDesigner.cs
- Int16Storage.cs
- DbgCompiler.cs
- ServiceReference.cs
- ConfigurationLockCollection.cs
- TextServicesHost.cs
- RelativeSource.cs
- ChannelServices.cs
- TransformerTypeCollection.cs
- DefaultValueMapping.cs
- SQLDouble.cs
- GeometryCollection.cs
- CounterSampleCalculator.cs
- CommonObjectSecurity.cs
- NativeMethods.cs
- AnonymousIdentificationSection.cs
- CompositeCollection.cs
- ChannelListenerBase.cs
- ZoneIdentityPermission.cs
- SafeNativeMethods.cs
- InputElement.cs
- SurrogateSelector.cs
- BCLDebug.cs
- TileBrush.cs
- WebPartEventArgs.cs
- HighlightVisual.cs
- RectangleGeometry.cs
- CollectionChangedEventManager.cs
- MatrixTransform3D.cs
- DmlSqlGenerator.cs
- FileNotFoundException.cs
- PropertyGeneratedEventArgs.cs
- clipboard.cs
- TemplateEditingService.cs
- XmlSchemaValidator.cs
- RelationshipManager.cs
- HtmlHistory.cs
- BuildManager.cs
- TrackBarRenderer.cs
- Command.cs
- PropertyContainer.cs
- CompilationLock.cs
- HTMLTextWriter.cs