Code:
/ 4.0 / 4.0 / 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. 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
- Profiler.cs
- Helpers.cs
- RightsManagementEncryptedStream.cs
- DiagnosticTraceSource.cs
- Debug.cs
- SqlHelper.cs
- Vector.cs
- WebConfigManager.cs
- WorkflowRuntime.cs
- SchemaNames.cs
- QilPatternVisitor.cs
- StreamResourceInfo.cs
- AvTrace.cs
- InputLanguageManager.cs
- QueryStringHandler.cs
- HttpRequestTraceRecord.cs
- X509ClientCertificateAuthenticationElement.cs
- WindowsUserNameCachingSecurityTokenAuthenticator.cs
- SqlBooleanizer.cs
- CompiledXpathExpr.cs
- MDIClient.cs
- SafeNativeMethods.cs
- SafeProcessHandle.cs
- PreviewPrintController.cs
- RegexCode.cs
- BaseUriHelper.cs
- NamedPipeWorkerProcess.cs
- RegexTree.cs
- FormView.cs
- OutKeywords.cs
- ColumnMapVisitor.cs
- TrustSection.cs
- SqlNamer.cs
- SplashScreenNativeMethods.cs
- AddInToken.cs
- Command.cs
- Persist.cs
- GZipStream.cs
- PrivateFontCollection.cs
- PriorityBinding.cs
- TaskFileService.cs
- PeerNode.cs
- DataGridViewRowConverter.cs
- KeyEvent.cs
- StrokeDescriptor.cs
- Attributes.cs
- SizeChangedEventArgs.cs
- SessionEndingCancelEventArgs.cs
- CopyCodeAction.cs
- TableCell.cs
- MediaPlayer.cs
- FileUtil.cs
- ThreadStaticAttribute.cs
- Executor.cs
- TransactionBridge.cs
- HtmlShimManager.cs
- BaseParaClient.cs
- IProvider.cs
- SqlOuterApplyReducer.cs
- DBSqlParser.cs
- FixedPageAutomationPeer.cs
- SqlGenericUtil.cs
- WmlTextBoxAdapter.cs
- VisualTreeFlattener.cs
- ObjectItemCachedAssemblyLoader.cs
- Visitors.cs
- SoapSchemaMember.cs
- UnionCodeGroup.cs
- GenericTextProperties.cs
- PanningMessageFilter.cs
- BasicHttpBindingElement.cs
- ConfigXmlCDataSection.cs
- EntityException.cs
- SequentialUshortCollection.cs
- BindUriHelper.cs
- EpmSyndicationContentSerializer.cs
- PerformanceCounterLib.cs
- Vector3DAnimationBase.cs
- SelectedPathEditor.cs
- MsmqIntegrationAppDomainProtocolHandler.cs
- XsltLoader.cs
- WmpBitmapDecoder.cs
- Schema.cs
- StringConcat.cs
- BlockExpression.cs
- WebPartHelpVerb.cs
- ImageSourceConverter.cs
- SHA512Managed.cs
- HostingEnvironment.cs
- FamilyCollection.cs
- SplitterDesigner.cs
- SHA512Managed.cs
- WebEventTraceProvider.cs
- BitConverter.cs
- PermissionSetEnumerator.cs
- x509store.cs
- BrowserCapabilitiesCodeGenerator.cs
- ObjectReferenceStack.cs
- CommandTreeTypeHelper.cs
- Task.cs