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
- OleDbRowUpdatingEvent.cs
- FixedPageProcessor.cs
- PackageDigitalSignatureManager.cs
- EventLogEntryCollection.cs
- CategoryNameCollection.cs
- CheckPair.cs
- MarkupWriter.cs
- MethodSignatureGenerator.cs
- Shape.cs
- LogicalChannel.cs
- MetabaseReader.cs
- LayoutTableCell.cs
- SqlTrackingWorkflowInstance.cs
- TextSelectionProcessor.cs
- ComponentResourceKey.cs
- ObjectStateEntryBaseUpdatableDataRecord.cs
- DCSafeHandle.cs
- RegexCapture.cs
- ControlParameter.cs
- CompoundFileReference.cs
- BatchServiceHost.cs
- HostingPreferredMapPath.cs
- PriorityChain.cs
- ArrowControl.xaml.cs
- TogglePattern.cs
- DelegateBodyWriter.cs
- PackagePart.cs
- PinProtectionHelper.cs
- AutomationElementCollection.cs
- ContactManager.cs
- SystemIPGlobalProperties.cs
- EntityProviderFactory.cs
- XsltQilFactory.cs
- DocumentsTrace.cs
- StylusLogic.cs
- TreeViewAutomationPeer.cs
- _CookieModule.cs
- HandlerFactoryCache.cs
- WorkflowQueueInfo.cs
- BindingCollectionElement.cs
- IsolatedStorageFileStream.cs
- Shape.cs
- ImportCatalogPart.cs
- XmlAttributes.cs
- RegexTypeEditor.cs
- FaultFormatter.cs
- NullRuntimeConfig.cs
- ToggleButton.cs
- CompositionTarget.cs
- TransformerInfoCollection.cs
- _NegoStream.cs
- SizeChangedInfo.cs
- ForwardPositionQuery.cs
- EntityType.cs
- DataObjectCopyingEventArgs.cs
- AttributeEmitter.cs
- MultiTrigger.cs
- TreeNodeCollection.cs
- AttachedPropertiesService.cs
- GridItemCollection.cs
- InputLanguageCollection.cs
- DefinitionBase.cs
- XmlSchemaSimpleContentRestriction.cs
- MappedMetaModel.cs
- UndirectedGraph.cs
- ConfigUtil.cs
- XmlSchemaImporter.cs
- GridViewSortEventArgs.cs
- MetadataItemEmitter.cs
- TemplateParser.cs
- EventMap.cs
- CodeCatchClause.cs
- NamedElement.cs
- HtmlUtf8RawTextWriter.cs
- Vector3DKeyFrameCollection.cs
- Rotation3DAnimationBase.cs
- SerializationSectionGroup.cs
- DataGridViewAutoSizeColumnModeEventArgs.cs
- DataGridCaption.cs
- TextEffect.cs
- WebSysDefaultValueAttribute.cs
- SecurityUtils.cs
- DataServiceHostFactory.cs
- DataSourceCache.cs
- AmbientEnvironment.cs
- ButtonChrome.cs
- SqlWebEventProvider.cs
- RuntimeConfig.cs
- LocalizabilityAttribute.cs
- ContextDataSourceContextData.cs
- sqlstateclientmanager.cs
- CacheDependency.cs
- ExpandableObjectConverter.cs
- DataListItemEventArgs.cs
- SqlGenericUtil.cs
- ScriptResourceInfo.cs
- VirtualPath.cs
- NullableBoolConverter.cs
- ObjectContextServiceProvider.cs
- KnownTypesHelper.cs