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
- _CommandStream.cs
- ServicePoint.cs
- XmlParser.cs
- ImageAutomationPeer.cs
- OleDbConnection.cs
- BamlLocalizationDictionary.cs
- CellParaClient.cs
- COM2IPerPropertyBrowsingHandler.cs
- ConfigXmlCDataSection.cs
- WebReferencesBuildProvider.cs
- EventRecord.cs
- SimpleHandlerFactory.cs
- AlternateView.cs
- ClientBuildManager.cs
- ToolBarTray.cs
- DataGridViewImageColumn.cs
- WinFormsUtils.cs
- KnownTypesProvider.cs
- XXXInfos.cs
- ProtocolsConfiguration.cs
- AutomationElementCollection.cs
- ProfileSection.cs
- SinglePageViewer.cs
- SecurityState.cs
- ConfigXmlSignificantWhitespace.cs
- TdsParserHelperClasses.cs
- ProbeMatchesCD1.cs
- RuntimeResourceSet.cs
- FilterException.cs
- RectangleHotSpot.cs
- XMLDiffLoader.cs
- WebServiceBindingAttribute.cs
- AlphabeticalEnumConverter.cs
- TransformCollection.cs
- ContextMenu.cs
- WindowPatternIdentifiers.cs
- Panel.cs
- ISAPIApplicationHost.cs
- DynamicValueConverter.cs
- PKCS1MaskGenerationMethod.cs
- DateBoldEvent.cs
- XMLDiffLoader.cs
- WebProxyScriptElement.cs
- RequestQueryProcessor.cs
- RoleManagerEventArgs.cs
- EventRoute.cs
- ParsedAttributeCollection.cs
- ShaderEffect.cs
- AsymmetricSignatureFormatter.cs
- TextEffectResolver.cs
- ResourcePool.cs
- PropertyDescriptorGridEntry.cs
- BrowserCapabilitiesCompiler.cs
- PermissionListSet.cs
- AutomationProperties.cs
- SelectionItemProviderWrapper.cs
- EpmSyndicationContentSerializer.cs
- WinFormsUtils.cs
- DataGridViewCellLinkedList.cs
- PropertyGrid.cs
- KeyPullup.cs
- SchemaTypeEmitter.cs
- XmlSchemaSimpleContent.cs
- GiveFeedbackEvent.cs
- DotExpr.cs
- DesignerActionUIStateChangeEventArgs.cs
- XmlHierarchyData.cs
- PeerNameRecordCollection.cs
- XsltCompileContext.cs
- StorageBasedPackageProperties.cs
- LongValidatorAttribute.cs
- AppLevelCompilationSectionCache.cs
- OleDbRowUpdatingEvent.cs
- LineSegment.cs
- ChannelDispatcherBase.cs
- ActivityTypeDesigner.xaml.cs
- UIElementParaClient.cs
- FileSecurity.cs
- LicenseException.cs
- CompletedAsyncResult.cs
- ResolveDuplexCD1AsyncResult.cs
- XPathDocument.cs
- CommandField.cs
- LinqDataSourceView.cs
- Style.cs
- LineServicesRun.cs
- PriorityBinding.cs
- ClusterRegistryConfigurationProvider.cs
- UsernameTokenFactoryCredential.cs
- TemplateField.cs
- ImageDrawing.cs
- DesignerTextWriter.cs
- ItemsChangedEventArgs.cs
- KoreanLunisolarCalendar.cs
- LassoHelper.cs
- ContentControl.cs
- SoapAttributes.cs
- FormViewRow.cs
- SecurityDocument.cs
- SqlCommandAsyncResult.cs