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
- SmtpLoginAuthenticationModule.cs
- PassportAuthenticationModule.cs
- KnownBoxes.cs
- StrongNameUtility.cs
- BinaryMethodMessage.cs
- shaperfactory.cs
- XPathNavigator.cs
- DbConnectionStringCommon.cs
- control.ime.cs
- ComContractElementCollection.cs
- AssemblyAttributes.cs
- DataBindingExpressionBuilder.cs
- XmlSchemaElement.cs
- CommentAction.cs
- HandlerFactoryWrapper.cs
- ExitEventArgs.cs
- XsdBuilder.cs
- AliasGenerator.cs
- documentsequencetextview.cs
- PointLightBase.cs
- SystemColorTracker.cs
- TabItemWrapperAutomationPeer.cs
- ConnectionProviderAttribute.cs
- TransformerInfo.cs
- ConfigurationPropertyAttribute.cs
- ValueTypeFixupInfo.cs
- TextRunCacheImp.cs
- ObservableCollection.cs
- LinqDataView.cs
- Internal.cs
- TextOutput.cs
- BindingBase.cs
- HtmlGenericControl.cs
- AssemblySettingAttributes.cs
- SortedSetDebugView.cs
- ButtonRenderer.cs
- ServiceDescriptionSerializer.cs
- DBBindings.cs
- WindowsGraphicsCacheManager.cs
- AccessorTable.cs
- TypeNameParser.cs
- DesignerActionGlyph.cs
- LinqToSqlWrapper.cs
- EmptyEnumerable.cs
- CodeAssignStatement.cs
- ClientOptions.cs
- ProcessModuleCollection.cs
- ZipIOExtraFieldZip64Element.cs
- NodeLabelEditEvent.cs
- RoamingStoreFileUtility.cs
- GeometryValueSerializer.cs
- ToolStripProgressBar.cs
- CodeExpressionCollection.cs
- Pen.cs
- DbMetaDataCollectionNames.cs
- PagerSettings.cs
- StringPropertyBuilder.cs
- SubtreeProcessor.cs
- ContainerUtilities.cs
- Soap.cs
- OleDbConnectionPoolGroupProviderInfo.cs
- StyleSelector.cs
- FlatButtonAppearance.cs
- WebPartConnectVerb.cs
- Security.cs
- WpfPayload.cs
- XamlFigureLengthSerializer.cs
- MimeImporter.cs
- DocumentPageTextView.cs
- ClientSession.cs
- KeyNotFoundException.cs
- DeploymentExceptionMapper.cs
- WindowClosedEventArgs.cs
- CheckoutException.cs
- Point4DConverter.cs
- Membership.cs
- Lasso.cs
- OperatingSystem.cs
- QuotedPrintableStream.cs
- KeyedHashAlgorithm.cs
- Activator.cs
- GridViewCancelEditEventArgs.cs
- TdsParser.cs
- UpdateCompiler.cs
- HtmlUtf8RawTextWriter.cs
- GeometryModel3D.cs
- SplitterPanel.cs
- UpdateCompiler.cs
- DataServiceClientException.cs
- PropagatorResult.cs
- WebBrowserDocumentCompletedEventHandler.cs
- JoinGraph.cs
- HtmlPanelAdapter.cs
- EFAssociationProvider.cs
- UpdateExpressionVisitor.cs
- AssemblyInfo.cs
- NetworkInformationException.cs
- SystemBrushes.cs
- ApplicationFileParser.cs
- ErrorRuntimeConfig.cs