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 Collection reasons = 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 Collection reasons = 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
- SettingsProviderCollection.cs
- DesignerTransactionCloseEvent.cs
- EventMappingSettings.cs
- SiteMapDataSource.cs
- ImageSource.cs
- regiisutil.cs
- ComboBox.cs
- EventProperty.cs
- ProxyElement.cs
- AttributedMetaModel.cs
- NumericPagerField.cs
- HotSpotCollection.cs
- TypeDependencyAttribute.cs
- UriSection.cs
- CodeArrayCreateExpression.cs
- JsonReader.cs
- ApplicationCommands.cs
- FormsAuthenticationUser.cs
- LogicalChannelCollection.cs
- XamlReaderHelper.cs
- GroupLabel.cs
- ParsedAttributeCollection.cs
- Clipboard.cs
- SchemaObjectWriter.cs
- SectionUpdates.cs
- ChangeNode.cs
- BoundField.cs
- WeakReferenceEnumerator.cs
- ComplexPropertyEntry.cs
- WorkflowMarkupSerializationManager.cs
- DbConnectionPoolGroupProviderInfo.cs
- EntityCommandExecutionException.cs
- ThreadStaticAttribute.cs
- HwndHost.cs
- MobileDeviceCapabilitiesSectionHandler.cs
- IIS7ConfigurationLoader.cs
- TextInfo.cs
- TextServicesDisplayAttribute.cs
- SecurityHelper.cs
- Matrix.cs
- HyperLinkDataBindingHandler.cs
- CodeAttributeDeclaration.cs
- NonceCache.cs
- ResourceLoader.cs
- WindowsAuthenticationModule.cs
- TreeView.cs
- GridViewRow.cs
- ConsumerConnectionPoint.cs
- DataProviderNameConverter.cs
- X509ChainPolicy.cs
- HashStream.cs
- RoutedEventConverter.cs
- CodePropertyReferenceExpression.cs
- HyperLink.cs
- XmlSchemaElement.cs
- InvariantComparer.cs
- ArcSegment.cs
- RunWorkerCompletedEventArgs.cs
- GroupStyle.cs
- SoapExtensionTypeElementCollection.cs
- XmlCompatibilityReader.cs
- ScrollPattern.cs
- HyperLink.cs
- ClickablePoint.cs
- BindingsCollection.cs
- PermissionAttributes.cs
- DynamicVirtualDiscoSearcher.cs
- XamlSerializerUtil.cs
- AccessibilityApplicationManager.cs
- MessageAction.cs
- KeyPullup.cs
- XmlWrappingReader.cs
- ComponentTray.cs
- X509SecurityToken.cs
- AncillaryOps.cs
- SafeRightsManagementSessionHandle.cs
- PersonalizationProvider.cs
- ClockGroup.cs
- httpserverutility.cs
- MethodAccessException.cs
- ServicePointManager.cs
- PagedDataSource.cs
- IPAddress.cs
- InlineObject.cs
- CompositeActivityCodeGenerator.cs
- BlurEffect.cs
- SafeProcessHandle.cs
- XPathParser.cs
- ProgressiveCrcCalculatingStream.cs
- PrintDialog.cs
- RTLAwareMessageBox.cs
- SpeechSynthesizer.cs
- Path.cs
- InputReportEventArgs.cs
- ByteArrayHelperWithString.cs
- DocumentViewerAutomationPeer.cs
- FaultDescriptionCollection.cs
- ExecutedRoutedEventArgs.cs
- UpdatePanelTriggerCollection.cs
- EditingCommands.cs