Code:
/ 4.0 / 4.0 / untmp / 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DragEvent.cs
- ExcCanonicalXml.cs
- ProcessModelSection.cs
- EmptyCollection.cs
- BidPrivateBase.cs
- VersionPair.cs
- OdbcError.cs
- BindingManagerDataErrorEventArgs.cs
- WorkflowViewManager.cs
- ImportOptions.cs
- AuthorizationSection.cs
- XmlSchemaCompilationSettings.cs
- HtmlTable.cs
- TriggerAction.cs
- _ChunkParse.cs
- ArgumentNullException.cs
- ThreadInterruptedException.cs
- StorageConditionPropertyMapping.cs
- DragDeltaEventArgs.cs
- MouseCaptureWithinProperty.cs
- WebScriptMetadataMessage.cs
- Ref.cs
- EpmCustomContentDeSerializer.cs
- MenuAdapter.cs
- RoleGroupCollection.cs
- PartitionResolver.cs
- ControlBuilderAttribute.cs
- EntityDataSourceChangingEventArgs.cs
- LayoutEditorPart.cs
- SchemaImporter.cs
- PasswordValidationException.cs
- WindowsPrincipal.cs
- SchemaImporterExtensionsSection.cs
- WindowsTooltip.cs
- fixedPageContentExtractor.cs
- ComponentCache.cs
- RemotingConfigParser.cs
- XmlSchemaAnnotated.cs
- DataRowView.cs
- ValueOfAction.cs
- SessionStateModule.cs
- TextEncodedRawTextWriter.cs
- ReferencedType.cs
- XPathCompileException.cs
- WrappedReader.cs
- PointLightBase.cs
- FastEncoderWindow.cs
- GridView.cs
- JavaScriptSerializer.cs
- RawStylusInput.cs
- ExpressionBuilderCollection.cs
- DataGridViewCellContextMenuStripNeededEventArgs.cs
- RoleServiceManager.cs
- Style.cs
- Base64Stream.cs
- CheckBox.cs
- OutputCacheProfileCollection.cs
- HttpModuleAction.cs
- ListBoxItemAutomationPeer.cs
- Enlistment.cs
- ResourcesGenerator.cs
- lengthconverter.cs
- MergePropertyDescriptor.cs
- SiteMapSection.cs
- AudienceUriMode.cs
- CollectionViewGroup.cs
- CacheVirtualItemsEvent.cs
- ScrollableControl.cs
- HtmlContainerControl.cs
- DefaultBindingPropertyAttribute.cs
- HyperLinkField.cs
- FactoryId.cs
- AnnotationComponentChooser.cs
- TextDecorationCollection.cs
- CheckBox.cs
- ProtocolsConfigurationEntry.cs
- Process.cs
- TextParagraph.cs
- TdsParserStateObject.cs
- PackageFilter.cs
- Int16AnimationBase.cs
- IPipelineRuntime.cs
- ManagementException.cs
- WebException.cs
- DbConnectionPoolCounters.cs
- OneToOneMappingSerializer.cs
- DesignBindingPicker.cs
- PixelFormatConverter.cs
- RegexCapture.cs
- TreeView.cs
- DBConnection.cs
- SourceFileBuildProvider.cs
- IssuanceLicense.cs
- CapabilitiesSection.cs
- TCPClient.cs
- SinglePageViewer.cs
- RelationshipSet.cs
- AutoResizedEvent.cs
- XmlDownloadManager.cs
- CalculatedColumn.cs