Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DLinq / Dlinq / SqlClient / Query / SqlTopReducer.cs / 1305376 / SqlTopReducer.cs
using System; using System.Collections.Generic; using System.Linq.Expressions; using System.Reflection; using System.Data.Linq; using System.Data.Linq.Provider; using System.Linq; namespace System.Data.Linq.SqlClient { internal class SqlTopReducer { internal static SqlNode Reduce(SqlNode node, SqlNodeAnnotations annotations, SqlFactory sql) { return new Visitor(annotations, sql).Visit(node); } class Visitor : SqlVisitor { SqlNodeAnnotations annotations; SqlFactory sql; internal Visitor(SqlNodeAnnotations annotations, SqlFactory sql) { this.annotations = annotations; this.sql = sql; } internal override SqlSelect VisitSelect(SqlSelect select) { base.VisitSelect(select); if (select.Top != null) { if (select.Top.NodeType == SqlNodeType.Value) { SqlValue val = (SqlValue)select.Top; // convert to literal value for SQL2K compatibility if (val.IsClientSpecified) { select.Top = sql.Value(val.ClrType, val.SqlType, val.Value, false, val.SourceExpression); } } else { // cannot be converted to literal value. note that this select is not SQL2K compatible this.annotations.Add(select.Top, new SqlServerCompatibilityAnnotation(Strings.SourceExpressionAnnotation(select.Top.SourceExpression), SqlProvider.ProviderMode.Sql2000)); } } return select; } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. using System; using System.Collections.Generic; using System.Linq.Expressions; using System.Reflection; using System.Data.Linq; using System.Data.Linq.Provider; using System.Linq; namespace System.Data.Linq.SqlClient { internal class SqlTopReducer { internal static SqlNode Reduce(SqlNode node, SqlNodeAnnotations annotations, SqlFactory sql) { return new Visitor(annotations, sql).Visit(node); } class Visitor : SqlVisitor { SqlNodeAnnotations annotations; SqlFactory sql; internal Visitor(SqlNodeAnnotations annotations, SqlFactory sql) { this.annotations = annotations; this.sql = sql; } internal override SqlSelect VisitSelect(SqlSelect select) { base.VisitSelect(select); if (select.Top != null) { if (select.Top.NodeType == SqlNodeType.Value) { SqlValue val = (SqlValue)select.Top; // convert to literal value for SQL2K compatibility if (val.IsClientSpecified) { select.Top = sql.Value(val.ClrType, val.SqlType, val.Value, false, val.SourceExpression); } } else { // cannot be converted to literal value. note that this select is not SQL2K compatible this.annotations.Add(select.Top, new SqlServerCompatibilityAnnotation(Strings.SourceExpressionAnnotation(select.Top.SourceExpression), SqlProvider.ProviderMode.Sql2000)); } } return select; } } } } // 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
- ValidatingCollection.cs
- StrokeNode.cs
- TdsParserHelperClasses.cs
- ValueOfAction.cs
- ArglessEventHandlerProxy.cs
- SequenceFullException.cs
- EventNotify.cs
- DragStartedEventArgs.cs
- IPGlobalProperties.cs
- PersistChildrenAttribute.cs
- CustomAttributeSerializer.cs
- DataSourceControlBuilder.cs
- SoapAttributes.cs
- SiteMap.cs
- MessageQueueCriteria.cs
- ResolveCriteria11.cs
- WindowsHyperlink.cs
- MemberExpression.cs
- TableCellAutomationPeer.cs
- WebControlsSection.cs
- HttpHandlerActionCollection.cs
- AttachedPropertyBrowsableForTypeAttribute.cs
- ColorContext.cs
- Pair.cs
- PageSettings.cs
- RequestCachePolicyConverter.cs
- KnownIds.cs
- OrthographicCamera.cs
- CheckedPointers.cs
- ContractBase.cs
- MetadataPropertyAttribute.cs
- DiscoveryEndpointValidator.cs
- RightsController.cs
- XmlSerializerAssemblyAttribute.cs
- DataServiceException.cs
- TextDecorationCollection.cs
- AudioFormatConverter.cs
- IriParsingElement.cs
- ServiceHostingEnvironment.cs
- DbInsertCommandTree.cs
- ActivityMarkupSerializer.cs
- Converter.cs
- ItemChangedEventArgs.cs
- Models.cs
- ObjectListFieldCollection.cs
- NamedPipeHostedTransportConfiguration.cs
- CqlWriter.cs
- RangeValueProviderWrapper.cs
- MetadataPropertyvalue.cs
- PrincipalPermission.cs
- RSAOAEPKeyExchangeDeformatter.cs
- ChangeProcessor.cs
- FileAccessException.cs
- Utils.cs
- FileIOPermission.cs
- HttpApplicationStateWrapper.cs
- HierarchicalDataBoundControlAdapter.cs
- MenuAdapter.cs
- Point4DConverter.cs
- ProgressBar.cs
- CollectionBase.cs
- DynamicFilter.cs
- DeploymentSectionCache.cs
- WebPartVerbCollection.cs
- ContourSegment.cs
- WindowsListBox.cs
- SplashScreen.cs
- WorkerRequest.cs
- Resources.Designer.cs
- FontFamily.cs
- exports.cs
- GradientSpreadMethodValidation.cs
- Compensate.cs
- ForEachAction.cs
- FunctionParameter.cs
- SynchronizedDispatch.cs
- PrivilegedConfigurationManager.cs
- RegistrationProxy.cs
- altserialization.cs
- InvalidOperationException.cs
- ObjectStateEntry.cs
- PropertyValue.cs
- RoutedEventArgs.cs
- AsyncCompletedEventArgs.cs
- ScrollBarAutomationPeer.cs
- ProviderBase.cs
- ProcessActivityTreeOptions.cs
- CollectionChangeEventArgs.cs
- ObjectAssociationEndMapping.cs
- OperationAbortedException.cs
- DrawingImage.cs
- GC.cs
- XmlMessageFormatter.cs
- AsyncDataRequest.cs
- RadialGradientBrush.cs
- CellQuery.cs
- BuiltInPermissionSets.cs
- PerformanceCounterPermissionEntry.cs
- InheritedPropertyChangedEventArgs.cs
- AbsoluteQuery.cs