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
- CalendarKeyboardHelper.cs
- WorkflowOperationInvoker.cs
- TextParagraphProperties.cs
- SqlConnectionManager.cs
- DbConnectionStringBuilder.cs
- ModelItemImpl.cs
- TextServicesContext.cs
- FileLoadException.cs
- ExpressionBuilder.cs
- NameValuePair.cs
- TreeNodeStyle.cs
- ToolStripLocationCancelEventArgs.cs
- Misc.cs
- RepeatBehavior.cs
- CacheChildrenQuery.cs
- AliasExpr.cs
- PeerNameRecordCollection.cs
- X509UI.cs
- ExceptionHandlers.cs
- QueryGenerator.cs
- WebPartConnectionsEventArgs.cs
- NameValueFileSectionHandler.cs
- QuotedPrintableStream.cs
- Unit.cs
- FormatSettings.cs
- ErrorTableItemStyle.cs
- XmlCustomFormatter.cs
- WindowsSlider.cs
- NewArrayExpression.cs
- StylusPointDescription.cs
- BaseAppDomainProtocolHandler.cs
- ObjectFactoryCodeDomTreeGenerator.cs
- Speller.cs
- ScriptingScriptResourceHandlerSection.cs
- CharAnimationUsingKeyFrames.cs
- ResourceProperty.cs
- Permission.cs
- EditorPartCollection.cs
- DataGridTable.cs
- diagnosticsswitches.cs
- XmlElementCollection.cs
- SizeChangedInfo.cs
- GradientStop.cs
- CodeDOMUtility.cs
- DetailsViewInsertEventArgs.cs
- GroupQuery.cs
- ListViewDataItem.cs
- SqlReferenceCollection.cs
- UnitySerializationHolder.cs
- MetadataElement.cs
- ListMarkerLine.cs
- __Error.cs
- CounterCreationData.cs
- ProcessHostServerConfig.cs
- ConnectionConsumerAttribute.cs
- AmbientProperties.cs
- FSWPathEditor.cs
- RepeaterDataBoundAdapter.cs
- FontWeights.cs
- OracleCommandSet.cs
- DbBuffer.cs
- LinqDataSource.cs
- VisualTreeFlattener.cs
- CheckBox.cs
- RangeBase.cs
- ScriptServiceAttribute.cs
- RegularExpressionValidator.cs
- ServiceDescriptionSerializer.cs
- AttributeCollection.cs
- Array.cs
- ReturnValue.cs
- FloaterBaseParagraph.cs
- TrustManager.cs
- cryptoapiTransform.cs
- SequenceDesignerAccessibleObject.cs
- TextHidden.cs
- IdnMapping.cs
- Root.cs
- X509Certificate2Collection.cs
- Point3DCollection.cs
- PlainXmlSerializer.cs
- parserscommon.cs
- LayoutManager.cs
- CrossAppDomainChannel.cs
- _HTTPDateParse.cs
- HttpValueCollection.cs
- WindowsStreamSecurityUpgradeProvider.cs
- RenderContext.cs
- ClientConvert.cs
- RIPEMD160Managed.cs
- ResourceWriter.cs
- GlobalizationSection.cs
- Membership.cs
- ObjectStateEntryDbDataRecord.cs
- UserNamePasswordClientCredential.cs
- CultureTableRecord.cs
- FileAuthorizationModule.cs
- ClientSession.cs
- CngKeyBlobFormat.cs
- XmlValidatingReader.cs