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
- ThreadInterruptedException.cs
- EntityDataSourceState.cs
- ReverseInheritProperty.cs
- CopyAttributesAction.cs
- Aggregates.cs
- QuaternionIndependentAnimationStorage.cs
- SkipStoryboardToFill.cs
- SelectionPattern.cs
- Compress.cs
- XmlUTF8TextReader.cs
- ManagedWndProcTracker.cs
- HeaderedItemsControl.cs
- Pen.cs
- Decoder.cs
- ForEachAction.cs
- GridItemPattern.cs
- MimeMapping.cs
- TemplateBamlRecordReader.cs
- ContextStaticAttribute.cs
- TextDecoration.cs
- Select.cs
- PageContentCollection.cs
- URI.cs
- ISFClipboardData.cs
- ToolboxComponentsCreatingEventArgs.cs
- HtmlInputFile.cs
- ButtonField.cs
- WindowsListViewGroupSubsetLink.cs
- StackOverflowException.cs
- ApplicationServicesHostFactory.cs
- StylusDevice.cs
- LambdaCompiler.Unary.cs
- PreservationFileReader.cs
- ButtonBase.cs
- MenuItem.cs
- SubMenuStyleCollection.cs
- SaveFileDialog.cs
- Decoder.cs
- WebExceptionStatus.cs
- ConfigurationManagerHelper.cs
- AgileSafeNativeMemoryHandle.cs
- MsmqIntegrationSecurity.cs
- SmiRecordBuffer.cs
- Dictionary.cs
- SrgsElement.cs
- BooleanStorage.cs
- SchemaNames.cs
- XmlSchemaObject.cs
- IndentedTextWriter.cs
- wgx_render.cs
- RealProxy.cs
- TextTreeExtractElementUndoUnit.cs
- OptimizerPatterns.cs
- GifBitmapDecoder.cs
- Cell.cs
- BinaryCommonClasses.cs
- Bind.cs
- SafeNativeMethods.cs
- DragStartedEventArgs.cs
- PageVisual.cs
- MailMessageEventArgs.cs
- smtpconnection.cs
- ImportContext.cs
- DmlSqlGenerator.cs
- WizardForm.cs
- RequestCache.cs
- UndirectedGraph.cs
- EdmConstants.cs
- UndoEngine.cs
- FormsAuthenticationConfiguration.cs
- RelatedPropertyManager.cs
- PersistChildrenAttribute.cs
- Propagator.JoinPropagator.cs
- CallSiteHelpers.cs
- GenericUriParser.cs
- SafeBitVector32.cs
- DataGridViewCellCancelEventArgs.cs
- DrawingContextDrawingContextWalker.cs
- ControlPaint.cs
- Ray3DHitTestResult.cs
- AvTraceFormat.cs
- CompositeActivityDesigner.cs
- XmlSerializerNamespaces.cs
- ReliableChannelBinder.cs
- CodeSnippetStatement.cs
- StringBuilder.cs
- ColumnMapCopier.cs
- BroadcastEventHelper.cs
- X509RawDataKeyIdentifierClause.cs
- SessionStateItemCollection.cs
- Repeater.cs
- CellNormalizer.cs
- DbModificationClause.cs
- XPathBinder.cs
- InternalBase.cs
- MappingMetadataHelper.cs
- SqlInternalConnectionSmi.cs
- Metafile.cs
- BindingContext.cs
- BoundPropertyEntry.cs