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 / internal / materialization / recordstatefactory.cs / 1 / recordstatefactory.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// [....]
//-----------------------------------------------------------------------------
using System.Collections.Generic;
using System.Data.Metadata.Edm;
using System.Linq;
using System.Linq.Expressions;
namespace System.Data.Common.Internal.Materialization
{
///
/// An immutable class used to generate new RecordStates, which are used
/// at runtime to produce value-layer (aka DataReader) results.
///
/// Contains static information collected by the Translator visitor. The
/// expressions produced by the Translator are compiled. The RecordStates
/// will refer to this object for all static information.
///
/// This class is cached in the query cache as part of the CoordinatorFactory.
///
internal class RecordStateFactory
{
#region state
///
/// Indicates which state slot in the Shaper.State is expected to hold the
/// value for this record state. Each unique record shape has it's own state
/// slot.
///
internal readonly int StateSlotNumber;
///
/// How many column values we have to reserve space for in this record.
///
internal readonly int ColumnCount;
///
/// The DataRecordInfo we must return for this record. If the record represents
/// an entity, this will be used to construct a unique EntityRecordInfo with the
/// EntityKey and EntitySet for the entity.
///
internal readonly DataRecordInfo DataRecordInfo;
///
/// A function that will gather the data for the row and store it on the record state.
///
internal readonly Func GatherData;
///
/// Collection of nested records for this record, such as a complex type that is
/// part of an entity. This does not include records that are part of a nested
/// collection, however.
///
internal readonly System.Collections.ObjectModel.ReadOnlyCollection NestedRecordStateFactories;
///
/// The name for each column.
///
internal readonly System.Collections.ObjectModel.ReadOnlyCollection ColumnNames;
///
/// The type usage information for each column.
///
internal readonly System.Collections.ObjectModel.ReadOnlyCollection TypeUsages;
///
/// Tracks which columns might need special handling (nested readers/records)
///
internal readonly System.Collections.ObjectModel.ReadOnlyCollection IsColumnNested;
///
/// Tracks whether there are ANY columns that need special handling.
///
internal readonly bool HasNestedColumns;
///
/// A helper class to make the translation from name->ordinal.
///
internal readonly FieldNameLookup FieldNameLookup;
///
/// Description of this RecordStateFactory, used for debugging only; while this
/// is not needed in retail code, it is pretty important because it's the only
/// description we'll have once we compile the Expressions; debugging a problem
/// with retail bits would be pretty hard without this.
///
private readonly string Description;
#endregion
#region constructor
public RecordStateFactory(int stateSlotNumber, int columnCount, RecordStateFactory[] nestedRecordStateFactories, DataRecordInfo dataRecordInfo, Expression gatherData, string[] propertyNames, TypeUsage[] typeUsages)
{
this.StateSlotNumber = stateSlotNumber;
this.ColumnCount = columnCount;
this.NestedRecordStateFactories = new System.Collections.ObjectModel.ReadOnlyCollection(nestedRecordStateFactories);
this.DataRecordInfo = dataRecordInfo;
this.GatherData = Translator.Compile(gatherData);
this.Description = gatherData.ToString();
this.ColumnNames = new System.Collections.ObjectModel.ReadOnlyCollection(propertyNames);
this.TypeUsages = new System.Collections.ObjectModel.ReadOnlyCollection(typeUsages);
this.FieldNameLookup = new FieldNameLookup(this.ColumnNames, -1);
// pre-compute the nested objects from typeUsage, for performance
bool[] isColumnNested = new bool[columnCount];
for (int ordinal = 0; ordinal < columnCount; ordinal++)
{
switch (typeUsages[ordinal].EdmType.BuiltInTypeKind)
{
case BuiltInTypeKind.EntityType:
case BuiltInTypeKind.ComplexType:
case BuiltInTypeKind.RowType:
case BuiltInTypeKind.CollectionType:
isColumnNested[ordinal] = true;
this.HasNestedColumns = true;
break;
default:
isColumnNested[ordinal] = false;
break;
}
}
this.IsColumnNested = new System.Collections.ObjectModel.ReadOnlyCollection(isColumnNested);
}
#endregion
#region "public" surface area
///
/// It's GO time, create the record state.
///
internal RecordState Create(CoordinatorFactory coordinatorFactory)
{
return new RecordState(this, coordinatorFactory);
}
#endregion
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// [....]
//-----------------------------------------------------------------------------
using System.Collections.Generic;
using System.Data.Metadata.Edm;
using System.Linq;
using System.Linq.Expressions;
namespace System.Data.Common.Internal.Materialization
{
///
/// An immutable class used to generate new RecordStates, which are used
/// at runtime to produce value-layer (aka DataReader) results.
///
/// Contains static information collected by the Translator visitor. The
/// expressions produced by the Translator are compiled. The RecordStates
/// will refer to this object for all static information.
///
/// This class is cached in the query cache as part of the CoordinatorFactory.
///
internal class RecordStateFactory
{
#region state
///
/// Indicates which state slot in the Shaper.State is expected to hold the
/// value for this record state. Each unique record shape has it's own state
/// slot.
///
internal readonly int StateSlotNumber;
///
/// How many column values we have to reserve space for in this record.
///
internal readonly int ColumnCount;
///
/// The DataRecordInfo we must return for this record. If the record represents
/// an entity, this will be used to construct a unique EntityRecordInfo with the
/// EntityKey and EntitySet for the entity.
///
internal readonly DataRecordInfo DataRecordInfo;
///
/// A function that will gather the data for the row and store it on the record state.
///
internal readonly Func GatherData;
///
/// Collection of nested records for this record, such as a complex type that is
/// part of an entity. This does not include records that are part of a nested
/// collection, however.
///
internal readonly System.Collections.ObjectModel.ReadOnlyCollection NestedRecordStateFactories;
///
/// The name for each column.
///
internal readonly System.Collections.ObjectModel.ReadOnlyCollection ColumnNames;
///
/// The type usage information for each column.
///
internal readonly System.Collections.ObjectModel.ReadOnlyCollection TypeUsages;
///
/// Tracks which columns might need special handling (nested readers/records)
///
internal readonly System.Collections.ObjectModel.ReadOnlyCollection IsColumnNested;
///
/// Tracks whether there are ANY columns that need special handling.
///
internal readonly bool HasNestedColumns;
///
/// A helper class to make the translation from name->ordinal.
///
internal readonly FieldNameLookup FieldNameLookup;
///
/// Description of this RecordStateFactory, used for debugging only; while this
/// is not needed in retail code, it is pretty important because it's the only
/// description we'll have once we compile the Expressions; debugging a problem
/// with retail bits would be pretty hard without this.
///
private readonly string Description;
#endregion
#region constructor
public RecordStateFactory(int stateSlotNumber, int columnCount, RecordStateFactory[] nestedRecordStateFactories, DataRecordInfo dataRecordInfo, Expression gatherData, string[] propertyNames, TypeUsage[] typeUsages)
{
this.StateSlotNumber = stateSlotNumber;
this.ColumnCount = columnCount;
this.NestedRecordStateFactories = new System.Collections.ObjectModel.ReadOnlyCollection(nestedRecordStateFactories);
this.DataRecordInfo = dataRecordInfo;
this.GatherData = Translator.Compile(gatherData);
this.Description = gatherData.ToString();
this.ColumnNames = new System.Collections.ObjectModel.ReadOnlyCollection(propertyNames);
this.TypeUsages = new System.Collections.ObjectModel.ReadOnlyCollection(typeUsages);
this.FieldNameLookup = new FieldNameLookup(this.ColumnNames, -1);
// pre-compute the nested objects from typeUsage, for performance
bool[] isColumnNested = new bool[columnCount];
for (int ordinal = 0; ordinal < columnCount; ordinal++)
{
switch (typeUsages[ordinal].EdmType.BuiltInTypeKind)
{
case BuiltInTypeKind.EntityType:
case BuiltInTypeKind.ComplexType:
case BuiltInTypeKind.RowType:
case BuiltInTypeKind.CollectionType:
isColumnNested[ordinal] = true;
this.HasNestedColumns = true;
break;
default:
isColumnNested[ordinal] = false;
break;
}
}
this.IsColumnNested = new System.Collections.ObjectModel.ReadOnlyCollection(isColumnNested);
}
#endregion
#region "public" surface area
///
/// It's GO time, create the record state.
///
internal RecordState Create(CoordinatorFactory coordinatorFactory)
{
return new RecordState(this, coordinatorFactory);
}
#endregion
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- InkSerializer.cs
- ValidatingPropertiesEventArgs.cs
- DateTimeConverter2.cs
- ADMembershipProvider.cs
- XslVisitor.cs
- XmlReflectionMember.cs
- JsonCollectionDataContract.cs
- WebPartDisplayMode.cs
- SeparatorAutomationPeer.cs
- FormView.cs
- WebPartHelpVerb.cs
- CodeNamespaceImport.cs
- StorageInfo.cs
- SortedList.cs
- Grid.cs
- CodeSnippetExpression.cs
- TypeConstant.cs
- TabPage.cs
- RangeBase.cs
- DataPagerFieldCommandEventArgs.cs
- BufferBuilder.cs
- StructuralObject.cs
- CategoryValueConverter.cs
- BrowserTree.cs
- WebPartConnectionsCancelVerb.cs
- SortedList.cs
- ReflectionUtil.cs
- SizeAnimation.cs
- QualificationDataItem.cs
- PauseStoryboard.cs
- CellLabel.cs
- LoginView.cs
- DataMisalignedException.cs
- ScrollEventArgs.cs
- TextRangeAdaptor.cs
- XsdValidatingReader.cs
- BaseParser.cs
- AccessText.cs
- MeshGeometry3D.cs
- ProfileService.cs
- DBParameter.cs
- DictionaryEntry.cs
- mongolianshape.cs
- MimeBasePart.cs
- UInt32.cs
- HttpsChannelListener.cs
- ReachSerializableProperties.cs
- HyperlinkAutomationPeer.cs
- ResourcePart.cs
- CodeComment.cs
- ScriptIgnoreAttribute.cs
- PositiveTimeSpanValidator.cs
- XmlWriterTraceListener.cs
- MarginsConverter.cs
- _SafeNetHandles.cs
- PopOutPanel.cs
- StorageConditionPropertyMapping.cs
- SchemaCollectionPreprocessor.cs
- DnsPermission.cs
- XmlSchemas.cs
- NamedPipeProcessProtocolHandler.cs
- ProgressiveCrcCalculatingStream.cs
- WebPartCancelEventArgs.cs
- SchemaInfo.cs
- GridViewRowPresenterBase.cs
- MetaType.cs
- MsmqQueue.cs
- ClipboardProcessor.cs
- JapaneseCalendar.cs
- SqlServer2KCompatibilityAnnotation.cs
- TextBlockAutomationPeer.cs
- WindowsGraphicsCacheManager.cs
- Pens.cs
- HyperLinkStyle.cs
- ToolStripGrip.cs
- HttpEncoder.cs
- CollectionDataContractAttribute.cs
- EventRecordWrittenEventArgs.cs
- Size.cs
- BufferModeSettings.cs
- ProtectedConfigurationProviderCollection.cs
- AppSecurityManager.cs
- XmlElementAttribute.cs
- MachineSettingsSection.cs
- ToolStripKeyboardHandlingService.cs
- DataGridColumn.cs
- ModuleElement.cs
- StrongNameUtility.cs
- TimeSpanStorage.cs
- GeneralTransformGroup.cs
- ExpressionConverter.cs
- BinHexDecoder.cs
- MetadataArtifactLoaderCompositeResource.cs
- ButtonChrome.cs
- ClipboardProcessor.cs
- BufferedStream.cs
- safex509handles.cs
- PathFigureCollection.cs
- BasePropertyDescriptor.cs
- RequestCacheManager.cs