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 / EntityClient / EntityAdapter.cs / 1 / EntityAdapter.cs
//---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....], [....] //--------------------------------------------------------------------- using System.Collections.Generic; using System.Text; using System.Data; using System.Data.Common; using System.Data.Mapping.Update.Internal; using System.Data.Objects; using System.Diagnostics; using System.Data.Mapping; namespace System.Data.EntityClient { ////// Class representing a data adapter for the conceptual layer /// internal sealed class EntityAdapter : IEntityAdapter { private bool _acceptChangesDuringUpdate = true; private EntityConnection _connection; private Int32? _commandTimeout; ////// Constructs the EntityAdapter object without a connection object /// public EntityAdapter() { } ////// Gets or sets the map connection used by this adapter. /// DbConnection IEntityAdapter.Connection { get { return this.Connection; } set { this.Connection = (EntityConnection)value; } } ////// Gets or sets the map connection used by this adapter. /// public EntityConnection Connection { get { return _connection; } set { _connection = value; } } ////// Gets or sets whether the IEntityCache.AcceptChanges should be called during a call to IEntityAdapter.Update. /// public bool AcceptChangesDuringUpdate { get { return this._acceptChangesDuringUpdate; } set { this._acceptChangesDuringUpdate = value; } } ////// Gets of sets the command timeout for update operations. If null, indicates that the default timeout /// for the provider should be used. /// Int32? IEntityAdapter.CommandTimeout { get { return this._commandTimeout; } set { this._commandTimeout = value; } } ////// Persist modifications described in the given cache. /// /// Entity cache containing changes to persist to the store. ///Number of cache entries affected by the udpate. public Int32 Update(IEntityStateManager entityCache) { EntityUtil.CheckArgumentNull(entityCache, "entityCache"); if (!IsStateManagerDirty(entityCache)) { return 0; } // Check that we have a connection before we proceed if (_connection == null) { throw EntityUtil.InvalidOperation(System.Data.Entity.Strings.EntityClient_NoConnectionForAdapter); } // Check that the store connection is available if (_connection.StoreProviderFactory == null || this._connection.StoreConnection == null) { throw EntityUtil.InvalidOperation(System.Data.Entity.Strings.EntityClient_NoStoreConnectionForUpdate); } // Check that the connection is open before we proceed if (ConnectionState.Open != _connection.State) { throw EntityUtil.InvalidOperation(System.Data.Entity.Strings.EntityClient_ClosedConnectionForUpdate); } return UpdateTranslator.Update(entityCache, this); } ////// Determine whether the cache has changes to apply. /// /// ObjectStateManager to check. Must not be null. ///true if cache contains changes entries; false otherwise private static bool IsStateManagerDirty(IEntityStateManager entityCache) { Debug.Assert(null != entityCache); bool hasChanges = false; // this call to GetCacheEntries is constant time (the ObjectStateManager implementation // maintains an explicit list of entries in each state) foreach (ObjectStateEntry entry in entityCache.GetEntityStateEntries( EntityState.Added | EntityState.Deleted | EntityState.Modified)) { hasChanges = true; break; } return hasChanges; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....], [....] //--------------------------------------------------------------------- using System.Collections.Generic; using System.Text; using System.Data; using System.Data.Common; using System.Data.Mapping.Update.Internal; using System.Data.Objects; using System.Diagnostics; using System.Data.Mapping; namespace System.Data.EntityClient { ////// Class representing a data adapter for the conceptual layer /// internal sealed class EntityAdapter : IEntityAdapter { private bool _acceptChangesDuringUpdate = true; private EntityConnection _connection; private Int32? _commandTimeout; ////// Constructs the EntityAdapter object without a connection object /// public EntityAdapter() { } ////// Gets or sets the map connection used by this adapter. /// DbConnection IEntityAdapter.Connection { get { return this.Connection; } set { this.Connection = (EntityConnection)value; } } ////// Gets or sets the map connection used by this adapter. /// public EntityConnection Connection { get { return _connection; } set { _connection = value; } } ////// Gets or sets whether the IEntityCache.AcceptChanges should be called during a call to IEntityAdapter.Update. /// public bool AcceptChangesDuringUpdate { get { return this._acceptChangesDuringUpdate; } set { this._acceptChangesDuringUpdate = value; } } ////// Gets of sets the command timeout for update operations. If null, indicates that the default timeout /// for the provider should be used. /// Int32? IEntityAdapter.CommandTimeout { get { return this._commandTimeout; } set { this._commandTimeout = value; } } ////// Persist modifications described in the given cache. /// /// Entity cache containing changes to persist to the store. ///Number of cache entries affected by the udpate. public Int32 Update(IEntityStateManager entityCache) { EntityUtil.CheckArgumentNull(entityCache, "entityCache"); if (!IsStateManagerDirty(entityCache)) { return 0; } // Check that we have a connection before we proceed if (_connection == null) { throw EntityUtil.InvalidOperation(System.Data.Entity.Strings.EntityClient_NoConnectionForAdapter); } // Check that the store connection is available if (_connection.StoreProviderFactory == null || this._connection.StoreConnection == null) { throw EntityUtil.InvalidOperation(System.Data.Entity.Strings.EntityClient_NoStoreConnectionForUpdate); } // Check that the connection is open before we proceed if (ConnectionState.Open != _connection.State) { throw EntityUtil.InvalidOperation(System.Data.Entity.Strings.EntityClient_ClosedConnectionForUpdate); } return UpdateTranslator.Update(entityCache, this); } ////// Determine whether the cache has changes to apply. /// /// ObjectStateManager to check. Must not be null. ///true if cache contains changes entries; false otherwise private static bool IsStateManagerDirty(IEntityStateManager entityCache) { Debug.Assert(null != entityCache); bool hasChanges = false; // this call to GetCacheEntries is constant time (the ObjectStateManager implementation // maintains an explicit list of entries in each state) foreach (ObjectStateEntry entry in entityCache.GetEntityStateEntries( EntityState.Added | EntityState.Deleted | EntityState.Modified)) { hasChanges = true; break; } return hasChanges; } } } // 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
- TimersDescriptionAttribute.cs
- XmlTextAttribute.cs
- PersistenceContextEnlistment.cs
- BuildManager.cs
- TypeFieldSchema.cs
- ProviderConnectionPointCollection.cs
- ImageProxy.cs
- COM2IDispatchConverter.cs
- DataBindEngine.cs
- ChannelManager.cs
- InvalidProgramException.cs
- ResolveDuplexCD1AsyncResult.cs
- MsmqAppDomainProtocolHandler.cs
- CompilationLock.cs
- WebServiceReceiveDesigner.cs
- InvalidOperationException.cs
- GridViewCellAutomationPeer.cs
- ComplexPropertyEntry.cs
- AssociatedControlConverter.cs
- SmtpClient.cs
- ImageDrawing.cs
- RegexFCD.cs
- Knowncolors.cs
- SoapProtocolImporter.cs
- RtfNavigator.cs
- CancelEventArgs.cs
- DBCommandBuilder.cs
- GridItemCollection.cs
- SqlDataSourceCache.cs
- QuerySettings.cs
- RadioButtonAutomationPeer.cs
- CodeDOMProvider.cs
- WindowsEditBox.cs
- SourceSwitch.cs
- DataSourceXmlSubItemAttribute.cs
- MonikerProxyAttribute.cs
- XmlBinaryReader.cs
- TileModeValidation.cs
- ExtendedTransformFactory.cs
- SecurityState.cs
- VisualStyleTypesAndProperties.cs
- EdmComplexPropertyAttribute.cs
- DeviceSpecific.cs
- SafeCertificateContext.cs
- MessageEventSubscriptionService.cs
- ILGenerator.cs
- IgnoreFileBuildProvider.cs
- CompilerError.cs
- x509utils.cs
- ValidationErrorInfo.cs
- Util.cs
- AutoScrollExpandMessageFilter.cs
- SqlColumnizer.cs
- PrintPreviewControl.cs
- ObjectDataSourceEventArgs.cs
- EventLogInternal.cs
- SlipBehavior.cs
- metadatamappinghashervisitor.cs
- CryptoHelper.cs
- StylusButton.cs
- Properties.cs
- tibetanshape.cs
- Geometry3D.cs
- LazyTextWriterCreator.cs
- TemporaryBitmapFile.cs
- DynamicRenderer.cs
- BackStopAuthenticationModule.cs
- WindowsFormsDesignerOptionService.cs
- TransactionFlowOption.cs
- PersistenceProviderDirectory.cs
- FileLevelControlBuilderAttribute.cs
- RolePrincipal.cs
- DataGridViewDataConnection.cs
- MetadataArtifactLoaderCompositeResource.cs
- DiffuseMaterial.cs
- ObfuscationAttribute.cs
- TabControlAutomationPeer.cs
- DomainConstraint.cs
- CodeBinaryOperatorExpression.cs
- HostedNamedPipeTransportManager.cs
- SqlClientMetaDataCollectionNames.cs
- ViewValidator.cs
- Point3DIndependentAnimationStorage.cs
- CodeObject.cs
- HtmlTitle.cs
- XmlILIndex.cs
- MachinePropertyVariants.cs
- DefaultTraceListener.cs
- BindingGraph.cs
- QueuePathDialog.cs
- NetworkInterface.cs
- __Filters.cs
- XamlFigureLengthSerializer.cs
- CriticalFinalizerObject.cs
- DataObjectSettingDataEventArgs.cs
- BlurEffect.cs
- StructuralCache.cs
- SignHashRequest.cs
- RequestTimeoutManager.cs
- EventItfInfo.cs