Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / ndp / fx / src / DLinq / Dlinq / SqlClient / Query / SqlCrossApplyToCrossJoin.cs / 1 / 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
- SqlParameterizer.cs
- SystemNetworkInterface.cs
- DataGridViewRowHeightInfoNeededEventArgs.cs
- DefaultTypeArgumentAttribute.cs
- AmbientEnvironment.cs
- LinkedResource.cs
- FlowLayoutPanel.cs
- Transform3D.cs
- CodeIdentifiers.cs
- VScrollProperties.cs
- EntityStoreSchemaGenerator.cs
- AnnotationAdorner.cs
- PageParserFilter.cs
- IdentityValidationException.cs
- HttpServerVarsCollection.cs
- TreeNode.cs
- ValidateNames.cs
- TypeDelegator.cs
- FontUnit.cs
- DataGridViewColumnStateChangedEventArgs.cs
- StrokeCollection2.cs
- Unit.cs
- CapabilitiesPattern.cs
- WebContext.cs
- ToolStripPanel.cs
- TreeWalker.cs
- HistoryEventArgs.cs
- ReadOnlyDictionary.cs
- AuthenticationException.cs
- CaretElement.cs
- ReplyAdapterChannelListener.cs
- EasingKeyFrames.cs
- RepeatBehavior.cs
- NumberFormatter.cs
- WsdlBuildProvider.cs
- LabelDesigner.cs
- WebPartVerbCollection.cs
- CoreSwitches.cs
- ListControlDesigner.cs
- WizardPanel.cs
- Cursors.cs
- IncomingWebRequestContext.cs
- ScalarRestriction.cs
- GACMembershipCondition.cs
- ToolStripDropTargetManager.cs
- XmlSchemaSimpleType.cs
- IApplicationTrustManager.cs
- XmlTextReaderImpl.cs
- SecUtil.cs
- ThousandthOfEmRealPoints.cs
- XmlConvert.cs
- SecurityState.cs
- DateTimeFormatInfo.cs
- Matrix.cs
- TraceContextRecord.cs
- PerfCounters.cs
- WeakEventTable.cs
- TextEncodedRawTextWriter.cs
- ADMembershipUser.cs
- DbProviderSpecificTypePropertyAttribute.cs
- FragmentNavigationEventArgs.cs
- StreamGeometry.cs
- RegexGroupCollection.cs
- TaiwanCalendar.cs
- WindowsGraphics.cs
- TextCompositionManager.cs
- LogWriteRestartAreaAsyncResult.cs
- StringValidatorAttribute.cs
- InlineCollection.cs
- CatalogPartCollection.cs
- _NegoState.cs
- DataGridItemEventArgs.cs
- Errors.cs
- PropertySegmentSerializer.cs
- SerializerProvider.cs
- HttpContextWrapper.cs
- AdRotator.cs
- ProxyManager.cs
- ServiceAuthorizationElement.cs
- TemplateParser.cs
- PolicyException.cs
- DelegateArgument.cs
- Image.cs
- WindowsRichEdit.cs
- AbandonedMutexException.cs
- DataSourceProvider.cs
- IDispatchConstantAttribute.cs
- DataViewManagerListItemTypeDescriptor.cs
- CellPartitioner.cs
- ContentHostHelper.cs
- PropertyChangeTracker.cs
- SQLMembershipProvider.cs
- ImageAutomationPeer.cs
- PeerApplication.cs
- SQLBytes.cs
- DiscoveryDocument.cs
- DbParameterCollectionHelper.cs
- LoggedException.cs
- InheritanceContextHelper.cs
- ServiceHostFactory.cs