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
- SecurityTokenParameters.cs
- SchemeSettingElementCollection.cs
- ConfigPathUtility.cs
- ProgressiveCrcCalculatingStream.cs
- ConnectionsZone.cs
- SecurityUtils.cs
- MetabaseSettingsIis7.cs
- IndexedWhereQueryOperator.cs
- FlowDocumentScrollViewer.cs
- RegisteredArrayDeclaration.cs
- UnsafeNativeMethodsPenimc.cs
- ProvidePropertyAttribute.cs
- RSAPKCS1KeyExchangeFormatter.cs
- UserControlParser.cs
- HasCopySemanticsAttribute.cs
- ReachVisualSerializer.cs
- ParameterReplacerVisitor.cs
- StringConverter.cs
- StorageEntityTypeMapping.cs
- AsymmetricCryptoHandle.cs
- ImagingCache.cs
- RoutingConfiguration.cs
- AstNode.cs
- validation.cs
- Char.cs
- PointHitTestResult.cs
- Renderer.cs
- GcSettings.cs
- GridViewColumnHeaderAutomationPeer.cs
- EditorZoneAutoFormat.cs
- BatchServiceHost.cs
- WmlCalendarAdapter.cs
- HtmlSelect.cs
- Encoder.cs
- ManipulationDeltaEventArgs.cs
- WebPartManagerInternals.cs
- CustomPopupPlacement.cs
- FontInfo.cs
- _OverlappedAsyncResult.cs
- SchemaMapping.cs
- TextEncodedRawTextWriter.cs
- TemplateBindingExpression.cs
- ListSourceHelper.cs
- HwndAppCommandInputProvider.cs
- QueryExpr.cs
- RegexCaptureCollection.cs
- OdbcPermission.cs
- GuidTagList.cs
- Int16Converter.cs
- EventWaitHandleSecurity.cs
- DbException.cs
- SHA512Managed.cs
- PolicyStatement.cs
- CollectionViewGroupRoot.cs
- ExpandoClass.cs
- WebConfigurationFileMap.cs
- PersonalizablePropertyEntry.cs
- DataComponentNameHandler.cs
- CodeDomSerializationProvider.cs
- AuthenticationManager.cs
- SystemKeyConverter.cs
- ProfileService.cs
- InternalTypeHelper.cs
- XsdDateTime.cs
- SamlAuthenticationClaimResource.cs
- Geometry3D.cs
- SqlDelegatedTransaction.cs
- RoleManagerModule.cs
- CellParagraph.cs
- SimpleTypesSurrogate.cs
- XmlBaseWriter.cs
- CngProvider.cs
- ExpandedWrapper.cs
- XamlTemplateSerializer.cs
- TranslateTransform.cs
- PropertyEmitterBase.cs
- SafeTokenHandle.cs
- webeventbuffer.cs
- EncodingFallbackAwareXmlTextWriter.cs
- SoapMessage.cs
- StandardCommands.cs
- TableCell.cs
- XmlILIndex.cs
- Types.cs
- AssemblyGen.cs
- XNameTypeConverter.cs
- EventLogPermissionEntry.cs
- HttpCachePolicyWrapper.cs
- HttpRuntimeSection.cs
- PolyBezierSegment.cs
- AudioStateChangedEventArgs.cs
- ConfigurationLocationCollection.cs
- While.cs
- ImageClickEventArgs.cs
- HtmlInputImage.cs
- RowParagraph.cs
- LogEntrySerializer.cs
- XsltContext.cs
- OutputCacheModule.cs
- DataPagerFieldCommandEventArgs.cs