Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DLinq / Dlinq / SqlClient / Common / SqlServer2KCompatibilityCheck.cs / 1305376 / 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
- XmlSecureResolver.cs
- PathData.cs
- TypeRestriction.cs
- SettingsBindableAttribute.cs
- SettingsAttributeDictionary.cs
- XsdBuildProvider.cs
- TripleDES.cs
- SimpleHandlerBuildProvider.cs
- SmiRequestExecutor.cs
- XmlnsCache.cs
- TreeViewCancelEvent.cs
- PieceDirectory.cs
- OdbcEnvironmentHandle.cs
- OdbcUtils.cs
- CryptographicAttribute.cs
- EncoderNLS.cs
- Link.cs
- diagnosticsswitches.cs
- FlowNode.cs
- BoundField.cs
- RawKeyboardInputReport.cs
- UTF8Encoding.cs
- InvalidAsynchronousStateException.cs
- StyleBamlRecordReader.cs
- ToolStripPanelRow.cs
- CatalogZone.cs
- DesignerTransactionCloseEvent.cs
- OleDbFactory.cs
- ExpandableObjectConverter.cs
- LayoutTableCell.cs
- TableCellAutomationPeer.cs
- RangeValidator.cs
- DataGridViewAccessibleObject.cs
- XmlSchemaAny.cs
- TreeViewAutomationPeer.cs
- ManualResetEventSlim.cs
- TransformerInfoCollection.cs
- TextDecoration.cs
- SendMailErrorEventArgs.cs
- UnsafeNativeMethods.cs
- NativeObjectSecurity.cs
- AnimatedTypeHelpers.cs
- ModelItemKeyValuePair.cs
- RemotingHelper.cs
- InvokeBinder.cs
- XmlRootAttribute.cs
- TaskHelper.cs
- PolicyValidationException.cs
- GeometryDrawing.cs
- PowerModeChangedEventArgs.cs
- DefaultTraceListener.cs
- ConstructorExpr.cs
- DataGridViewCellStateChangedEventArgs.cs
- X509CertificateValidator.cs
- TextElementCollection.cs
- StringHandle.cs
- GridViewPageEventArgs.cs
- ApplicationProxyInternal.cs
- ObjectDataSourceFilteringEventArgs.cs
- MarkupCompilePass2.cs
- ObjectListTitleAttribute.cs
- XmlDataSource.cs
- ListSourceHelper.cs
- RSAPKCS1KeyExchangeFormatter.cs
- TreeNode.cs
- ADConnectionHelper.cs
- TableCell.cs
- ControlEvent.cs
- designeractionlistschangedeventargs.cs
- WebInvokeAttribute.cs
- DecimalMinMaxAggregationOperator.cs
- TripleDES.cs
- HtmlImageAdapter.cs
- Facet.cs
- BitConverter.cs
- StaticSiteMapProvider.cs
- Point4D.cs
- WebPartHeaderCloseVerb.cs
- AuthenticationException.cs
- MailWebEventProvider.cs
- PathFigureCollectionValueSerializer.cs
- GPRECT.cs
- RegexTree.cs
- TypeConstant.cs
- DataReceivedEventArgs.cs
- CodeMemberEvent.cs
- AtomMaterializerLog.cs
- DefaultParameterValueAttribute.cs
- XmlCustomFormatter.cs
- Document.cs
- SafeLocalMemHandle.cs
- ContractMapping.cs
- PaginationProgressEventArgs.cs
- ToolStripContainer.cs
- LiteralTextContainerControlBuilder.cs
- DataBindingsDialog.cs
- SetStateDesigner.cs
- SubMenuStyle.cs
- UriParserTemplates.cs
- ListViewDeleteEventArgs.cs