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
- SafeFileMapViewHandle.cs
- UndoManager.cs
- SQLDecimalStorage.cs
- TimeSpan.cs
- DrawListViewSubItemEventArgs.cs
- TextParaLineResult.cs
- OdbcReferenceCollection.cs
- DocumentXPathNavigator.cs
- EditorAttribute.cs
- RegexTree.cs
- SqlFacetAttribute.cs
- SizeConverter.cs
- CacheMemory.cs
- ComplexTypeEmitter.cs
- DataSourceHelper.cs
- Viewport2DVisual3D.cs
- CngKey.cs
- HScrollBar.cs
- DataErrorValidationRule.cs
- HtmlInputControl.cs
- DataGridViewElement.cs
- SqlMetaData.cs
- ParentQuery.cs
- HttpValueCollection.cs
- RegionData.cs
- VerificationAttribute.cs
- XmlSchemaParticle.cs
- TextFormatterContext.cs
- GeometryDrawing.cs
- SQLCharsStorage.cs
- GenericWebPart.cs
- SynchronizationContext.cs
- DescendentsWalker.cs
- ToolStripRendererSwitcher.cs
- TableDetailsRow.cs
- SamlSubjectStatement.cs
- QilName.cs
- TraceUtils.cs
- HebrewCalendar.cs
- DataGridColumnHeadersPresenterAutomationPeer.cs
- CreateUserErrorEventArgs.cs
- OleDbCommandBuilder.cs
- DataGridViewComboBoxColumnDesigner.cs
- SortQuery.cs
- DataColumnCollection.cs
- GeometryModel3D.cs
- HotSpot.cs
- SmtpAuthenticationManager.cs
- Application.cs
- MimeXmlImporter.cs
- QuotedPairReader.cs
- MsmqHostedTransportManager.cs
- ProxyWebPartManager.cs
- ValidatorCollection.cs
- UpdateManifestForBrowserApplication.cs
- JournalNavigationScope.cs
- CodeDomSerializer.cs
- ComponentConverter.cs
- WebPartCatalogCloseVerb.cs
- RegexCode.cs
- AnnotationStore.cs
- Interfaces.cs
- dbdatarecord.cs
- FieldAccessException.cs
- Sql8ConformanceChecker.cs
- TableItemStyle.cs
- BinaryFormatter.cs
- EntitySqlQueryBuilder.cs
- Matrix3D.cs
- FtpWebRequest.cs
- Native.cs
- FlowNode.cs
- ParallelForEach.cs
- FastEncoderStatics.cs
- pingexception.cs
- OracleRowUpdatedEventArgs.cs
- CacheVirtualItemsEvent.cs
- NavigationCommands.cs
- HitTestWithGeometryDrawingContextWalker.cs
- SafeArrayTypeMismatchException.cs
- SqlClientWrapperSmiStream.cs
- StreamSecurityUpgradeInitiatorAsyncResult.cs
- DataGridCellsPresenter.cs
- RequiredAttributeAttribute.cs
- MessageDecoder.cs
- ExpressionEditorAttribute.cs
- IssuanceLicense.cs
- DocumentPageViewAutomationPeer.cs
- CacheDependency.cs
- InputLanguageCollection.cs
- EventLogQuery.cs
- InternalConfigRoot.cs
- StringStorage.cs
- MimePart.cs
- JsonReaderWriterFactory.cs
- ControlPager.cs
- QueryOutputWriter.cs
- DataServiceQueryContinuation.cs
- DataGridViewRowErrorTextNeededEventArgs.cs
- ConstraintCollection.cs