Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / ndp / fx / src / DLinq / Dlinq / SqlClient / Query / SqlTopReducer.cs / 1 / 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
- PartialClassGenerationTask.cs
- SubpageParaClient.cs
- XmlILTrace.cs
- RSAPKCS1KeyExchangeDeformatter.cs
- DateTimeFormatInfoScanner.cs
- NameTable.cs
- LicenseProviderAttribute.cs
- DataTableClearEvent.cs
- BinaryHeap.cs
- LocatorBase.cs
- CodeFieldReferenceExpression.cs
- XmlSchemaExporter.cs
- XMLDiffLoader.cs
- SqlMethods.cs
- RequestSecurityToken.cs
- SetterBaseCollection.cs
- InputLangChangeRequestEvent.cs
- XmlUrlResolver.cs
- StrokeCollectionDefaultValueFactory.cs
- unsafenativemethodsother.cs
- ZoneMembershipCondition.cs
- AmbientProperties.cs
- WeakHashtable.cs
- ElapsedEventArgs.cs
- OutputWindow.cs
- formatstringdialog.cs
- PowerEase.cs
- WindowsButton.cs
- CqlErrorHelper.cs
- GenericQueueSurrogate.cs
- TextParaLineResult.cs
- Vector3DCollectionValueSerializer.cs
- ContentHostHelper.cs
- DSGeneratorProblem.cs
- GeometryGroup.cs
- EmptyEnumerator.cs
- Deflater.cs
- ZipIOLocalFileBlock.cs
- FontStyle.cs
- BooleanExpr.cs
- DiagnosticsConfiguration.cs
- KnownTypeDataContractResolver.cs
- SqlErrorCollection.cs
- WebPartCloseVerb.cs
- UriWriter.cs
- InfoCardProofToken.cs
- FtpCachePolicyElement.cs
- HtmlUtf8RawTextWriter.cs
- LogSwitch.cs
- LocationSectionRecord.cs
- AppSettingsReader.cs
- ConstructorNeedsTagAttribute.cs
- Attributes.cs
- Panel.cs
- SectionXmlInfo.cs
- _CacheStreams.cs
- Publisher.cs
- RequestNavigateEventArgs.cs
- ReflectionServiceProvider.cs
- ControlBindingsCollection.cs
- WebPartTransformer.cs
- IgnoreFlushAndCloseStream.cs
- GridLengthConverter.cs
- xdrvalidator.cs
- TreeNodeStyle.cs
- KnownBoxes.cs
- IdentitySection.cs
- FixedTextBuilder.cs
- DoubleUtil.cs
- _DigestClient.cs
- Transform.cs
- XmlSchemaSimpleTypeRestriction.cs
- ScalarType.cs
- safesecurityhelperavalon.cs
- TabRenderer.cs
- TreeNodeEventArgs.cs
- NetTcpBindingElement.cs
- ButtonBaseAutomationPeer.cs
- ToolStripKeyboardHandlingService.cs
- LambdaCompiler.ControlFlow.cs
- ClassicBorderDecorator.cs
- ChangeBlockUndoRecord.cs
- BitmapScalingModeValidation.cs
- Msmq.cs
- ConnectionsZone.cs
- LabelEditEvent.cs
- ControlCodeDomSerializer.cs
- BatchServiceHost.cs
- NonClientArea.cs
- PtsHelper.cs
- XamlFxTrace.cs
- SecUtil.cs
- LinqMaximalSubtreeNominator.cs
- securitycriticaldataformultiplegetandset.cs
- EmbeddedObject.cs
- EntitySetBaseCollection.cs
- XmlArrayItemAttributes.cs
- FeatureSupport.cs
- ActivityBindForm.cs
- HttpPostProtocolReflector.cs