Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / ndp / fx / src / DLinq / Dlinq / SqlClient / Common / SqlServer2KCompatibilityCheck.cs / 1 / SqlServer2KCompatibilityCheck.cs
using System; using System.Collections.ObjectModel; using System.Text; namespace System.Data.Linq.SqlClient { ////// Methods for checking whethe a query was compatible with the /// server it will be sent to. /// static internal class SqlServerCompatibilityCheck { ////// Private visitor class checks each node for compatibility annotations. /// private class Visitor : SqlVisitor { private SqlProvider.ProviderMode provider; internal SqlNodeAnnotations annotations; internal Visitor(SqlProvider.ProviderMode provider) { this.provider = provider; } ////// The reasons why this query is not 2K compatible. /// internal Collectionreasons = new Collection (); internal override SqlNode Visit(SqlNode node) { if (annotations.NodeIsAnnotated(node)) { foreach (SqlNodeAnnotation annotation in annotations.Get(node)) { SqlServerCompatibilityAnnotation ssca = annotation as SqlServerCompatibilityAnnotation; if (ssca != null && ssca.AppliesTo(provider)) { reasons.Add(annotation.Message); } } } return base.Visit(node); } } /// /// Checks whether the given node is supported on the given server. /// internal static void ThrowIfUnsupported(SqlNode node, SqlNodeAnnotations annotations, SqlProvider.ProviderMode provider) { // Check to see whether there's at least one SqlServerCompatibilityAnnotation. if (annotations.HasAnnotationType(typeof(SqlServerCompatibilityAnnotation))) { Visitor visitor = new Visitor(provider); visitor.annotations = annotations; visitor.Visit(node); // If any messages were recorded, then throw an exception. if (visitor.reasons.Count > 0) { throw Error.ExpressionNotSupportedForSqlServerVersion(visitor.reasons); } } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. using System; using System.Collections.ObjectModel; using System.Text; namespace System.Data.Linq.SqlClient { ////// Methods for checking whethe a query was compatible with the /// server it will be sent to. /// static internal class SqlServerCompatibilityCheck { ////// Private visitor class checks each node for compatibility annotations. /// private class Visitor : SqlVisitor { private SqlProvider.ProviderMode provider; internal SqlNodeAnnotations annotations; internal Visitor(SqlProvider.ProviderMode provider) { this.provider = provider; } ////// The reasons why this query is not 2K compatible. /// internal Collectionreasons = new Collection (); internal override SqlNode Visit(SqlNode node) { if (annotations.NodeIsAnnotated(node)) { foreach (SqlNodeAnnotation annotation in annotations.Get(node)) { SqlServerCompatibilityAnnotation ssca = annotation as SqlServerCompatibilityAnnotation; if (ssca != null && ssca.AppliesTo(provider)) { reasons.Add(annotation.Message); } } } return base.Visit(node); } } /// /// Checks whether the given node is supported on the given server. /// internal static void ThrowIfUnsupported(SqlNode node, SqlNodeAnnotations annotations, SqlProvider.ProviderMode provider) { // Check to see whether there's at least one SqlServerCompatibilityAnnotation. if (annotations.HasAnnotationType(typeof(SqlServerCompatibilityAnnotation))) { Visitor visitor = new Visitor(provider); visitor.annotations = annotations; visitor.Visit(node); // If any messages were recorded, then throw an exception. if (visitor.reasons.Count > 0) { throw Error.ExpressionNotSupportedForSqlServerVersion(visitor.reasons); } } } } } // 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
- GACIdentityPermission.cs
- PagedControl.cs
- FrameworkObject.cs
- HttpContext.cs
- ListViewVirtualItemsSelectionRangeChangedEvent.cs
- WebRequestModuleElement.cs
- CopyAction.cs
- DoubleLink.cs
- BindingMAnagerBase.cs
- EdmToObjectNamespaceMap.cs
- CacheForPrimitiveTypes.cs
- SqlNamer.cs
- DataProtection.cs
- Cursors.cs
- GACIdentityPermission.cs
- DBNull.cs
- LookupNode.cs
- TextElementCollectionHelper.cs
- DataGridViewAutoSizeColumnsModeEventArgs.cs
- XD.cs
- CounterNameConverter.cs
- ExpressionVisitor.cs
- PropertyStore.cs
- SpinLock.cs
- SqlResolver.cs
- ClrPerspective.cs
- PseudoWebRequest.cs
- WorkerRequest.cs
- ClientEndpointLoader.cs
- RoleExceptions.cs
- InternalsVisibleToAttribute.cs
- DesignerProperties.cs
- XmlSchemaAppInfo.cs
- CharConverter.cs
- DbConnectionFactory.cs
- DataServiceQueryContinuation.cs
- PenCursorManager.cs
- SortFieldComparer.cs
- ResolveCriteriaApril2005.cs
- ToolStripHighContrastRenderer.cs
- SiteOfOriginPart.cs
- Adorner.cs
- PageBreakRecord.cs
- AuthenticationConfig.cs
- LayoutEvent.cs
- ToolBarOverflowPanel.cs
- EventSetterHandlerConverter.cs
- GlyphsSerializer.cs
- CaseInsensitiveComparer.cs
- TextRange.cs
- ConfigurationErrorsException.cs
- Rotation3DKeyFrameCollection.cs
- TypeUsageBuilder.cs
- ReliableMessagingVersionConverter.cs
- CellCreator.cs
- _OverlappedAsyncResult.cs
- ContentIterators.cs
- indexingfiltermarshaler.cs
- XMLSyntaxException.cs
- CornerRadiusConverter.cs
- GridViewColumn.cs
- DeobfuscatingStream.cs
- AsymmetricKeyExchangeDeformatter.cs
- ClickablePoint.cs
- ToolStripContentPanelRenderEventArgs.cs
- FileAuthorizationModule.cs
- WindowsToolbarItemAsMenuItem.cs
- _ConnectStream.cs
- CompilerState.cs
- WebPartTransformerAttribute.cs
- WebPartTransformer.cs
- DetailsViewDesigner.cs
- LinkButton.cs
- GeneralTransformGroup.cs
- XmlCustomFormatter.cs
- Comparer.cs
- ComNativeDescriptor.cs
- PageResolution.cs
- RuleInfoComparer.cs
- SizeFConverter.cs
- IgnoreSection.cs
- SelectionGlyph.cs
- CodeExpressionCollection.cs
- SessionStateModule.cs
- ResourcesGenerator.cs
- BamlRecordHelper.cs
- basemetadatamappingvisitor.cs
- _AuthenticationState.cs
- EventPropertyMap.cs
- Imaging.cs
- HttpPostLocalhostServerProtocol.cs
- Timer.cs
- AnimatedTypeHelpers.cs
- UIPropertyMetadata.cs
- PlainXmlWriter.cs
- DatePickerTextBox.cs
- ComponentCollection.cs
- UnsafeNetInfoNativeMethods.cs
- localization.cs
- ResourceExpressionBuilder.cs