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 / 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
- KeyValueInternalCollection.cs
- PointAnimationUsingKeyFrames.cs
- ImplicitInputBrush.cs
- GB18030Encoding.cs
- TdsParserStateObject.cs
- HMACSHA384.cs
- MissingMethodException.cs
- RecognizerStateChangedEventArgs.cs
- ExpressionPrinter.cs
- TabletDeviceInfo.cs
- CircleHotSpot.cs
- arclist.cs
- CompareValidator.cs
- DependencySource.cs
- DbConvert.cs
- InstanceDataCollectionCollection.cs
- CachingParameterInspector.cs
- FlagsAttribute.cs
- TreeNodeEventArgs.cs
- SystemFonts.cs
- SqlBuilder.cs
- TableLayoutPanel.cs
- WebBrowserContainer.cs
- ZipFileInfoCollection.cs
- CmsInterop.cs
- DbParameterCollectionHelper.cs
- DBProviderConfigurationHandler.cs
- KnownTypes.cs
- ObjectStateEntryDbUpdatableDataRecord.cs
- LastQueryOperator.cs
- BrowsableAttribute.cs
- RawStylusInputCustomData.cs
- JsonFaultDetail.cs
- DecimalConstantAttribute.cs
- WebPartCatalogCloseVerb.cs
- FactoryGenerator.cs
- ByteAnimation.cs
- RemoteWebConfigurationHost.cs
- TextCollapsingProperties.cs
- DocumentSchemaValidator.cs
- SqlDataSourceDesigner.cs
- VisualTreeHelper.cs
- ArrangedElementCollection.cs
- WindowsIdentity.cs
- StandardOleMarshalObject.cs
- HashHelper.cs
- CLSCompliantAttribute.cs
- WebPartConnectVerb.cs
- HtmlTernaryTree.cs
- ToolboxSnapDragDropEventArgs.cs
- XmlBoundElement.cs
- DocumentXmlWriter.cs
- MobilePage.cs
- TreeNodeStyleCollection.cs
- TCPListener.cs
- BitmapPalettes.cs
- DocumentPaginator.cs
- FormsAuthentication.cs
- PartialCachingControl.cs
- InlineCategoriesDocument.cs
- SafeIUnknown.cs
- RoutedPropertyChangedEventArgs.cs
- PersonalizablePropertyEntry.cs
- UIAgentInitializationException.cs
- Odbc32.cs
- ResourceDictionary.cs
- MulticastIPAddressInformationCollection.cs
- IChannel.cs
- PortCache.cs
- ImageButton.cs
- WebPartAuthorizationEventArgs.cs
- Wildcard.cs
- TraceInternal.cs
- StaticResourceExtension.cs
- Vars.cs
- MenuRendererStandards.cs
- TrackingStringDictionary.cs
- MediaEntryAttribute.cs
- Marshal.cs
- WorkflowFileItem.cs
- ApplicationDirectoryMembershipCondition.cs
- UDPClient.cs
- TableParagraph.cs
- DependencyPropertyValueSerializer.cs
- RadioButtonFlatAdapter.cs
- ObjectNotFoundException.cs
- ComponentResourceKey.cs
- wgx_render.cs
- KeysConverter.cs
- XmlSerializerFactory.cs
- DbDataReader.cs
- SqlPersonalizationProvider.cs
- UIElement.cs
- JpegBitmapDecoder.cs
- IgnoreSectionHandler.cs
- InstancePersistence.cs
- DocumentViewerBase.cs
- BufferedResponseStream.cs
- PropVariant.cs
- ListViewItemMouseHoverEvent.cs