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
- PreviewPageInfo.cs
- SelectedDatesCollection.cs
- ChannelBinding.cs
- Floater.cs
- Permission.cs
- TemplateControlBuildProvider.cs
- RelatedEnd.cs
- CounterNameConverter.cs
- IdentifierService.cs
- ObjectDataSourceFilteringEventArgs.cs
- PerformanceCounterLib.cs
- Label.cs
- FileLoadException.cs
- RequestSecurityTokenSerializer.cs
- ColorBuilder.cs
- COM2EnumConverter.cs
- CodeDomConfigurationHandler.cs
- FunctionImportMapping.ReturnTypeRenameMapping.cs
- DeleteIndexBinder.cs
- XmlCharCheckingReader.cs
- HtmlHistory.cs
- TimeSpanFormat.cs
- UrlMappingsSection.cs
- InlinedAggregationOperatorEnumerator.cs
- DataServiceQueryException.cs
- ActivityXRefPropertyEditor.cs
- DefaultDiscoveryService.cs
- NativeMethods.cs
- DataProtection.cs
- DtrList.cs
- GPPOINTF.cs
- TypeToken.cs
- ExportOptions.cs
- CheckPair.cs
- SpnegoTokenProvider.cs
- StringFormat.cs
- BinaryHeap.cs
- DateTimeUtil.cs
- DbMetaDataFactory.cs
- TemplateLookupAction.cs
- ImageDrawing.cs
- MatrixCamera.cs
- WindowsListViewScroll.cs
- MetadataItem.cs
- EncryptedData.cs
- ColorAnimationBase.cs
- ActivityExecutionContextCollection.cs
- RequestReplyCorrelator.cs
- Object.cs
- SaveFileDialog.cs
- DbgCompiler.cs
- ToggleButton.cs
- TreeWalkHelper.cs
- HMACMD5.cs
- XmlBufferReader.cs
- SessionStateItemCollection.cs
- DataContractAttribute.cs
- SynchronizationLockException.cs
- ClassData.cs
- MatrixStack.cs
- TypeDescriptionProvider.cs
- NullReferenceException.cs
- ScrollData.cs
- EmptyQuery.cs
- PartManifestEntry.cs
- DependencyPropertyConverter.cs
- listitem.cs
- CodeDefaultValueExpression.cs
- DateTimeSerializationSection.cs
- AttachmentService.cs
- Nullable.cs
- UserControlBuildProvider.cs
- RuntimeCompatibilityAttribute.cs
- ExternalCalls.cs
- DataSourceCache.cs
- UserPreferenceChangingEventArgs.cs
- AttachedProperty.cs
- WebColorConverter.cs
- MarshalDirectiveException.cs
- XPathQilFactory.cs
- ConfigUtil.cs
- Trigger.cs
- UIElementIsland.cs
- ExpressionVisitorHelpers.cs
- PanelStyle.cs
- ThreadStartException.cs
- UpdateException.cs
- GroupDescription.cs
- WindowsFormsSectionHandler.cs
- ParserHooks.cs
- StringReader.cs
- ImageMetadata.cs
- DetailsViewRow.cs
- ActivityExecutor.cs
- ProfileWorkflowElement.cs
- StatusBarDesigner.cs
- CompareInfo.cs
- Cursor.cs
- WindowsTooltip.cs
- IImplicitResourceProvider.cs