Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataEntity / System / Data / Map / ViewGeneration / DiscriminatorMap.cs / 1305376 / DiscriminatorMap.cs
//---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....] // @backupOwner [....] //--------------------------------------------------------------------- using System.Data.Common.CommandTrees; using System.Data.Common.CommandTrees.Internal; using System.Collections.Generic; using System.Data.Metadata.Edm; using System.Linq; using System.Globalization; using System.Diagnostics; using System.Data.Common.Utils; namespace System.Data.Mapping.ViewGeneration { ////// Describes top-level query mapping view projection of the form: /// /// SELECT VALUE CASE /// WHEN Discriminator = DiscriminatorValue1 THEN EntityType1(...) /// WHEN Discriminator = DiscriminatorValue2 THEN EntityType2(...) /// ... /// /// Supports optimizing queries to leverage user supplied discriminator values /// in TPH mappings rather than introducing our own. This avoids the need /// to introduce a CASE statement in the store. /// internal class DiscriminatorMap { ////// Expression retrieving discriminator value from projection input. /// internal readonly DbPropertyExpression Discriminator; ////// Map from discriminator values to implied entity type. /// internal readonly System.Collections.ObjectModel.ReadOnlyCollection> TypeMap; /// /// Map from entity property to expression generating value for that property. Note that /// the expression must be the same for all types in discriminator map. /// internal readonly System.Collections.ObjectModel.ReadOnlyCollection> PropertyMap; /// /// Map from entity relproperty to expression generating value for that property. Note that /// the expression must be the same for all types in discriminator map. /// internal readonly System.Collections.ObjectModel.ReadOnlyCollection> RelPropertyMap; /// /// EntitySet to which the map applies. /// internal readonly EntitySet EntitySet; private DiscriminatorMap(DbPropertyExpression discriminator, List> typeMap, Dictionary propertyMap, Dictionary relPropertyMap, EntitySet entitySet) { this.Discriminator = discriminator; this.TypeMap = typeMap.AsReadOnly(); this.PropertyMap = propertyMap.ToList().AsReadOnly(); this.RelPropertyMap = relPropertyMap.ToList().AsReadOnly(); this.EntitySet = entitySet; } /// /// Determines whether the given query view matches the discriminator map pattern. /// internal static bool TryCreateDiscriminatorMap(EntitySet entitySet, DbExpression queryView, out DiscriminatorMap discriminatorMap) { discriminatorMap = null; if (queryView.ExpressionKind != DbExpressionKind.Project) { return false; } var project = (DbProjectExpression)queryView; if (project.Projection.ExpressionKind != DbExpressionKind.Case) { return false; } var caseExpression = (DbCaseExpression)project.Projection; if (project.Projection.ResultType.EdmType.BuiltInTypeKind != BuiltInTypeKind.EntityType) { return false; } // determine value domain by walking filter if (project.Input.Expression.ExpressionKind != DbExpressionKind.Filter) { return false; } var filterExpression = (DbFilterExpression)project.Input.Expression; HashSet
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- sqlinternaltransaction.cs
- RegisterResponseInfo.cs
- CheckBoxStandardAdapter.cs
- TrustManagerMoreInformation.cs
- CleanUpVirtualizedItemEventArgs.cs
- ProcessHost.cs
- MD5CryptoServiceProvider.cs
- MultiPageTextView.cs
- SharedPersonalizationStateInfo.cs
- HtmlInputReset.cs
- PowerModeChangedEventArgs.cs
- IntegerFacetDescriptionElement.cs
- PropertySet.cs
- XamlGridLengthSerializer.cs
- SoapAttributeOverrides.cs
- EmptyStringExpandableObjectConverter.cs
- ModelUIElement3D.cs
- _SafeNetHandles.cs
- ServiceHandle.cs
- BlobPersonalizationState.cs
- XmlTypeMapping.cs
- AssociationTypeEmitter.cs
- InvokerUtil.cs
- PolyQuadraticBezierSegment.cs
- PathSegment.cs
- DesignerListAdapter.cs
- ImageConverter.cs
- TextHidden.cs
- GeneralTransform.cs
- JoinGraph.cs
- WebPartConnectionCollection.cs
- BreakRecordTable.cs
- TimelineCollection.cs
- ArrayElementGridEntry.cs
- DrawingGroupDrawingContext.cs
- ReadOnlyDictionary.cs
- AbandonedMutexException.cs
- TrackingProfile.cs
- NonParentingControl.cs
- FixedElement.cs
- SHA512Managed.cs
- StyleCollection.cs
- Attributes.cs
- SettingsProperty.cs
- Socket.cs
- MouseGesture.cs
- ThreadSafeList.cs
- NopReturnReader.cs
- ExtendLockAsyncResult.cs
- Token.cs
- HorizontalAlignConverter.cs
- EncoderExceptionFallback.cs
- ObjectConverter.cs
- ObjectDataSourceMethodEventArgs.cs
- MenuItemAutomationPeer.cs
- Filter.cs
- AudienceUriMode.cs
- EventTrigger.cs
- ContentElement.cs
- TextStore.cs
- NativeMethods.cs
- DBPropSet.cs
- LogStore.cs
- ConfigXmlCDataSection.cs
- PeerResolver.cs
- DataRecordInfo.cs
- PreservationFileWriter.cs
- TraceListeners.cs
- DefaultProxySection.cs
- WebPartTransformer.cs
- MemoryStream.cs
- TabItemAutomationPeer.cs
- HttpEncoderUtility.cs
- UriSectionReader.cs
- NameValueConfigurationCollection.cs
- DateRangeEvent.cs
- TraceUtils.cs
- DataGridViewControlCollection.cs
- ClientApiGenerator.cs
- SoapIgnoreAttribute.cs
- DrawingContext.cs
- StringUtil.cs
- PropertyCollection.cs
- ToolStripSeparatorRenderEventArgs.cs
- ASCIIEncoding.cs
- ExtendedProperty.cs
- ToggleProviderWrapper.cs
- TemplateBindingExtensionConverter.cs
- HitTestDrawingContextWalker.cs
- DocumentSequenceHighlightLayer.cs
- InfiniteIntConverter.cs
- EntityContainerRelationshipSetEnd.cs
- TransformDescriptor.cs
- ArrangedElementCollection.cs
- LedgerEntry.cs
- GradientStopCollection.cs
- AssemblyResourceLoader.cs
- ManagedWndProcTracker.cs
- ViewCellSlot.cs
- FieldNameLookup.cs