Code:
/ 4.0 / 4.0 / 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.
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");
}
ObjectQuery query = 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");
ObjectQuery query = 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
- ACE.cs
- App.cs
- RedistVersionInfo.cs
- ListCollectionView.cs
- ServiceEndpointCollection.cs
- PointLight.cs
- ParagraphVisual.cs
- ObjectViewFactory.cs
- EventLogTraceListener.cs
- MiniLockedBorderGlyph.cs
- EntityDataSourceSelectingEventArgs.cs
- WebPartDisplayMode.cs
- HitTestParameters3D.cs
- WebPartActionVerb.cs
- DataGridViewSortCompareEventArgs.cs
- EventLogPermissionEntry.cs
- RegexCompilationInfo.cs
- AnimationClock.cs
- EventQueueState.cs
- DynamicValidatorEventArgs.cs
- HttpConfigurationSystem.cs
- DataGridLength.cs
- BufferedOutputAsyncStream.cs
- Tuple.cs
- ZipIOZip64EndOfCentralDirectoryBlock.cs
- ScaleTransform3D.cs
- RenderData.cs
- BoundingRectTracker.cs
- NameSpaceEvent.cs
- ButtonBase.cs
- Config.cs
- SuppressMergeCheckAttribute.cs
- SessionStateModule.cs
- DateTimeFormatInfoScanner.cs
- GroupItemAutomationPeer.cs
- SmiContextFactory.cs
- EditorPartCollection.cs
- _BaseOverlappedAsyncResult.cs
- MulticastIPAddressInformationCollection.cs
- ReferentialConstraintRoleElement.cs
- InstanceDescriptor.cs
- PrtTicket_Public.cs
- Atom10FormatterFactory.cs
- SrgsSubset.cs
- SafeEventLogReadHandle.cs
- AutomationElementIdentifiers.cs
- AssemblyContextControlItem.cs
- ExternalCalls.cs
- TypeConstant.cs
- SerializationObjectManager.cs
- CustomWebEventKey.cs
- ColumnMap.cs
- XmlUrlResolver.cs
- Clipboard.cs
- OdbcDataAdapter.cs
- Geometry.cs
- SecureConversationServiceElement.cs
- IdnMapping.cs
- SafeSecurityHandles.cs
- NetSectionGroup.cs
- X509WindowsSecurityToken.cs
- _FixedSizeReader.cs
- _CommandStream.cs
- DelimitedListTraceListener.cs
- PerformanceCountersBase.cs
- ExcCanonicalXml.cs
- ObjectQuery.cs
- DataBindingsDialog.cs
- TargetConverter.cs
- ListParaClient.cs
- DrawingImage.cs
- TableCellCollection.cs
- ApplyTemplatesAction.cs
- DeploymentSectionCache.cs
- JapaneseCalendar.cs
- PriorityBinding.cs
- XmlNamespaceMapping.cs
- ExternalFile.cs
- IdentitySection.cs
- RSAPKCS1KeyExchangeFormatter.cs
- SHA256.cs
- BCryptNative.cs
- XhtmlBasicImageAdapter.cs
- WebEventCodes.cs
- CapabilitiesState.cs
- SafePointer.cs
- ResourceCodeDomSerializer.cs
- SystemColorTracker.cs
- CacheMode.cs
- ArglessEventHandlerProxy.cs
- CultureInfo.cs
- DecimalMinMaxAggregationOperator.cs
- MULTI_QI.cs
- FlowDocumentFormatter.cs
- SqlErrorCollection.cs
- GeneralTransform3DCollection.cs
- WebContentFormatHelper.cs
- ExternalException.cs
- XmlMembersMapping.cs
- ErrorFormatterPage.cs