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
- DrawingContext.cs
- PreservationFileWriter.cs
- RadioButtonBaseAdapter.cs
- QilBinary.cs
- Domain.cs
- SqlDesignerDataSourceView.cs
- VarRefManager.cs
- PropertyFilter.cs
- KeyedCollection.cs
- EventEntry.cs
- ThreadStartException.cs
- SynchronizedInputAdaptor.cs
- RemotingConfigParser.cs
- CodeMemberField.cs
- XslTransform.cs
- ExpressionBindingsDialog.cs
- SystemThemeKey.cs
- ResourceAssociationSet.cs
- TextWriterEngine.cs
- InvalidComObjectException.cs
- QueryableFilterRepeater.cs
- JsonFormatWriterGenerator.cs
- EntityDataSourceEntitySetNameItem.cs
- PerfService.cs
- ModelTreeEnumerator.cs
- Process.cs
- StringToken.cs
- BitmapEffect.cs
- TabControlEvent.cs
- ObjectQueryProvider.cs
- CompatibleComparer.cs
- XmlCountingReader.cs
- HitTestWithGeometryDrawingContextWalker.cs
- CompModSwitches.cs
- DiagnosticsConfigurationHandler.cs
- Sql8ConformanceChecker.cs
- LogReservationCollection.cs
- CodeCompileUnit.cs
- BamlResourceSerializer.cs
- PreservationFileWriter.cs
- TransformProviderWrapper.cs
- DataGridColumnDropSeparator.cs
- WindowsScrollBar.cs
- AddressAccessDeniedException.cs
- OdbcCommand.cs
- HybridCollection.cs
- XPathConvert.cs
- ConstrainedDataObject.cs
- DesignerVerbToolStripMenuItem.cs
- CharacterBuffer.cs
- SqlDataSourceConnectionPanel.cs
- Stacktrace.cs
- HttpProfileGroupBase.cs
- MemberNameValidator.cs
- DATA_BLOB.cs
- OutputCacheModule.cs
- FormViewUpdatedEventArgs.cs
- WebPartDescriptionCollection.cs
- SmiConnection.cs
- ITextView.cs
- Color.cs
- TextServicesProperty.cs
- ScrollBar.cs
- KnownTypes.cs
- DesignerDataSchemaClass.cs
- WebZoneDesigner.cs
- XmlSchemaObjectCollection.cs
- MulticastNotSupportedException.cs
- QilSortKey.cs
- TemplateBindingExtension.cs
- WindowsFormsHostAutomationPeer.cs
- QuaternionIndependentAnimationStorage.cs
- BroadcastEventHelper.cs
- SqlBinder.cs
- TranslateTransform.cs
- TraceListeners.cs
- DataExpression.cs
- AliasedSlot.cs
- TextElementAutomationPeer.cs
- Parameter.cs
- ProcessingInstructionAction.cs
- DeviceSpecificChoiceCollection.cs
- MissingMethodException.cs
- Grid.cs
- RSAPKCS1SignatureFormatter.cs
- WebPartRestoreVerb.cs
- ValueTable.cs
- SoapParser.cs
- httpserverutility.cs
- KeyEventArgs.cs
- DataGridViewBindingCompleteEventArgs.cs
- MappingModelBuildProvider.cs
- DetailsViewInsertedEventArgs.cs
- InkCanvasFeedbackAdorner.cs
- WindowsEditBoxRange.cs
- ToolStrip.cs
- TextFragmentEngine.cs
- TranslateTransform.cs
- WorkflowView.cs
- RtfToken.cs