Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / ndp / fx / src / DataEntity / System / Data / Common / QueryCache / CompiledQueryCacheEntry.cs / 1 / CompiledQueryCacheEntry.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....], favbiofv //----------------------------------------------------------------------------- namespace System.Data.Common.QueryCache { using System; using System.Data.Metadata.Edm; using System.Data.Objects; using System.Data.Objects.Internal; using System.Diagnostics; using System.Threading; ////// Represents a compiled LINQ ObjectQuery cache entry /// internal sealed class CompiledQueryCacheEntry : QueryCacheEntry { ////// The merge option that was inferred during expression conversion. /// public readonly MergeOption? PropagatedMergeOption; ////// The execution plan to use for the 'AppendOnly' merge option. /// private ObjectQueryExecutionPlan _appendOnlyPlan; ////// The execution plan to use for the 'NoTracking' merge option. /// private ObjectQueryExecutionPlan _noTrackingPlan; ////// The execution plan to use for the 'OverwriteChanges' merge option. /// private ObjectQueryExecutionPlan _overwriteChangesPlan; ////// The execution plan to use for the 'PreserveChanges' merge option. /// private ObjectQueryExecutionPlan _preserveChangesPlan; #region Constructors ////// constructor /// /// The cache key that targets this cache entry ///The inferred merge option that applies to this cached query internal CompiledQueryCacheEntry(QueryCacheKey queryCacheKey, MergeOption? mergeOption) : base(queryCacheKey, null) { this.PropagatedMergeOption = mergeOption; } #endregion #region Methods/Properties ////// Retrieves the execution plan for the specified merge option. May return null if the plan for that merge option has yet to be populated. /// /// The merge option for which an execution plan is required. ///The corresponding execution plan, if it exists; otherwise internal ObjectQueryExecutionPlan GetExecutionPlan(MergeOption mergeOption) { switch(mergeOption) { case MergeOption.AppendOnly: return this._appendOnlyPlan; case MergeOption.NoTracking: return this._noTrackingPlan; case MergeOption.OverwriteChanges: return this._overwriteChangesPlan; case MergeOption.PreserveChanges: return this._preserveChangesPlan; default: throw EntityUtil.ArgumentOutOfRange("mergeOption"); } } ///null ./// Attempts to set the execution plan for /// The new execution plan to add to this cache entry. ///'s merge option on this cache entry to . /// If a plan already exists for that merge option, the current value is not changed but is returned to the caller. /// Otherwise is returned to the caller. /// The execution plan that corresponds to internal ObjectQueryExecutionPlan SetExecutionPlan(ObjectQueryExecutionPlan newPlan) { Debug.Assert(newPlan != null, "New plan cannot be null"); ObjectQueryExecutionPlan currentPlan; switch(newPlan.MergeOption) { case MergeOption.AppendOnly: currentPlan = Interlocked.CompareExchange(ref _appendOnlyPlan, newPlan, null); break; case MergeOption.NoTracking: currentPlan = Interlocked.CompareExchange(ref _noTrackingPlan, newPlan, null); break; case MergeOption.OverwriteChanges: currentPlan = Interlocked.CompareExchange(ref _overwriteChangesPlan, newPlan, null); break; case MergeOption.PreserveChanges: currentPlan = Interlocked.CompareExchange(ref _preserveChangesPlan, newPlan, null); break; default: throw EntityUtil.ArgumentOutOfRange("newPlan.MergeOption"); } return (currentPlan ?? newPlan); } ///'s merge option, which may be or may be a previously added execution plan. /// Convenience method to retrieve the result type from the first non-null execution plan found on this cache entry. /// /// The result type of any execution plan that is or could be added to this cache entry ///internal bool TryGetResultType(out TypeUsage resultType) { // AppendOnly - the default ObjectQueryExecutionPlan plan = this._appendOnlyPlan; if (plan != null) { resultType = plan.ResultType; return true; } // NoTracking plan = this._noTrackingPlan; if (plan != null) { resultType = plan.ResultType; return true; } // OverwriteChanges plan = this._overwriteChangesPlan; if (plan != null) { resultType = plan.ResultType; return true; } // PreserveChanges plan = this._preserveChangesPlan; if (plan != null) { resultType = plan.ResultType; return true; } // No plan is present resultType = null; return false; } #endregion } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ // true if at least one execution plan was present and a result type could be retrieved; otherwisefalse // Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....], favbiofv //----------------------------------------------------------------------------- namespace System.Data.Common.QueryCache { using System; using System.Data.Metadata.Edm; using System.Data.Objects; using System.Data.Objects.Internal; using System.Diagnostics; using System.Threading; ////// Represents a compiled LINQ ObjectQuery cache entry /// internal sealed class CompiledQueryCacheEntry : QueryCacheEntry { ////// The merge option that was inferred during expression conversion. /// public readonly MergeOption? PropagatedMergeOption; ////// The execution plan to use for the 'AppendOnly' merge option. /// private ObjectQueryExecutionPlan _appendOnlyPlan; ////// The execution plan to use for the 'NoTracking' merge option. /// private ObjectQueryExecutionPlan _noTrackingPlan; ////// The execution plan to use for the 'OverwriteChanges' merge option. /// private ObjectQueryExecutionPlan _overwriteChangesPlan; ////// The execution plan to use for the 'PreserveChanges' merge option. /// private ObjectQueryExecutionPlan _preserveChangesPlan; #region Constructors ////// constructor /// /// The cache key that targets this cache entry ///The inferred merge option that applies to this cached query internal CompiledQueryCacheEntry(QueryCacheKey queryCacheKey, MergeOption? mergeOption) : base(queryCacheKey, null) { this.PropagatedMergeOption = mergeOption; } #endregion #region Methods/Properties ////// Retrieves the execution plan for the specified merge option. May return null if the plan for that merge option has yet to be populated. /// /// The merge option for which an execution plan is required. ///The corresponding execution plan, if it exists; otherwise internal ObjectQueryExecutionPlan GetExecutionPlan(MergeOption mergeOption) { switch(mergeOption) { case MergeOption.AppendOnly: return this._appendOnlyPlan; case MergeOption.NoTracking: return this._noTrackingPlan; case MergeOption.OverwriteChanges: return this._overwriteChangesPlan; case MergeOption.PreserveChanges: return this._preserveChangesPlan; default: throw EntityUtil.ArgumentOutOfRange("mergeOption"); } } ///null ./// Attempts to set the execution plan for /// The new execution plan to add to this cache entry. ///'s merge option on this cache entry to . /// If a plan already exists for that merge option, the current value is not changed but is returned to the caller. /// Otherwise is returned to the caller. /// The execution plan that corresponds to internal ObjectQueryExecutionPlan SetExecutionPlan(ObjectQueryExecutionPlan newPlan) { Debug.Assert(newPlan != null, "New plan cannot be null"); ObjectQueryExecutionPlan currentPlan; switch(newPlan.MergeOption) { case MergeOption.AppendOnly: currentPlan = Interlocked.CompareExchange(ref _appendOnlyPlan, newPlan, null); break; case MergeOption.NoTracking: currentPlan = Interlocked.CompareExchange(ref _noTrackingPlan, newPlan, null); break; case MergeOption.OverwriteChanges: currentPlan = Interlocked.CompareExchange(ref _overwriteChangesPlan, newPlan, null); break; case MergeOption.PreserveChanges: currentPlan = Interlocked.CompareExchange(ref _preserveChangesPlan, newPlan, null); break; default: throw EntityUtil.ArgumentOutOfRange("newPlan.MergeOption"); } return (currentPlan ?? newPlan); } ///'s merge option, which may be or may be a previously added execution plan. /// Convenience method to retrieve the result type from the first non-null execution plan found on this cache entry. /// /// The result type of any execution plan that is or could be added to this cache entry ///internal bool TryGetResultType(out TypeUsage resultType) { // AppendOnly - the default ObjectQueryExecutionPlan plan = this._appendOnlyPlan; if (plan != null) { resultType = plan.ResultType; return true; } // NoTracking plan = this._noTrackingPlan; if (plan != null) { resultType = plan.ResultType; return true; } // OverwriteChanges plan = this._overwriteChangesPlan; if (plan != null) { resultType = plan.ResultType; return true; } // PreserveChanges plan = this._preserveChangesPlan; if (plan != null) { resultType = plan.ResultType; return true; } // No plan is present resultType = null; return false; } #endregion } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. true if at least one execution plan was present and a result type could be retrieved; otherwisefalse
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ZipIOZip64EndOfCentralDirectoryLocatorBlock.cs
- XmlComment.cs
- BindingMAnagerBase.cs
- TextBox.cs
- AxisAngleRotation3D.cs
- LineSegment.cs
- TextTreeInsertUndoUnit.cs
- TemplateXamlTreeBuilder.cs
- Funcletizer.cs
- BufferedReadStream.cs
- X509ScopedServiceCertificateElementCollection.cs
- Animatable.cs
- Html32TextWriter.cs
- TypeGeneratedEventArgs.cs
- InputLangChangeRequestEvent.cs
- UdpDiscoveryEndpointProvider.cs
- Menu.cs
- RegexCaptureCollection.cs
- BaseServiceProvider.cs
- SmiXetterAccessMap.cs
- ContentTextAutomationPeer.cs
- WinCategoryAttribute.cs
- TransactionBehavior.cs
- DragStartedEventArgs.cs
- SocketPermission.cs
- RectangleConverter.cs
- AllowedAudienceUriElementCollection.cs
- Pkcs7Signer.cs
- SafeFileMappingHandle.cs
- DesignerVerb.cs
- ZipIOExtraFieldPaddingElement.cs
- AutomationElementCollection.cs
- MaterialGroup.cs
- TrackingQueryElement.cs
- TrailingSpaceComparer.cs
- BindingManagerDataErrorEventArgs.cs
- JoinQueryOperator.cs
- BasicExpressionVisitor.cs
- PersistenceTypeAttribute.cs
- EntitySetBase.cs
- AvTraceFormat.cs
- XmlNodeChangedEventArgs.cs
- RandomNumberGenerator.cs
- ValueSerializerAttribute.cs
- DictionaryChange.cs
- dbenumerator.cs
- DelayedRegex.cs
- DataGridItemEventArgs.cs
- BrushValueSerializer.cs
- DependencyPropertyChangedEventArgs.cs
- DictionaryEditChange.cs
- OdbcEnvironmentHandle.cs
- RegistrationContext.cs
- ProfileInfo.cs
- HttpCacheVaryByContentEncodings.cs
- CalendarButtonAutomationPeer.cs
- DesignerLabelAdapter.cs
- WindowsSlider.cs
- Context.cs
- _CookieModule.cs
- SmtpMail.cs
- CatalogPartCollection.cs
- DataGridRelationshipRow.cs
- RemotingServices.cs
- ComplexPropertyEntry.cs
- PlaceHolder.cs
- InternalControlCollection.cs
- LinearQuaternionKeyFrame.cs
- TextDpi.cs
- ResourcesChangeInfo.cs
- ConfigurationFileMap.cs
- HMACSHA512.cs
- ZoneMembershipCondition.cs
- MemberCollection.cs
- PagesSection.cs
- DeclarativeCatalogPartDesigner.cs
- BindingValueChangedEventArgs.cs
- ToolStripHighContrastRenderer.cs
- DataControlFieldCollection.cs
- Pens.cs
- LogicalMethodInfo.cs
- SimpleApplicationHost.cs
- InstancePersistenceEvent.cs
- XhtmlBasicImageAdapter.cs
- XappLauncher.cs
- FileNotFoundException.cs
- QuadraticBezierSegment.cs
- ControlCachePolicy.cs
- UnicodeEncoding.cs
- ColorContext.cs
- ManifestResourceInfo.cs
- HttpException.cs
- JapaneseCalendar.cs
- LayoutManager.cs
- SettingsBase.cs
- TextLineBreak.cs
- IDReferencePropertyAttribute.cs
- DataGridTablesFactory.cs
- SqlWebEventProvider.cs
- PathData.cs