Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / 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
- XPathNode.cs
- PropertyEmitter.cs
- _ConnectOverlappedAsyncResult.cs
- ClipboardProcessor.cs
- ChannelTerminatedException.cs
- ItemCollection.cs
- MatrixTransform.cs
- ClockController.cs
- DataGridViewColumnTypeEditor.cs
- __Error.cs
- InputLanguageSource.cs
- SchemaTableColumn.cs
- ChangeBlockUndoRecord.cs
- DateTimeFormat.cs
- CallSiteHelpers.cs
- XappLauncher.cs
- DataControlField.cs
- SqlXml.cs
- RectValueSerializer.cs
- CounterNameConverter.cs
- Button.cs
- CompositeKey.cs
- SchemaInfo.cs
- ArgumentNullException.cs
- PointLight.cs
- HtmlTextArea.cs
- ContentElementAutomationPeer.cs
- SerializationAttributes.cs
- PackageDigitalSignature.cs
- OLEDB_Util.cs
- DataGridViewUtilities.cs
- DrawingGroup.cs
- ServiceReference.cs
- AssociationSet.cs
- PageCodeDomTreeGenerator.cs
- StringAnimationBase.cs
- RuntimeConfig.cs
- SecurityTokenResolver.cs
- Brush.cs
- PropertyEmitterBase.cs
- HashHelper.cs
- TableLayoutSettingsTypeConverter.cs
- SafeRightsManagementQueryHandle.cs
- Int32Rect.cs
- SrgsText.cs
- XmlSerializerNamespaces.cs
- ImageDrawing.cs
- TextSpan.cs
- ListViewTableCell.cs
- AsymmetricKeyExchangeFormatter.cs
- ToolboxDataAttribute.cs
- Int32.cs
- ContentHostHelper.cs
- StoreContentChangedEventArgs.cs
- PrintController.cs
- ServerType.cs
- TextDataBindingHandler.cs
- SchemaTableOptionalColumn.cs
- FunctionMappingTranslator.cs
- GenericAuthenticationEventArgs.cs
- ResourcePermissionBase.cs
- SymbolType.cs
- LoadMessageLogger.cs
- AppDomainFactory.cs
- NameValuePermission.cs
- QueryExecutionOption.cs
- Configuration.cs
- ReadOnlyTernaryTree.cs
- sqlmetadatafactory.cs
- formatter.cs
- TextPenaltyModule.cs
- HttpHandlerAction.cs
- CommandHelpers.cs
- DisplayMemberTemplateSelector.cs
- PenLineJoinValidation.cs
- ScriptComponentDescriptor.cs
- TextOutput.cs
- ScriptRegistrationManager.cs
- StringToken.cs
- ObjectContextServiceProvider.cs
- nulltextnavigator.cs
- ToolStripEditorManager.cs
- XmlNamespaceMappingCollection.cs
- GeneralTransform3DTo2DTo3D.cs
- MemberPath.cs
- GraphicsPath.cs
- MulticastIPAddressInformationCollection.cs
- Int64Storage.cs
- ImageList.cs
- DataObjectPastingEventArgs.cs
- Pkcs7Recipient.cs
- IntranetCredentialPolicy.cs
- DbBuffer.cs
- OverlappedAsyncResult.cs
- ResourcesBuildProvider.cs
- AesManaged.cs
- IisHelper.cs
- CallContext.cs
- EventKeyword.cs
- initElementDictionary.cs