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
- OutOfProcStateClientManager.cs
- X509UI.cs
- DelimitedListTraceListener.cs
- ConfigurationElementCollection.cs
- ProtocolsConfiguration.cs
- ValidatingPropertiesEventArgs.cs
- EmptyImpersonationContext.cs
- DocumentOrderQuery.cs
- RequestStatusBarUpdateEventArgs.cs
- ChangeTracker.cs
- ImmutableObjectAttribute.cs
- RelationshipEndMember.cs
- ArraySegment.cs
- EventMap.cs
- XAMLParseException.cs
- EmptyArray.cs
- TypeNameHelper.cs
- HtmlTextArea.cs
- Empty.cs
- DPTypeDescriptorContext.cs
- UserNamePasswordValidator.cs
- DbProviderFactories.cs
- SQLInt32.cs
- OAVariantLib.cs
- LinqDataSourceInsertEventArgs.cs
- DataProviderNameConverter.cs
- DataTableNewRowEvent.cs
- RecognizerInfo.cs
- RoleBoolean.cs
- Rectangle.cs
- ViewStateModeByIdAttribute.cs
- Function.cs
- CodeMemberField.cs
- Int32.cs
- DataContractSet.cs
- MessageQueueKey.cs
- DateTimeConstantAttribute.cs
- DataPagerFieldCollection.cs
- TextPattern.cs
- DBDataPermissionAttribute.cs
- RoutedCommand.cs
- KnownBoxes.cs
- TextServicesLoader.cs
- RelatedPropertyManager.cs
- SHA1Managed.cs
- XmlReturnWriter.cs
- ToolBar.cs
- Types.cs
- ExecutionContext.cs
- HttpProxyTransportBindingElement.cs
- SubqueryTrackingVisitor.cs
- FloaterParaClient.cs
- ModifierKeysValueSerializer.cs
- PerspectiveCamera.cs
- InputMethodStateTypeInfo.cs
- SignedPkcs7.cs
- XmlSchemaSimpleContentExtension.cs
- ContextDataSourceContextData.cs
- ProfileGroupSettings.cs
- ServiceHostFactory.cs
- ValidatedControlConverter.cs
- Vertex.cs
- LogLogRecordHeader.cs
- ResXResourceSet.cs
- ColorBlend.cs
- HttpModuleCollection.cs
- LinkDesigner.cs
- BindStream.cs
- ApplicationSettingsBase.cs
- Validator.cs
- Pen.cs
- ExtensionFile.cs
- LinqDataSourceUpdateEventArgs.cs
- QueryPageSettingsEventArgs.cs
- DataGridViewRowHeaderCell.cs
- SequentialUshortCollection.cs
- ContentElement.cs
- UpdateProgress.cs
- EventBuilder.cs
- _NtlmClient.cs
- CodeDomLocalizationProvider.cs
- RadialGradientBrush.cs
- DataException.cs
- SqlMethodAttribute.cs
- ObjectHandle.cs
- ColorIndependentAnimationStorage.cs
- FormsAuthenticationUserCollection.cs
- XNameTypeConverter.cs
- TableLayoutPanelBehavior.cs
- TreeNodeBinding.cs
- MetafileHeader.cs
- WhitespaceSignificantCollectionAttribute.cs
- LongValidatorAttribute.cs
- DelegateBodyWriter.cs
- ControlIdConverter.cs
- ConnectionPoint.cs
- HashSet.cs
- DataBoundControlHelper.cs
- MarshalDirectiveException.cs
- MemberPathMap.cs