Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / ndp / fx / src / DLinq / Dlinq / SqlClient / Query / SqlCrossApplyToCrossJoin.cs / 1 / 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
- TextRangeEditLists.cs
- ParagraphVisual.cs
- PropertiesTab.cs
- Point4DValueSerializer.cs
- DataColumnMapping.cs
- RSAOAEPKeyExchangeDeformatter.cs
- InteropBitmapSource.cs
- _SSPIWrapper.cs
- ValidationSummary.cs
- DetailsViewInsertEventArgs.cs
- ApplicationTrust.cs
- CatalogPart.cs
- DiscoveryClientProtocol.cs
- DesignerVerbToolStripMenuItem.cs
- KeyedByTypeCollection.cs
- MemberInitExpression.cs
- KeyValuePairs.cs
- RouteParametersHelper.cs
- QilDataSource.cs
- AssemblySettingAttributes.cs
- FileUpload.cs
- XmlUtil.cs
- RadioButtonList.cs
- PropertyEmitter.cs
- XmlRawWriter.cs
- DesignerTextWriter.cs
- InvalidPropValue.cs
- WebPartCloseVerb.cs
- ByteAnimationBase.cs
- DateTime.cs
- LocationUpdates.cs
- WorkflowViewStateService.cs
- QueryOpcode.cs
- XsdDateTime.cs
- OleDbFactory.cs
- SmuggledIUnknown.cs
- wgx_sdk_version.cs
- VisualTransition.cs
- TdsEnums.cs
- BamlVersionHeader.cs
- FolderBrowserDialog.cs
- TextEditorContextMenu.cs
- GlobalDataBindingHandler.cs
- XmlRawWriterWrapper.cs
- SamlAssertionDirectKeyIdentifierClause.cs
- CallTemplateAction.cs
- UIElementCollection.cs
- UiaCoreTypesApi.cs
- FontUnit.cs
- DocumentViewerBaseAutomationPeer.cs
- ReturnEventArgs.cs
- StrokeRenderer.cs
- IntegerCollectionEditor.cs
- ScriptResourceDefinition.cs
- ProviderMetadata.cs
- InputLangChangeEvent.cs
- EventLogPermissionEntryCollection.cs
- ViewPort3D.cs
- CellConstant.cs
- SelectionBorderGlyph.cs
- ApplicationManager.cs
- SqlDependency.cs
- AutomationPatternInfo.cs
- ObjectStateEntryBaseUpdatableDataRecord.cs
- __FastResourceComparer.cs
- PasswordBoxAutomationPeer.cs
- PropertyValueChangedEvent.cs
- CacheDependency.cs
- IndexedString.cs
- XmlSequenceWriter.cs
- Thread.cs
- ExpressionConverter.cs
- Model3D.cs
- _IPv4Address.cs
- PieceNameHelper.cs
- MergablePropertyAttribute.cs
- CodeIdentifier.cs
- XsdBuildProvider.cs
- GridViewAutomationPeer.cs
- ScaleTransform.cs
- ApplicationManager.cs
- TdsParserSessionPool.cs
- TabPanel.cs
- RawKeyboardInputReport.cs
- SequentialUshortCollection.cs
- VariableAction.cs
- DataGridViewBand.cs
- CodeParameterDeclarationExpression.cs
- ArraySegment.cs
- RegexFCD.cs
- TypedReference.cs
- SpecialNameAttribute.cs
- WebPartDisplayModeCancelEventArgs.cs
- TextParagraphCache.cs
- SAPICategories.cs
- QueryInterceptorAttribute.cs
- Enlistment.cs
- xmlsaver.cs
- XamlGridLengthSerializer.cs
- TemplatedAdorner.cs