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
- HandledEventArgs.cs
- CategoriesDocumentFormatter.cs
- ParentQuery.cs
- PrimaryKeyTypeConverter.cs
- FilterQueryOptionExpression.cs
- HttpResponseWrapper.cs
- MenuItem.cs
- DrawingAttributeSerializer.cs
- Vector.cs
- XamlReader.cs
- TrustExchangeException.cs
- WpfPayload.cs
- ReadOnlyCollection.cs
- HtmlElementErrorEventArgs.cs
- CopyAttributesAction.cs
- GenericEnumerator.cs
- XPathNodeInfoAtom.cs
- JsonFormatReaderGenerator.cs
- RuntimeResourceSet.cs
- TextAutomationPeer.cs
- ToolStripSplitButton.cs
- HyperLink.cs
- BackStopAuthenticationModule.cs
- ComboBox.cs
- StreamReader.cs
- Empty.cs
- ResolveRequestResponseAsyncResult.cs
- View.cs
- DataRow.cs
- SimpleBitVector32.cs
- SiteMapSection.cs
- PersistNameAttribute.cs
- RadioButtonFlatAdapter.cs
- NullExtension.cs
- SoapParser.cs
- AuthenticationService.cs
- IconBitmapDecoder.cs
- CodeTypeReference.cs
- PerformanceCounterPermission.cs
- GridPattern.cs
- PingOptions.cs
- TypeEnumerableViewSchema.cs
- MetadataImporter.cs
- RangeContentEnumerator.cs
- DirectoryRootQuery.cs
- RenderingEventArgs.cs
- ReaderWriterLock.cs
- Int32CAMarshaler.cs
- TripleDES.cs
- MenuTracker.cs
- ping.cs
- Exception.cs
- ScrollBarRenderer.cs
- ProviderConnectionPoint.cs
- HtmlTableRowCollection.cs
- DataTableClearEvent.cs
- DebugInfoExpression.cs
- SoapFault.cs
- Size.cs
- indexingfiltermarshaler.cs
- ColorKeyFrameCollection.cs
- ConfigurationStrings.cs
- OleStrCAMarshaler.cs
- SessionIDManager.cs
- LifetimeServices.cs
- _AutoWebProxyScriptHelper.cs
- TimerElapsedEvenArgs.cs
- CompiledELinqQueryState.cs
- PageParserFilter.cs
- CircleEase.cs
- Compiler.cs
- HandlerFactoryWrapper.cs
- IpcClientManager.cs
- RpcCryptoContext.cs
- WebPartZone.cs
- RuntimeIdentifierPropertyAttribute.cs
- ScrollBar.cs
- SocketCache.cs
- QilIterator.cs
- PeerResolverMode.cs
- Stroke.cs
- DataListAutoFormat.cs
- MarkedHighlightComponent.cs
- RecordConverter.cs
- PerformanceCounterPermissionAttribute.cs
- FileResponseElement.cs
- QilPatternFactory.cs
- EntityRecordInfo.cs
- BigInt.cs
- ADMembershipUser.cs
- DataGridViewToolTip.cs
- PathSegment.cs
- SchemaComplexType.cs
- ProgressBarRenderer.cs
- MetadataItemEmitter.cs
- LinearQuaternionKeyFrame.cs
- HttpListenerResponse.cs
- OperationInfoBase.cs
- PageBuildProvider.cs
- EntityTypeEmitter.cs