Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / 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
- CharacterBuffer.cs
- ProxyWebPartManager.cs
- SqlGenerator.cs
- ConfigXmlCDataSection.cs
- RtfToXamlReader.cs
- HttpResponseBase.cs
- InternalPolicyElement.cs
- AlternateViewCollection.cs
- Vector.cs
- TransactionFlowBindingElement.cs
- GridViewColumnCollection.cs
- Label.cs
- CreateUserWizard.cs
- RequestSecurityToken.cs
- PerspectiveCamera.cs
- DiscardableAttribute.cs
- LinqDataSourceContextEventArgs.cs
- Parallel.cs
- XXXOnTypeBuilderInstantiation.cs
- XmlHierarchicalEnumerable.cs
- Viewport2DVisual3D.cs
- ScalarType.cs
- FieldToken.cs
- Inflater.cs
- PageBuildProvider.cs
- ImmutableAssemblyCacheEntry.cs
- ModelPropertyDescriptor.cs
- MouseEvent.cs
- RemoteWebConfigurationHostServer.cs
- ResourceProviderFactory.cs
- PaperSource.cs
- TextEditorTables.cs
- CharKeyFrameCollection.cs
- HttpServerUtilityWrapper.cs
- ObjectDataSourceMethodEventArgs.cs
- OutputCacheProfileCollection.cs
- XmlAttributeCollection.cs
- DiffuseMaterial.cs
- MissingMemberException.cs
- HttpRequestContext.cs
- LineMetrics.cs
- TextComposition.cs
- StringExpressionSet.cs
- DefaultAssemblyResolver.cs
- DESCryptoServiceProvider.cs
- LongTypeConverter.cs
- Parameter.cs
- figurelengthconverter.cs
- DataSourceIDConverter.cs
- LogLogRecordEnumerator.cs
- ListBase.cs
- Sql8ConformanceChecker.cs
- ToolboxItemSnapLineBehavior.cs
- DataGridColumnHeaderItemAutomationPeer.cs
- RelationshipFixer.cs
- WmlPhoneCallAdapter.cs
- EntityStoreSchemaGenerator.cs
- ConnectionPoolManager.cs
- StaticSiteMapProvider.cs
- MemoryRecordBuffer.cs
- LinearKeyFrames.cs
- TextBoxLine.cs
- ToolStripPanelRow.cs
- XslTransform.cs
- SafeEventHandle.cs
- EventLogInternal.cs
- EmptyControlCollection.cs
- OSFeature.cs
- TableSectionStyle.cs
- DataSourceSelectArguments.cs
- BitmapEffectrendercontext.cs
- PartDesigner.cs
- LineBreakRecord.cs
- TextTreeNode.cs
- VisualBasicValue.cs
- UITypeEditor.cs
- CancelRequestedQuery.cs
- ForceCopyBuildProvider.cs
- ActiveDocumentEvent.cs
- DataGridViewDataErrorEventArgs.cs
- Style.cs
- Viewport2DVisual3D.cs
- RelatedView.cs
- CompositeDataBoundControl.cs
- UserControl.cs
- FormClosedEvent.cs
- ForeignKeyConstraint.cs
- ChangeTracker.cs
- TargetInvocationException.cs
- CustomActivityDesigner.cs
- LinqTreeNodeEvaluator.cs
- QueryableFilterUserControl.cs
- COM2IDispatchConverter.cs
- ContentIterators.cs
- OleDbPermission.cs
- coordinator.cs
- ControlIdConverter.cs
- HttpRawResponse.cs
- DataConnectionHelper.cs
- LazyLoadBehavior.cs