Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataEntity / System / Data / Objects / ELinq / ObjectQueryProvider.cs / 1305376 / ObjectQueryProvider.cs
//---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....] // @backupOwner [....] //--------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Data.Objects.Internal; using System.Data.Metadata.Edm; using System.Diagnostics; using System.Linq; using System.Linq.Expressions; using System.Reflection; namespace System.Data.Objects.ELinq { ////// LINQ query provider implementation. /// internal sealed class ObjectQueryProvider : IQueryProvider { private readonly ObjectContext _context; internal ObjectQueryProvider(ObjectContext context) { Debug.Assert(null != context, "context must be given"); _context = context; } ////// Creates a new query instance using the given LINQ expresion. /// The current query is used to produce the context for the new query, but none of its logic /// is used. /// ///Element type for query result. /// LINQ expression forming the query. ///ObjectQuery implementing the expression logic. IQueryableIQueryProvider.CreateQuery(Expression expression) { EntityUtil.CheckArgumentNull(expression, "expression"); if (!typeof(IQueryable).IsAssignableFrom(expression.Type)) { throw EntityUtil.Argument(System.Data.Entity.Strings.ELinq_ExpressionMustBeIQueryable, "expression"); } ObjectQueryquery = CreateQuery(expression); return query; } ////// Executes the given LINQ expression returning a single value, or null if the query yields /// no results. If the return type is unexpected, raises a cast exception. /// The current query is used to produce the context for the new query, but none of its logic /// is used. /// ///Type of returned value. /// Expression to evaluate. ///Single result from execution. S IQueryProvider.Execute(Expression expression) { EntityUtil.CheckArgumentNull(expression, "expression"); ObjectQueryquery = CreateQuery(expression); return ExecuteSingle(query, expression); } ////// Creates a new query instance using the given LINQ expresion. /// The current query is used to produce the context for the new query, but none of its logic /// is used. /// /// Expression forming the query. ///ObjectQuery instance implementing the given expression. IQueryable IQueryProvider.CreateQuery(Expression expression) { EntityUtil.CheckArgumentNull(expression, "expression"); if (!typeof(IQueryable).IsAssignableFrom(expression.Type)) { throw EntityUtil.Argument(System.Data.Entity.Strings.ELinq_ExpressionMustBeIQueryable, "expression"); } // Determine the type of the query instance by binding generic parameter in Query<>.Queryable // (based on element type of expression) Type elementType = TypeSystem.GetElementType(expression.Type); ObjectQuery query = CreateQuery(expression, elementType); return query; } ////// Executes the given LINQ expression returning a single value, or null if the query yields /// no results. /// The current query is used to produce the context for the new query, but none of its logic /// is used. /// /// Expression to evaluate. ///Single result from execution. object IQueryProvider.Execute(Expression expression) { EntityUtil.CheckArgumentNull(expression, "expression"); ObjectQuery query = CreateQuery(expression, expression.Type); IEnumerable
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- TdsParser.cs
- Visual3D.cs
- Span.cs
- ObjectListItem.cs
- TableItemProviderWrapper.cs
- QueryReaderSettings.cs
- PackageRelationshipCollection.cs
- DecoderFallback.cs
- DesignerEditorPartChrome.cs
- _LazyAsyncResult.cs
- WmlControlAdapter.cs
- ErrorStyle.cs
- ComponentRenameEvent.cs
- EntityDataSourceChangedEventArgs.cs
- ValidatingPropertiesEventArgs.cs
- XmlElementAttributes.cs
- CatalogZoneBase.cs
- ListBox.cs
- AuthorizationRule.cs
- DataServiceRequestException.cs
- Point3D.cs
- HMACSHA256.cs
- ObjectItemCollection.cs
- BaseCollection.cs
- Itemizer.cs
- DbMetaDataCollectionNames.cs
- TabPage.cs
- HitTestFilterBehavior.cs
- WmfPlaceableFileHeader.cs
- ContentOperations.cs
- SqlCacheDependencySection.cs
- ExpressionBindingCollection.cs
- CachedPathData.cs
- ToolStripLabel.cs
- TraceUtils.cs
- MinimizableAttributeTypeConverter.cs
- FormsAuthenticationUser.cs
- _UriTypeConverter.cs
- StreamInfo.cs
- WindowsListView.cs
- SqlBuilder.cs
- XmlTextReaderImplHelpers.cs
- httpserverutility.cs
- EmbeddedMailObject.cs
- FileVersion.cs
- KeyInstance.cs
- CuspData.cs
- SqlInternalConnection.cs
- SourceFileInfo.cs
- LinkLabelLinkClickedEvent.cs
- Substitution.cs
- SHA512Managed.cs
- PropertyGeneratedEventArgs.cs
- ChtmlPageAdapter.cs
- XmlSchemaType.cs
- KeyValuePairs.cs
- StatusBarItemAutomationPeer.cs
- AspCompat.cs
- AuthenticatingEventArgs.cs
- XmlElement.cs
- HtmlTextArea.cs
- StrongNameUtility.cs
- TaskFormBase.cs
- XmlUtilWriter.cs
- XmlElement.cs
- AnnotationHighlightLayer.cs
- CryptoConfig.cs
- M3DUtil.cs
- HMAC.cs
- TimeZone.cs
- RepeaterItemCollection.cs
- EditorPartCollection.cs
- DesignTimeDataBinding.cs
- DataGridRowHeaderAutomationPeer.cs
- ToolboxControl.cs
- HMACSHA256.cs
- BooleanSwitch.cs
- DataGridDefaultColumnWidthTypeConverter.cs
- Signature.cs
- ClientRuntimeConfig.cs
- GridViewRowEventArgs.cs
- File.cs
- ProfileBuildProvider.cs
- DataGridViewRowStateChangedEventArgs.cs
- ByteAnimationBase.cs
- EventDriven.cs
- UnsafePeerToPeerMethods.cs
- GridViewDeleteEventArgs.cs
- RepeaterItemCollection.cs
- XsltLoader.cs
- CompModSwitches.cs
- ValueTypeFixupInfo.cs
- NotifyParentPropertyAttribute.cs
- DropDownList.cs
- NumericUpDownAcceleration.cs
- ListViewSortEventArgs.cs
- sqlinternaltransaction.cs
- XmlValueConverter.cs
- UnknownMessageReceivedEventArgs.cs
- NativeMethods.cs