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
- CustomAssemblyResolver.cs
- DrawingBrush.cs
- ReliabilityContractAttribute.cs
- MessageSecurityOverMsmq.cs
- SuppressMergeCheckAttribute.cs
- SignatureToken.cs
- GotoExpression.cs
- SoapHttpTransportImporter.cs
- TypedDataSetSchemaImporterExtension.cs
- RadioButtonBaseAdapter.cs
- SmtpFailedRecipientsException.cs
- HttpRequest.cs
- CompilerTypeWithParams.cs
- ConfigUtil.cs
- ReferencedCollectionType.cs
- WebPartRestoreVerb.cs
- HttpStaticObjectsCollectionBase.cs
- KeyValuePair.cs
- ToolStripLabel.cs
- SortableBindingList.cs
- Pointer.cs
- ComplexPropertyEntry.cs
- oledbmetadatacollectionnames.cs
- EdmType.cs
- SqlDataAdapter.cs
- LinkedResource.cs
- PerfCounterSection.cs
- HttpApplication.cs
- RayMeshGeometry3DHitTestResult.cs
- EntityDataSourceContextCreatingEventArgs.cs
- TemplateBindingExpressionConverter.cs
- FileLevelControlBuilderAttribute.cs
- DesignerPerfEventProvider.cs
- DefaultValueAttribute.cs
- DocumentXPathNavigator.cs
- DetailsViewInsertedEventArgs.cs
- ComponentGlyph.cs
- ToolboxItemAttribute.cs
- HeaderUtility.cs
- CommonXSendMessage.cs
- DataSourceCacheDurationConverter.cs
- ColumnHeaderCollectionEditor.cs
- SuppressMergeCheckAttribute.cs
- TextRunCacheImp.cs
- EdgeModeValidation.cs
- AnnotationResourceCollection.cs
- ComplexTypeEmitter.cs
- SqlDataSourceCommandEventArgs.cs
- TypeUtil.cs
- TraceHwndHost.cs
- InvalidProgramException.cs
- TransformedBitmap.cs
- ClipboardProcessor.cs
- DataControlFieldCollection.cs
- LicenseProviderAttribute.cs
- MbpInfo.cs
- ValidatingPropertiesEventArgs.cs
- RegexFCD.cs
- Assert.cs
- TreeViewImageKeyConverter.cs
- HttpRuntimeSection.cs
- ConnectorEditor.cs
- PerfCounterSection.cs
- MarkupWriter.cs
- ReadOnlyHierarchicalDataSource.cs
- ExplicitDiscriminatorMap.cs
- _CookieModule.cs
- BaseResourcesBuildProvider.cs
- DomNameTable.cs
- KnowledgeBase.cs
- As.cs
- CodeCommentStatementCollection.cs
- RegexBoyerMoore.cs
- RangeValidator.cs
- METAHEADER.cs
- BrowserTree.cs
- PropertyGeneratedEventArgs.cs
- WindowsEditBoxRange.cs
- ParameterExpression.cs
- EventProxy.cs
- HttpStreamMessage.cs
- ToolStripHighContrastRenderer.cs
- NavigationPropertyEmitter.cs
- SiteMapPath.cs
- FontStyles.cs
- SemanticAnalyzer.cs
- UncommonField.cs
- DecoderExceptionFallback.cs
- ServiceDescription.cs
- TypographyProperties.cs
- StatusBarItem.cs
- PageAsyncTask.cs
- XsltContext.cs
- StructuralCache.cs
- CodeValidator.cs
- CharEntityEncoderFallback.cs
- WebPartTransformer.cs
- PlainXmlDeserializer.cs
- SizeAnimationUsingKeyFrames.cs
- EdmItemCollection.OcAssemblyCache.cs