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
- CommonEndpointBehaviorElement.cs
- AppSettingsExpressionBuilder.cs
- ArraySegment.cs
- ListViewInsertedEventArgs.cs
- SuppressMessageAttribute.cs
- StrongNamePublicKeyBlob.cs
- MessageDecoder.cs
- ConnectionManagementElement.cs
- DefaultAssemblyResolver.cs
- SqlCacheDependencySection.cs
- SpeakCompletedEventArgs.cs
- RegistryDataKey.cs
- BitmapEffectDrawingContextWalker.cs
- ArglessEventHandlerProxy.cs
- EventLogTraceListener.cs
- BasicHttpSecurityElement.cs
- Pkcs7Recipient.cs
- MessagingActivityHelper.cs
- GeneralTransformCollection.cs
- ZoneIdentityPermission.cs
- RepeatBehavior.cs
- HttpCapabilitiesBase.cs
- ObjectAnimationUsingKeyFrames.cs
- RealizationDrawingContextWalker.cs
- NativeMethods.cs
- Stack.cs
- regiisutil.cs
- SecurityTokenSerializer.cs
- DeferrableContent.cs
- DataSourceComponent.cs
- Constraint.cs
- dataobject.cs
- CompilerWrapper.cs
- HtmlLink.cs
- ConditionalBranch.cs
- HtmlInputPassword.cs
- Authorization.cs
- ValidationSummaryDesigner.cs
- TableAutomationPeer.cs
- SerializerDescriptor.cs
- ColumnClickEvent.cs
- Function.cs
- PriorityChain.cs
- StylusTip.cs
- DesignConnection.cs
- BitmapEffectDrawing.cs
- CachedFontFace.cs
- LineServices.cs
- DrawingGroup.cs
- OdbcConnectionOpen.cs
- SessionParameter.cs
- ExecutorLocksHeldException.cs
- HitTestWithGeometryDrawingContextWalker.cs
- EditorAttributeInfo.cs
- ExpressionVisitor.cs
- RelOps.cs
- MembershipSection.cs
- NetDispatcherFaultException.cs
- EUCJPEncoding.cs
- MessageBox.cs
- ProviderBase.cs
- IntegrationExceptionEventArgs.cs
- Connector.cs
- Journal.cs
- AnimationException.cs
- StringPropertyBuilder.cs
- AuthenticationModulesSection.cs
- BindingExpressionUncommonField.cs
- _BufferOffsetSize.cs
- TargetParameterCountException.cs
- MsmqAppDomainProtocolHandler.cs
- ParameterReplacerVisitor.cs
- XPathMessageContext.cs
- MappedMetaModel.cs
- TripleDESCryptoServiceProvider.cs
- CommandHelper.cs
- ObsoleteAttribute.cs
- X509CertificateValidator.cs
- ExpressionVisitorHelpers.cs
- Merger.cs
- DesignBindingPropertyDescriptor.cs
- SystemIPInterfaceStatistics.cs
- WindowsListViewGroupHelper.cs
- ToolStripEditorManager.cs
- SqlCommand.cs
- CatalogZone.cs
- ConstantSlot.cs
- RadioButton.cs
- ServiceDescriptionReflector.cs
- KnownColorTable.cs
- EntitySetRetriever.cs
- TextureBrush.cs
- IPCCacheManager.cs
- ScriptRegistrationManager.cs
- ToolStripItemDesigner.cs
- Base64Encoder.cs
- GcSettings.cs
- BufferedGraphics.cs
- PersonalizationEntry.cs
- IisTraceWebEventProvider.cs