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
- OletxTransactionManager.cs
- EncoderNLS.cs
- TemplatePropertyEntry.cs
- HwndSourceParameters.cs
- DataServiceQuery.cs
- sitestring.cs
- SelectedPathEditor.cs
- DataTableExtensions.cs
- Span.cs
- ApplicationSecurityManager.cs
- TextParagraphView.cs
- ScriptReferenceEventArgs.cs
- RichTextBoxConstants.cs
- FixUp.cs
- DocumentPropertiesDialog.cs
- indexingfiltermarshaler.cs
- CodeArgumentReferenceExpression.cs
- TimeSpanValidatorAttribute.cs
- InternalBufferOverflowException.cs
- SoapObjectInfo.cs
- CombinedGeometry.cs
- ColorPalette.cs
- ToolStripContentPanel.cs
- FrameworkTemplate.cs
- sqlcontext.cs
- EntityDataSourceWrapperCollection.cs
- sitestring.cs
- BinaryNode.cs
- DataException.cs
- XNodeNavigator.cs
- XDeferredAxisSource.cs
- ToolStripOverflow.cs
- SemaphoreSecurity.cs
- DomainConstraint.cs
- DataGridViewCellValueEventArgs.cs
- BitmapSource.cs
- Vector3DCollection.cs
- DrawingCollection.cs
- InvalidProgramException.cs
- X509SecurityTokenProvider.cs
- infer.cs
- Options.cs
- WorkBatch.cs
- __Filters.cs
- ArrayTypeMismatchException.cs
- DataGridViewRow.cs
- HtmlTableRowCollection.cs
- DataGridViewTopRowAccessibleObject.cs
- SqlAliaser.cs
- ErrorFormatterPage.cs
- MonikerUtility.cs
- JsonDataContract.cs
- BufferedGraphics.cs
- IgnoreFlushAndCloseStream.cs
- ButtonFieldBase.cs
- VolatileResourceManager.cs
- ConfigurationStrings.cs
- ControlBindingsCollection.cs
- And.cs
- SpecialFolderEnumConverter.cs
- ListViewDataItem.cs
- QueueProcessor.cs
- StyleBamlRecordReader.cs
- Quaternion.cs
- ArraySet.cs
- DataError.cs
- BufferedGraphicsManager.cs
- XmlSchemaIdentityConstraint.cs
- IFlowDocumentViewer.cs
- ApplicationBuildProvider.cs
- Transform.cs
- EntityTypeEmitter.cs
- SQLInt16Storage.cs
- VisualBasicImportReference.cs
- XmlSchemaSimpleContentExtension.cs
- NavigationEventArgs.cs
- StreamSecurityUpgradeAcceptor.cs
- ConnectorRouter.cs
- ObjectHelper.cs
- MetadataFile.cs
- MimePart.cs
- PublishLicense.cs
- AxHost.cs
- ObjectViewFactory.cs
- _FtpControlStream.cs
- XmlSchemaValidator.cs
- ManipulationVelocities.cs
- BasePropertyDescriptor.cs
- DummyDataSource.cs
- MarkerProperties.cs
- mda.cs
- _HeaderInfo.cs
- Select.cs
- SQLByte.cs
- DecimalConverter.cs
- WebDescriptionAttribute.cs
- TextBlock.cs
- SortedList.cs
- TextRunTypographyProperties.cs
- ResourceDisplayNameAttribute.cs