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
- WindowCollection.cs
- Membership.cs
- DecoratedNameAttribute.cs
- ShapingEngine.cs
- ApplicationManager.cs
- StrongNameKeyPair.cs
- DataGridViewBindingCompleteEventArgs.cs
- TraceContext.cs
- MeasurementDCInfo.cs
- ProxyWebPartManager.cs
- GPPOINT.cs
- ToolStripPanel.cs
- Internal.cs
- KoreanLunisolarCalendar.cs
- RoutedPropertyChangedEventArgs.cs
- ViewEventArgs.cs
- SerialStream.cs
- VarRefManager.cs
- figurelength.cs
- BitmapInitialize.cs
- ECDiffieHellmanPublicKey.cs
- XPathSelfQuery.cs
- BasePropertyDescriptor.cs
- CodeGenerator.cs
- AssertSection.cs
- BufferedWebEventProvider.cs
- RuleInfoComparer.cs
- DataGridViewSelectedColumnCollection.cs
- XmlnsCompatibleWithAttribute.cs
- Trace.cs
- GroupDescription.cs
- Image.cs
- LOSFormatter.cs
- SqlDataSourceFilteringEventArgs.cs
- AutomationInteropProvider.cs
- TextInfo.cs
- TrackPointCollection.cs
- AgileSafeNativeMemoryHandle.cs
- TrailingSpaceComparer.cs
- DependentList.cs
- ReadOnlyDataSource.cs
- XmlSchemaSimpleContent.cs
- ManagedWndProcTracker.cs
- UriTemplateTableMatchCandidate.cs
- DbTypeMap.cs
- ProviderUtil.cs
- JsonWriter.cs
- WindowsTooltip.cs
- ConnectionString.cs
- safesecurityhelperavalon.cs
- KnownBoxes.cs
- ColorTransform.cs
- EDesignUtil.cs
- PropertyIDSet.cs
- WebBrowserContainer.cs
- CodeAssignStatement.cs
- DefaultClaimSet.cs
- Tablet.cs
- CodeTypeMember.cs
- Unit.cs
- TextElementEnumerator.cs
- DropSource.cs
- ManagementException.cs
- precedingsibling.cs
- SerializationFieldInfo.cs
- TextEditorSpelling.cs
- BitmapMetadata.cs
- VariantWrapper.cs
- BuildResultCache.cs
- ObjectQueryState.cs
- UIElement3D.cs
- NavigationProperty.cs
- TextElementAutomationPeer.cs
- XmlToDatasetMap.cs
- CopyNamespacesAction.cs
- SchemaConstraints.cs
- StickyNoteContentControl.cs
- ArrayHelper.cs
- ThicknessAnimation.cs
- NavigatorInput.cs
- GPStream.cs
- Button.cs
- FontResourceCache.cs
- WorkItem.cs
- XomlCompilerHelpers.cs
- DrawingImage.cs
- HMACMD5.cs
- GPPOINT.cs
- ModifierKeysValueSerializer.cs
- ComponentSerializationService.cs
- SymbolEqualComparer.cs
- System.Data_BID.cs
- DispatcherExceptionFilterEventArgs.cs
- SortedList.cs
- MouseButtonEventArgs.cs
- DrawingContextFlattener.cs
- XpsException.cs
- EnumerableCollectionView.cs
- ToolStripGripRenderEventArgs.cs
- ListControlConvertEventArgs.cs