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
- ExplicitDiscriminatorMap.cs
- TemplateApplicationHelper.cs
- PngBitmapDecoder.cs
- connectionpool.cs
- ToggleButton.cs
- RSAOAEPKeyExchangeDeformatter.cs
- EntityRecordInfo.cs
- TransformerTypeCollection.cs
- FormViewPagerRow.cs
- KeyToListMap.cs
- TextTrailingWordEllipsis.cs
- HatchBrush.cs
- XappLauncher.cs
- InheritanceContextChangedEventManager.cs
- safex509handles.cs
- WizardDesigner.cs
- ExtendedProtectionPolicyElement.cs
- PtsHelper.cs
- PathSegment.cs
- GridViewHeaderRowPresenter.cs
- NativeCompoundFileAPIs.cs
- AxWrapperGen.cs
- ByteStreamBufferedMessageData.cs
- TaiwanLunisolarCalendar.cs
- X509Extension.cs
- WMICapabilities.cs
- KeyManager.cs
- BidPrivateBase.cs
- ZipPackage.cs
- _RequestCacheProtocol.cs
- DataGridColumnHeaderAutomationPeer.cs
- _AcceptOverlappedAsyncResult.cs
- HyperlinkAutomationPeer.cs
- ThreadExceptionEvent.cs
- PieceDirectory.cs
- WebHttpBindingElement.cs
- Point3DCollection.cs
- OdbcReferenceCollection.cs
- ClientBuildManagerCallback.cs
- EventLogTraceListener.cs
- DataObjectCopyingEventArgs.cs
- ProfilePropertyMetadata.cs
- UIPropertyMetadata.cs
- XmlNodeChangedEventArgs.cs
- ToolStripDropTargetManager.cs
- BaseUriHelper.cs
- DispatcherFrame.cs
- SslStreamSecurityUpgradeProvider.cs
- PropertyConverter.cs
- RectAnimationBase.cs
- UIElementHelper.cs
- SafeEventLogWriteHandle.cs
- OutputCacheProfile.cs
- FormsAuthenticationUserCollection.cs
- control.ime.cs
- CodeSpit.cs
- WindowsGraphics.cs
- ObjectHandle.cs
- ProcessProtocolHandler.cs
- ConnectionsZoneDesigner.cs
- FormsAuthenticationModule.cs
- Assert.cs
- BinaryFormatterWriter.cs
- Binding.cs
- XmlSortKey.cs
- SystemEvents.cs
- Vector3dCollection.cs
- RecordManager.cs
- FlowNode.cs
- ZipPackage.cs
- IsolatedStorageFileStream.cs
- GenericWebPart.cs
- SymmetricKey.cs
- Aes.cs
- ContractMethodInfo.cs
- RoleServiceManager.cs
- DoubleLinkListEnumerator.cs
- BitmapCodecInfo.cs
- SecurityKeyIdentifier.cs
- EventMemberCodeDomSerializer.cs
- IODescriptionAttribute.cs
- UrlMappingsSection.cs
- ConfigurationSchemaErrors.cs
- LingerOption.cs
- AsymmetricSignatureFormatter.cs
- ExtenderControl.cs
- ChangeDirector.cs
- DataGridViewTopRowAccessibleObject.cs
- DataServiceBuildProvider.cs
- Options.cs
- UserControl.cs
- linebase.cs
- MonthCalendar.cs
- TextBoxBase.cs
- WebService.cs
- PolyBezierSegmentFigureLogic.cs
- NullableConverter.cs
- MappingException.cs
- _NtlmClient.cs
- XmlSchemaProviderAttribute.cs