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
- ExpressionConverter.cs
- Touch.cs
- WSDualHttpSecurity.cs
- JumpTask.cs
- Transform3D.cs
- KnownTypes.cs
- XamlPoint3DCollectionSerializer.cs
- SortFieldComparer.cs
- CategoryState.cs
- ClrPerspective.cs
- PropertyDescriptorCollection.cs
- BaseResourcesBuildProvider.cs
- TextRangeSerialization.cs
- CodeDOMUtility.cs
- UpdateExpressionVisitor.cs
- DataProtectionSecurityStateEncoder.cs
- BaseTemplateCodeDomTreeGenerator.cs
- ButtonChrome.cs
- SrgsSemanticInterpretationTag.cs
- UpDownBase.cs
- D3DImage.cs
- SolidColorBrush.cs
- SharedUtils.cs
- SchemaTableColumn.cs
- FilterQueryOptionExpression.cs
- httpstaticobjectscollection.cs
- DesignTable.cs
- BindingContext.cs
- DocumentCollection.cs
- LinqDataSourceDeleteEventArgs.cs
- ComPlusDiagnosticTraceSchemas.cs
- EncryptedPackageFilter.cs
- BuildManagerHost.cs
- NetworkInterface.cs
- Comparer.cs
- DrawingGroup.cs
- SpellerError.cs
- ArgumentOutOfRangeException.cs
- DecoderBestFitFallback.cs
- RegexCode.cs
- GeneralTransformGroup.cs
- SmiEventSink_DeferedProcessing.cs
- TableLayoutSettingsTypeConverter.cs
- Int32.cs
- ValueConversionAttribute.cs
- ListViewTableCell.cs
- ClientSettingsStore.cs
- SocketInformation.cs
- ProcessStartInfo.cs
- AbstractSvcMapFileLoader.cs
- OdbcTransaction.cs
- ZipIOLocalFileHeader.cs
- DeviceContext.cs
- login.cs
- VisualStateGroup.cs
- DesignerActionUI.cs
- Partitioner.cs
- ConsoleTraceListener.cs
- MessageBox.cs
- ReflectionHelper.cs
- UnorderedHashRepartitionStream.cs
- AVElementHelper.cs
- EventProxy.cs
- SqlNodeTypeOperators.cs
- DebugInfoExpression.cs
- ClientProxyGenerator.cs
- CodeDomSerializerException.cs
- BrowserTree.cs
- CompModHelpers.cs
- DesignerCategoryAttribute.cs
- HitTestWithGeometryDrawingContextWalker.cs
- DeferredReference.cs
- PagesSection.cs
- CachedRequestParams.cs
- RawUIStateInputReport.cs
- WaitHandleCannotBeOpenedException.cs
- StrokeNodeEnumerator.cs
- StartUpEventArgs.cs
- UnauthorizedAccessException.cs
- ILGenerator.cs
- Membership.cs
- Html32TextWriter.cs
- WindowsListViewGroup.cs
- TreeNodeClickEventArgs.cs
- Path.cs
- DataGridViewBindingCompleteEventArgs.cs
- DataGridViewSelectedCellCollection.cs
- SimpleApplicationHost.cs
- DescendantOverDescendantQuery.cs
- ResourceType.cs
- Pointer.cs
- _AuthenticationState.cs
- DeobfuscatingStream.cs
- UIElementCollection.cs
- LogEntrySerializationException.cs
- ISAPIApplicationHost.cs
- TemplatePropertyEntry.cs
- NullRuntimeConfig.cs
- BindingSource.cs
- TcpActivation.cs