Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DLinq / Dlinq / DataQuery.cs / 1599186 / DataQuery.cs
using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Linq.Expressions; using System.Linq; using System.Reflection; using System.Diagnostics; using System.Runtime.CompilerServices; namespace System.Data.Linq { using System.Data.Linq.Mapping; using System.Data.Linq.Provider; internal sealed class DataQuery: IOrderedQueryable , IQueryProvider, IEnumerable , IOrderedQueryable, IEnumerable, IListSource { DataContext context; Expression queryExpression; private IBindingList cachedList; public DataQuery(DataContext context, Expression expression) { this.context = context; this.queryExpression = expression; } Expression IQueryable.Expression { get { return this.queryExpression; } } Type IQueryable.ElementType { get { return typeof(T); } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] IQueryable IQueryProvider.CreateQuery(Expression expression) { if (expression == null) throw Error.ArgumentNull("expression"); Type eType = System.Data.Linq.SqlClient.TypeSystem.GetElementType(expression.Type); Type qType = typeof(IQueryable<>).MakeGenericType(eType); if (!qType.IsAssignableFrom(expression.Type)) throw Error.ExpectedQueryableArgument("expression", qType); Type dqType = typeof(DataQuery<>).MakeGenericType(eType); return (IQueryable)Activator.CreateInstance(dqType, new object[] { this.context, expression }); } IQueryable IQueryProvider.CreateQuery(Expression expression) { if (expression == null) throw Error.ArgumentNull("expression"); if (!typeof(IQueryable).IsAssignableFrom(expression.Type)) throw Error.ExpectedQueryableArgument("expression", typeof(IEnumerable)); return new DataQuery(this.context, expression); } object IQueryProvider.Execute(Expression expression) { return this.context.Provider.Execute(expression).ReturnValue; } S IQueryProvider.Execute(Expression expression) { return (S)this.context.Provider.Execute(expression).ReturnValue; } IQueryProvider IQueryable.Provider { get{ return (IQueryProvider)this; } } IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)this.context.Provider.Execute(this.queryExpression).ReturnValue).GetEnumerator(); } IEnumeratorIEnumerable .GetEnumerator() { return ((IEnumerable )this.context.Provider.Execute(this.queryExpression).ReturnValue).GetEnumerator(); } bool IListSource.ContainsListCollection { get { return false; } } IList IListSource.GetList() { if (cachedList == null) { cachedList = GetNewBindingList(); } return cachedList; } internal IBindingList GetNewBindingList() { return BindingList.Create (this.context, this); } public override string ToString() { return this.context.Provider.GetQueryText(this.queryExpression); } } } // 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
- RtfFormatStack.cs
- WindowsSlider.cs
- ItemsChangedEventArgs.cs
- LiteralLink.cs
- Classification.cs
- ActivityValidationServices.cs
- VectorKeyFrameCollection.cs
- ChtmlLinkAdapter.cs
- Journaling.cs
- RelativeSource.cs
- ServicePoint.cs
- SmtpAuthenticationManager.cs
- CodeAttributeArgument.cs
- CodeCommentStatementCollection.cs
- OracleNumber.cs
- XamlPathDataSerializer.cs
- AssemblyCollection.cs
- Base64Encoding.cs
- SoapCodeExporter.cs
- NCryptNative.cs
- FSWPathEditor.cs
- IPAddressCollection.cs
- ReadWriteSpinLock.cs
- TextRangeEditLists.cs
- path.cs
- SystemUdpStatistics.cs
- ErrorHandler.cs
- VersionValidator.cs
- SqlTriggerContext.cs
- VisualTarget.cs
- PolyLineSegment.cs
- TextEncodedRawTextWriter.cs
- ProcessHostServerConfig.cs
- EventProviderBase.cs
- BitmapCache.cs
- ImmComposition.cs
- OutKeywords.cs
- TcpTransportManager.cs
- URLString.cs
- ApplyImportsAction.cs
- RelationshipType.cs
- PersonalizationStateInfo.cs
- DesignTimeXamlWriter.cs
- MenuItem.cs
- ControlParameter.cs
- ForeignKeyConstraint.cs
- AnnotationHelper.cs
- FlagsAttribute.cs
- ToolStripItemEventArgs.cs
- WindowsMenu.cs
- NamespaceExpr.cs
- Action.cs
- InstanceKeyCompleteException.cs
- Tuple.cs
- AddIn.cs
- QueryPageSettingsEventArgs.cs
- FontCacheLogic.cs
- SqlServices.cs
- Vector3DConverter.cs
- HttpCacheVary.cs
- BaseInfoTable.cs
- MsmqIntegrationChannelFactory.cs
- ReadWriteSpinLock.cs
- Menu.cs
- FontDifferentiator.cs
- RoleManagerSection.cs
- CollectionViewSource.cs
- KeyInterop.cs
- ContourSegment.cs
- XamlNamespaceHelper.cs
- FactoryMaker.cs
- HandlerBase.cs
- EncryptedPackage.cs
- COM2IDispatchConverter.cs
- ConversionContext.cs
- MailSettingsSection.cs
- SafeViewOfFileHandle.cs
- ProjectionCamera.cs
- ScrollPattern.cs
- PerformanceCounterPermissionAttribute.cs
- SpeechRecognitionEngine.cs
- Avt.cs
- WebBrowserUriTypeConverter.cs
- InvalidPropValue.cs
- TextParagraph.cs
- RuleSettings.cs
- DateTimeFormat.cs
- Underline.cs
- MouseBinding.cs
- GlyphRun.cs
- ControlBuilderAttribute.cs
- AsyncResult.cs
- IdentityManager.cs
- StylusPointPropertyInfo.cs
- ReaderWriterLock.cs
- QilGeneratorEnv.cs
- XmlSequenceWriter.cs
- VerticalConnector.xaml.cs
- ItemChangedEventArgs.cs
- ListCardsInFileRequest.cs