Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataEntity / System / Data / Map / Update / Internal / RecordConverter.cs / 1305376 / RecordConverter.cs
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// @owner [....]
// @backupOwner [....]
//---------------------------------------------------------------------
using System.Data.Common;
using System.Data.Metadata.Edm;
using System.Data.Objects;
using System.Collections.Generic;
using System.Data.Common.Utils;
using System.Collections;
using System.Data.Entity;
namespace System.Data.Mapping.Update.Internal
{
///
/// Converts records to new instance expressions. Assumes that all inputs come from a single data reader (because
/// it caches record layout). If multiple readers are used, multiple converters must be constructed in case
/// the different readers return different layouts for types.
///
///
/// Conventions for modifiedProperties enumeration: null means all properties are modified, empty means none,
/// non-empty means some.
///
internal class RecordConverter
{
#region Constructors
///
/// Initializes a new converter given a command tree context. Initializes a new record layout cache.
///
/// Sets
internal RecordConverter(UpdateTranslator updateTranslator)
{
m_updateTranslator = updateTranslator;
}
#endregion
#region Fields
///
/// Context used to produce expressions.
///
private UpdateTranslator m_updateTranslator;
#endregion
#region Methods
///
/// Converts original values in a state entry to a DbNewInstanceExpression. The record must be either an entity or
/// a relationship set instance.
///
///
/// This method is not thread safe.
///
/// Gets state entry this record is associated with.
/// Indicates how to determine whether a property is modified.
/// New instance expression.
internal PropagatorResult ConvertOriginalValuesToPropagatorResult(IEntityStateEntry stateEntry, ModifiedPropertiesBehavior modifiedPropertiesBehavior)
{
return ConvertStateEntryToPropagatorResult(stateEntry, useCurrentValues: false, modifiedPropertiesBehavior: modifiedPropertiesBehavior);
}
///
/// Converts current values in a state entry to a DbNewInstanceExpression. The record must be either an entity or
/// a relationship set instance.
///
///
/// This method is not thread safe.
///
/// Gets state entry this record is associated with.
/// Indicates how to determine whether a property is modified.
/// New instance expression.
internal PropagatorResult ConvertCurrentValuesToPropagatorResult(IEntityStateEntry stateEntry, ModifiedPropertiesBehavior modifiedPropertiesBehavior)
{
return ConvertStateEntryToPropagatorResult(stateEntry, useCurrentValues: true, modifiedPropertiesBehavior: modifiedPropertiesBehavior);
}
private PropagatorResult ConvertStateEntryToPropagatorResult(IEntityStateEntry stateEntry, bool useCurrentValues, ModifiedPropertiesBehavior modifiedPropertiesBehavior)
{
try
{
EntityUtil.CheckArgumentNull(stateEntry, "stateEntry");
IExtendedDataRecord record = useCurrentValues
? EntityUtil.CheckArgumentNull(stateEntry.CurrentValues as IExtendedDataRecord, "stateEntry.CurrentValues")
: EntityUtil.CheckArgumentNull(stateEntry.OriginalValues as IExtendedDataRecord, "stateEntry.OriginalValues");
bool isModified = false; // the root of the state entry is unchanged because the type is static
return ExtractorMetadata.ExtractResultFromRecord(stateEntry, isModified, record, useCurrentValues, m_updateTranslator, modifiedPropertiesBehavior);
}
catch (Exception e)
{
if (UpdateTranslator.RequiresContext(e))
{
throw EntityUtil.Update(Strings.Update_ErrorLoadingRecord, e, stateEntry);
}
throw;
}
}
#endregion
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// @owner [....]
// @backupOwner [....]
//---------------------------------------------------------------------
using System.Data.Common;
using System.Data.Metadata.Edm;
using System.Data.Objects;
using System.Collections.Generic;
using System.Data.Common.Utils;
using System.Collections;
using System.Data.Entity;
namespace System.Data.Mapping.Update.Internal
{
///
/// Converts records to new instance expressions. Assumes that all inputs come from a single data reader (because
/// it caches record layout). If multiple readers are used, multiple converters must be constructed in case
/// the different readers return different layouts for types.
///
///
/// Conventions for modifiedProperties enumeration: null means all properties are modified, empty means none,
/// non-empty means some.
///
internal class RecordConverter
{
#region Constructors
///
/// Initializes a new converter given a command tree context. Initializes a new record layout cache.
///
/// Sets
internal RecordConverter(UpdateTranslator updateTranslator)
{
m_updateTranslator = updateTranslator;
}
#endregion
#region Fields
///
/// Context used to produce expressions.
///
private UpdateTranslator m_updateTranslator;
#endregion
#region Methods
///
/// Converts original values in a state entry to a DbNewInstanceExpression. The record must be either an entity or
/// a relationship set instance.
///
///
/// This method is not thread safe.
///
/// Gets state entry this record is associated with.
/// Indicates how to determine whether a property is modified.
/// New instance expression.
internal PropagatorResult ConvertOriginalValuesToPropagatorResult(IEntityStateEntry stateEntry, ModifiedPropertiesBehavior modifiedPropertiesBehavior)
{
return ConvertStateEntryToPropagatorResult(stateEntry, useCurrentValues: false, modifiedPropertiesBehavior: modifiedPropertiesBehavior);
}
///
/// Converts current values in a state entry to a DbNewInstanceExpression. The record must be either an entity or
/// a relationship set instance.
///
///
/// This method is not thread safe.
///
/// Gets state entry this record is associated with.
/// Indicates how to determine whether a property is modified.
/// New instance expression.
internal PropagatorResult ConvertCurrentValuesToPropagatorResult(IEntityStateEntry stateEntry, ModifiedPropertiesBehavior modifiedPropertiesBehavior)
{
return ConvertStateEntryToPropagatorResult(stateEntry, useCurrentValues: true, modifiedPropertiesBehavior: modifiedPropertiesBehavior);
}
private PropagatorResult ConvertStateEntryToPropagatorResult(IEntityStateEntry stateEntry, bool useCurrentValues, ModifiedPropertiesBehavior modifiedPropertiesBehavior)
{
try
{
EntityUtil.CheckArgumentNull(stateEntry, "stateEntry");
IExtendedDataRecord record = useCurrentValues
? EntityUtil.CheckArgumentNull(stateEntry.CurrentValues as IExtendedDataRecord, "stateEntry.CurrentValues")
: EntityUtil.CheckArgumentNull(stateEntry.OriginalValues as IExtendedDataRecord, "stateEntry.OriginalValues");
bool isModified = false; // the root of the state entry is unchanged because the type is static
return ExtractorMetadata.ExtractResultFromRecord(stateEntry, isModified, record, useCurrentValues, m_updateTranslator, modifiedPropertiesBehavior);
}
catch (Exception e)
{
if (UpdateTranslator.RequiresContext(e))
{
throw EntityUtil.Update(Strings.Update_ErrorLoadingRecord, e, stateEntry);
}
throw;
}
}
#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
- Rijndael.cs
- ResXBuildProvider.cs
- DataGridViewColumnCollection.cs
- XPathDocument.cs
- EntityDataSourceEntityTypeFilterConverter.cs
- Number.cs
- MetricEntry.cs
- XPathBuilder.cs
- DiscoveryViaBehavior.cs
- BooleanKeyFrameCollection.cs
- DrawItemEvent.cs
- PageThemeBuildProvider.cs
- TextProperties.cs
- ComponentManagerBroker.cs
- InstancePersistenceCommand.cs
- WSHttpTransportSecurityElement.cs
- EntityDataSource.cs
- DbInsertCommandTree.cs
- BodyWriter.cs
- TextTreeTextBlock.cs
- WriteTimeStream.cs
- ScriptComponentDescriptor.cs
- StartUpEventArgs.cs
- complextypematerializer.cs
- StylusPoint.cs
- ObjectAnimationBase.cs
- AddInStore.cs
- WorkflowServiceHost.cs
- ConfigurationElement.cs
- XomlDesignerLoader.cs
- SafeMILHandle.cs
- ResourceReferenceKeyNotFoundException.cs
- SqlEnums.cs
- SqlProfileProvider.cs
- ChildChangedEventArgs.cs
- XmlIlTypeHelper.cs
- XmlValidatingReaderImpl.cs
- TextComposition.cs
- XmlMtomWriter.cs
- ControlBindingsCollection.cs
- CompilerInfo.cs
- BulletChrome.cs
- BitConverter.cs
- ContainerFilterService.cs
- HttpClientCertificate.cs
- XmlSecureResolver.cs
- DbSourceParameterCollection.cs
- ProcessHostFactoryHelper.cs
- CodeCompileUnit.cs
- EventData.cs
- AuthenticationConfig.cs
- EditorPart.cs
- X509CertificateInitiatorClientCredential.cs
- _AutoWebProxyScriptEngine.cs
- Content.cs
- ImageListUtils.cs
- PartialTrustVisibleAssembliesSection.cs
- KeyConverter.cs
- IdentifierService.cs
- WindowsListViewGroup.cs
- GroupByExpressionRewriter.cs
- XmlSchemaElement.cs
- RC2.cs
- XmlILModule.cs
- CompositeDataBoundControl.cs
- ThumbButtonInfo.cs
- LineBreakRecord.cs
- WindowsClientElement.cs
- PeerName.cs
- ColumnWidthChangingEvent.cs
- ConstNode.cs
- BaseTemplateCodeDomTreeGenerator.cs
- XmlnsCompatibleWithAttribute.cs
- MenuBindingsEditor.cs
- XmlTextAttribute.cs
- FileChangeNotifier.cs
- ControlValuePropertyAttribute.cs
- ErrorEventArgs.cs
- PackageProperties.cs
- ExpressionHelper.cs
- ManifestResourceInfo.cs
- LinqDataSourceHelper.cs
- BaseAsyncResult.cs
- sqlmetadatafactory.cs
- listviewsubitemcollectioneditor.cs
- OracleSqlParser.cs
- LZCodec.cs
- __TransparentProxy.cs
- SystemIcmpV6Statistics.cs
- ReflectEventDescriptor.cs
- TouchFrameEventArgs.cs
- BasicViewGenerator.cs
- FontStyleConverter.cs
- _FixedSizeReader.cs
- OdbcReferenceCollection.cs
- ProjectedSlot.cs
- Avt.cs
- ResourcePermissionBase.cs
- StackSpiller.Generated.cs
- FlowDocumentPage.cs