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
- ToolStripItemImageRenderEventArgs.cs
- InvalidProgramException.cs
- ListDesigner.cs
- MediaEntryAttribute.cs
- RIPEMD160Managed.cs
- DocumentSchemaValidator.cs
- FamilyCollection.cs
- UTF32Encoding.cs
- SqlConnectionFactory.cs
- SiteMapNodeItemEventArgs.cs
- BaseCodeDomTreeGenerator.cs
- ResourcesChangeInfo.cs
- NullableDoubleSumAggregationOperator.cs
- EpmContentSerializer.cs
- Point.cs
- MarkedHighlightComponent.cs
- LoginName.cs
- DataGridItemCollection.cs
- LiteralTextContainerControlBuilder.cs
- CallContext.cs
- AssemblyHash.cs
- Equal.cs
- HostUtils.cs
- TextElementCollection.cs
- Stackframe.cs
- WindowsClientElement.cs
- RuleEngine.cs
- WebPartDisplayModeEventArgs.cs
- NamespaceQuery.cs
- ParseHttpDate.cs
- NullableDoubleSumAggregationOperator.cs
- PngBitmapDecoder.cs
- GreenMethods.cs
- CellParaClient.cs
- GenericParameterDataContract.cs
- MouseEventArgs.cs
- Vector3dCollection.cs
- SqlInternalConnectionTds.cs
- KnownIds.cs
- CheckBoxList.cs
- SamlAction.cs
- BitmapCodecInfo.cs
- Italic.cs
- TokenBasedSet.cs
- DataGridColumn.cs
- PropertyTabAttribute.cs
- Sequence.cs
- UnsupportedPolicyOptionsException.cs
- TextServicesDisplayAttribute.cs
- Cursor.cs
- Odbc32.cs
- ActiveXContainer.cs
- MarginCollapsingState.cs
- MulticastOption.cs
- KeyValueSerializer.cs
- Expressions.cs
- DataGridViewImageColumn.cs
- CacheVirtualItemsEvent.cs
- SafeCertificateStore.cs
- SessionStateContainer.cs
- DataColumnMapping.cs
- DataGridViewAccessibleObject.cs
- RenderTargetBitmap.cs
- PermissionAttributes.cs
- CLRBindingWorker.cs
- CustomCredentialPolicy.cs
- StylusPointPropertyId.cs
- EventMap.cs
- UpdateExpressionVisitor.cs
- ConvertEvent.cs
- FixedSOMPageElement.cs
- QualificationDataAttribute.cs
- MarkupExtensionReturnTypeAttribute.cs
- SQLDoubleStorage.cs
- StrokeDescriptor.cs
- LoadRetryHandler.cs
- ServiceOperationParameter.cs
- DeploymentExceptionMapper.cs
- AsyncCompletedEventArgs.cs
- HandleCollector.cs
- IgnoreFileBuildProvider.cs
- WebPartTracker.cs
- TypeConverterHelper.cs
- Pen.cs
- CategoryGridEntry.cs
- clipboard.cs
- HideDisabledControlAdapter.cs
- EventProxy.cs
- TabletDeviceInfo.cs
- DesignerHost.cs
- SerializationSectionGroup.cs
- FormsAuthentication.cs
- ReservationCollection.cs
- StrongNameUtility.cs
- ValidatingPropertiesEventArgs.cs
- HttpModuleActionCollection.cs
- HMACMD5.cs
- Brush.cs
- SessionSymmetricTransportSecurityProtocolFactory.cs
- WindowInteractionStateTracker.cs