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
- ConfigUtil.cs
- VirtualPathUtility.cs
- BuildResultCache.cs
- HotSpotCollection.cs
- Dynamic.cs
- FileDetails.cs
- FontStretch.cs
- GridViewHeaderRowPresenterAutomationPeer.cs
- CodeThrowExceptionStatement.cs
- MatcherBuilder.cs
- ReaderOutput.cs
- DataSourceExpressionCollection.cs
- ProcessHostConfigUtils.cs
- AdapterDictionary.cs
- ValidationErrorCollection.cs
- SimpleBitVector32.cs
- DBPropSet.cs
- CorrelationScope.cs
- SocketException.cs
- TransactionsSectionGroup.cs
- HandlerMappingMemo.cs
- ComponentDispatcher.cs
- IndividualDeviceConfig.cs
- _NTAuthentication.cs
- DataContractJsonSerializerOperationFormatter.cs
- BrowserInteropHelper.cs
- SoapRpcMethodAttribute.cs
- SystemWebCachingSectionGroup.cs
- MimeFormatter.cs
- ReflectEventDescriptor.cs
- ProcessModule.cs
- ProfileGroupSettingsCollection.cs
- PropertyValue.cs
- sqlcontext.cs
- ColumnClickEvent.cs
- BitmapImage.cs
- ChannelToken.cs
- OdbcEnvironment.cs
- ObjectStorage.cs
- GeneralTransform2DTo3DTo2D.cs
- DataIdProcessor.cs
- relpropertyhelper.cs
- DropSourceBehavior.cs
- Literal.cs
- InstanceStoreQueryResult.cs
- CompatibleComparer.cs
- PauseStoryboard.cs
- WebPartChrome.cs
- WorkflowServiceHost.cs
- SqlProcedureAttribute.cs
- DomainUpDown.cs
- LoadedOrUnloadedOperation.cs
- OdbcConnectionHandle.cs
- DesignerFrame.cs
- FloaterParaClient.cs
- ImageIndexConverter.cs
- DataKeyArray.cs
- ThreadAbortException.cs
- DataListItemEventArgs.cs
- IndexedString.cs
- OdbcFactory.cs
- TextureBrush.cs
- Gdiplus.cs
- DiscoveryReferences.cs
- EasingQuaternionKeyFrame.cs
- DesignTimeTemplateParser.cs
- TypeElement.cs
- TdsParser.cs
- FontResourceCache.cs
- MgmtConfigurationRecord.cs
- Dictionary.cs
- TreeNodeStyleCollection.cs
- WebBrowserUriTypeConverter.cs
- XmlParserContext.cs
- SecurityException.cs
- FontCacheUtil.cs
- ProxyFragment.cs
- GridViewUpdatedEventArgs.cs
- Boolean.cs
- CodeEventReferenceExpression.cs
- CodeObject.cs
- ListBoxItemWrapperAutomationPeer.cs
- HtmlInputControl.cs
- UnaryNode.cs
- FieldInfo.cs
- TraceContextEventArgs.cs
- Semaphore.cs
- DataGridViewDesigner.cs
- XmlCharType.cs
- DbSetClause.cs
- WebServiceErrorEvent.cs
- EventProperty.cs
- EditorPart.cs
- OrderedDictionary.cs
- WindowsPrincipal.cs
- TextViewBase.cs
- WSUtilitySpecificationVersion.cs
- ItemContainerGenerator.cs
- SubpageParagraph.cs
- ChangeProcessor.cs