578 references to EntityState
System.Data.Entity (570)
System\Data\Common\EntityUtil.cs (16)
820
internal static InvalidOperationException ObjectStateManagerDoesnotAllowToReAddUnchangedOrModifiedOrDeletedEntity(
EntityState
state) {
838
internal static void CheckValidStateForChangeEntityState(
EntityState
state)
842
case
EntityState
.Added:
843
case
EntityState
.Unchanged:
844
case
EntityState
.Modified:
845
case
EntityState
.Deleted:
846
case
EntityState
.Detached:
853
internal static void CheckValidStateForChangeRelationshipState(
EntityState
state, string paramName)
857
case
EntityState
.Added:
858
case
EntityState
.Unchanged:
859
case
EntityState
.Deleted:
860
case
EntityState
.Detached:
882
internal static InvalidOperationException ChangedInDifferentStateFromChanging(
EntityState
currentState,
EntityState
previousState) {
1317
internal static InvalidOperationException EntityMustBeUnchangedOrModified(
EntityState
state) {
1320
internal static InvalidOperationException EntityMustBeUnchangedOrModifiedOrDeleted(
EntityState
state) {
System\Data\Common\Internal\Materialization\Shaper.cs (11)
209
if (
EntityState
.Added == existingEntry.State)
307
EntityState
newEntryState;
341
if (targetEntry.State ==
EntityState
.Detached)
363
if (targetEntry.IsKeyEntry || newEntryState ==
EntityState
.Deleted)
372
if (targetEntry.State !=
EntityState
.Deleted)
390
manager.AddNewRelation(wrapper,
EntityState
.Deleted);
754
if (
EntityState
.Added == existingEntry.State)
761
Debug.Assert(
EntityState
.Added != existingEntry.State, "entry in State=Added");
762
Debug.Assert(
EntityState
.Detached != existingEntry.State, "entry in State=Detached");
766
if (
EntityState
.Deleted == existingEntry.State)
778
if (
EntityState
.Unchanged == existingEntry.State)
System\Data\EntityClient\EntityAdapter.cs (3)
137
EntityState
.Added |
EntityState
.Deleted |
EntityState
.Modified))
System\Data\IEntityStateEntry.cs (1)
33
EntityState
State { get; }
System\Data\IEntityStateManager.cs (1)
24
IEnumerable<IEntityStateEntry> GetEntityStateEntries(
EntityState
state);
System\Data\Mapping\Update\Internal\ExtractedStateEntry.cs (5)
23
internal readonly
EntityState
State;
36
case
EntityState
.Deleted:
41
case
EntityState
.Unchanged:
47
case
EntityState
.Modified:
53
case
EntityState
.Added:
System\Data\Mapping\Update\Internal\ExtractorMetadata.cs (1)
222
Debug.Assert(entityEntry.State ==
EntityState
.Added,
System\Data\Mapping\Update\Internal\FunctionMappingTranslator.cs (9)
110
if (stateEntries.All(e => e.State ==
EntityState
.Unchanged))
164
case
EntityState
.Unchanged:
173
case
EntityState
.Added:
178
case
EntityState
.Deleted:
204
case
EntityState
.Added:
208
case
EntityState
.Deleted:
212
case
EntityState
.Unchanged:
213
case
EntityState
.Modified:
309
bool isInsert =
EntityState
.Added == stateEntry.State;
System\Data\Mapping\Update\Internal\FunctionUpdateCommand.cs (5)
339
private static ModificationOperator GetModificationOperator(
EntityState
state)
343
case
EntityState
.Modified:
344
case
EntityState
.Unchanged:
349
case
EntityState
.Added:
352
case
EntityState
.Deleted:
System\Data\Mapping\Update\Internal\RelationshipConstraintValidator.cs (12)
72
if (
EntityState
.Added == stateEntry.State ||
EntityState
.Deleted == stateEntry.State)
80
EntityType entityType =
EntityState
.Added == stateEntry.State ?
187
if (
EntityState
.Deleted == stateEntry.State)
226
EntityState
? violationType = default(
EntityState
?);
230
violationType =
EntityState
.Added;
235
violationType =
EntityState
.Deleted;
263
(isAdd &&
EntityState
.Added != entityEntry.State) ||
264
(!isAdd &&
EntityState
.Deleted != entityEntry.State))
445
if (current.StateEntry.State ==
EntityState
.Added)
449
else if (current.StateEntry.State ==
EntityState
.Deleted)
System\Data\Mapping\Update\Internal\UpdateCommand.cs (4)
112
if (stateEntry.State ==
EntityState
.Added)
116
else if (stateEntry.State ==
EntityState
.Deleted)
141
bool isAdded = stateEntry.State ==
EntityState
.Added;
142
if (isAdded || stateEntry.State ==
EntityState
.Deleted)
System\Data\Mapping\Update\Internal\UpdateCompiler.cs (1)
112
if (stateEntries.All(it => (it.State ==
EntityState
.Unchanged)))
System\Data\Mapping\Update\Internal\UpdateTranslator.cs (23)
173
DbDataRecord record = stateEntry.State ==
EntityState
.Added ?
208
if (stateEntry.State ==
EntityState
.Added || stateEntry.State ==
EntityState
.Modified)
212
if (stateEntry.State ==
EntityState
.Deleted || stateEntry.State ==
EntityState
.Modified)
324
if (currentValues && null != existingPrincipal && existingPrincipal.State ==
EntityState
.Deleted &&
325
(stateEntry.State ==
EntityState
.Added || stateEntry.State ==
EntityState
.Modified))
598
if (
EntityState
.Unchanged != stateEntry.State)
839
foreach (IEntityStateEntry addedEntry in m_stateManager.GetEntityStateEntries(
EntityState
.Added))
849
foreach (IEntityStateEntry modifiedEntry in m_stateManager.GetEntityStateEntries(
EntityState
.Modified |
EntityState
.Added |
EntityState
.Deleted))
854
foreach (IEntityStateEntry modifiedEntry in m_stateManager.GetEntityStateEntries(
EntityState
.Modified |
EntityState
.Added |
EntityState
.Deleted))
937
if (0 != ((
EntityState
.Added |
EntityState
.Modified |
EntityState
.Unchanged) & stateEntry.State))
943
if (0 != ((
EntityState
.Modified |
EntityState
.Deleted |
EntityState
.Unchanged) & stateEntry.State))
1014
endEntry.State ==
EntityState
.Unchanged) // if the entity is being modified, it's already included anyways
System\Data\Objects\DataClasses\EntityObject.cs (5)
48
EntityState
IEntityChangeTracker.EntityState
52
return
EntityState
.Detached;
83
public
EntityState
EntityState
89
Debug.Assert(EntityChangeTracker != s_detachedEntityChangeTracker ? EntityChangeTracker.EntityState !=
EntityState
.Detached : true,
222
return EntityState !=
EntityState
.Detached;
System\Data\Objects\DataClasses\EntityReference.cs (9)
134
if (relationshipEntry.State !=
EntityState
.Deleted &&
273
EntityState
relationshipState =
EntityState
.Added;
279
relationshipState =
EntityState
.Unchanged;
310
if (WrappedOwner.ObjectStateEntry.State !=
EntityState
.Added &&
432
(EntityKey == null && targetEntity.ObjectStateEntry.State ==
EntityState
.Deleted || // setting to a deleted principle
433
(CachedForeignKey == null && targetEntity.ObjectStateEntry.State ==
EntityState
.Added))))) // setting to an added principle
659
bool canSetModifiedProps = entry != null && (entry.State ==
EntityState
.Modified || entry.State ==
EntityState
.Unchanged);
System\Data\Objects\DataClasses\EntityReference_TResultType.cs (6)
308
relationshipEntry.State !=
EntityState
.Deleted)
322
if (existingEntry.State ==
EntityState
.Deleted)
366
manager.AddNewRelation(wrapper, doAttach ?
EntityState
.Unchanged :
EntityState
.Added);
403
if (relationshipEntry != null && relationshipEntry.State !=
EntityState
.Detached)
445
if (relationshipEntry.State !=
EntityState
.Detached)
System\Data\Objects\DataClasses\IEntityChangeTracker.cs (1)
53
EntityState
EntityState { get; }
System\Data\Objects\DataClasses\RelatedEnd.cs (35)
337
EntityState
entityState;
342
entityState =
EntityState
.Detached;
356
if (entityState ==
EntityState
.Added &&
363
Debug.Assert(!(entityState !=
EntityState
.Detached && UsingNoTracking), "Entity with NoTracking option cannot exist in the ObjectStateManager");
370
if (!((entityState ==
EntityState
.Detached && UsingNoTracking) ||
371
entityState ==
EntityState
.Modified ||
372
entityState ==
EntityState
.Unchanged ||
373
entityState ==
EntityState
.Deleted ||
374
entityState ==
EntityState
.Added))
676
if (entry != null && entry.State ==
EntityState
.Deleted)
740
(_wrappedOwner.ObjectStateEntry.State ==
EntityState
.Unchanged ||
741
_wrappedOwner.ObjectStateEntry.State ==
EntityState
.Modified ||
742
(_wrappedOwner.ObjectStateEntry.State ==
EntityState
.Added && IsForeignKey && IsDependentEndOfReferentialConstraint(false)))))
910
if (stateEntry.State !=
EntityState
.Modified &&
911
stateEntry.State !=
EntityState
.Unchanged)
951
Debug.Assert(stateEntry.State !=
EntityState
.Detached,
956
if (stateEntry.State !=
EntityState
.Unchanged &&
957
stateEntry.State !=
EntityState
.Modified)
1117
if (entry != null && entry.State ==
EntityState
.Deleted)
1579
if (null != cacheEntry && cacheEntry.State ==
EntityState
.Deleted)
1666
if (cacheEntry.State ==
EntityState
.Added)
1681
if (doAttach && cacheEntry.State !=
EntityState
.Added)
1703
if (dependentEntry.State ==
EntityState
.Unchanged || dependentEntry.State ==
EntityState
.Modified)
1758
if (null != cacheEntry && cacheEntry.State !=
EntityState
.Deleted && !wrappedEntity.RelationshipManager.NodeVisited)
1832
if (wrappedRelatedEntity.ObjectStateEntry != null && wrappedRelatedEntity.ObjectStateEntry.State ==
EntityState
.Added)
1870
dependent.State !=
EntityState
.Added &&
1871
dependent.State !=
EntityState
.Deleted &&
1872
dependent.State !=
EntityState
.Detached)
1985
internal void DetachAll(
EntityState
ownerEntityState)
1997
ownerEntityState ==
EntityState
.Added ||
2165
(addRelationshipAsUnchanged || doAttach) ?
EntityState
.Unchanged :
EntityState
.Added);
2194
if (entry != null && entry.State !=
EntityState
.Detached)
2207
if (deletedEntry != null && deletedEntry.State !=
EntityState
.Detached)
System\Data\Objects\DataClasses\RelationshipManager.cs (1)
1181
internal void DetachEntityFromRelationships(
EntityState
ownerEntityState)
System\Data\Objects\EntityEntry.cs (161)
60
StateManagerTypeMetadata typeMetadata,
EntityState
state)
102
: base(cache, entitySet,
EntityState
.Unchanged)
191
if (
EntityState
.Modified == this.State && _modifiedFields != null)
214
Debug.Assert(State ==
EntityState
.Unchanged || State ==
EntityState
.Modified, "ValidateAndGetOrdinalForProperty should have thrown.");
216
if (
EntityState
.Unchanged == State)
218
State =
EntityState
.Modified;
219
_cache.ChangeState(this,
EntityState
.Unchanged, State);
253
if (State ==
EntityState
.Added || State ==
EntityState
.Deleted)
281
if (State ==
EntityState
.Unchanged)
287
Debug.Assert(State ==
EntityState
.Modified, "Should have handled all other states above.");
307
ChangeObjectState(
EntityState
.Unchanged);
336
if (this.State ==
EntityState
.Added)
392
if (this.State ==
EntityState
.Deleted)
431
Debug.Assert(!this.IsKeyEntry || State ==
EntityState
.Unchanged, "Key ObjectStateEntries must always be unchanged.");
435
case
EntityState
.Deleted:
440
_cache.ChangeState(this,
EntityState
.Deleted,
EntityState
.Detached);
443
case
EntityState
.Added:
462
State =
EntityState
.Unchanged;
474
case
EntityState
.Modified:
475
_cache.ChangeState(this,
EntityState
.Modified,
EntityState
.Unchanged);
479
State =
EntityState
.Unchanged;
487
case
EntityState
.Unchanged:
502
if (
EntityState
.Unchanged == State)
504
State =
EntityState
.Modified;
505
_cache.ChangeState(this,
EntityState
.Unchanged, State);
507
else if (
EntityState
.Modified != State)
540
public override void ChangeState(
EntityState
state)
544
if (this.State ==
EntityState
.Detached && state ==
EntityState
.Detached)
940
State = (_modifiedFields == null) ?
EntityState
.Unchanged :
EntityState
.Modified;
941
_cache.ChangeState(this,
EntityState
.Deleted, State);
956
Debug.Assert(entry.State ==
EntityState
.Deleted, "Relationship ObjectStateEntry should be in deleted state");
964
Debug.Assert(State ==
EntityState
.Modified, "SetModifiedAll called when not modified");
1165
EntityState
initialState = State;
1166
if (State !=
EntityState
.Added)
1168
State =
EntityState
.Modified;
1170
if (State ==
EntityState
.Modified)
1183
SetCachedChangingValues(null, null, null,
EntityState
.Detached, null);
1197
if (State ==
EntityState
.Added)
1202
EntityState
initialState = State;
1238
if (initialState ==
EntityState
.Unchanged)
1240
State =
EntityState
.Modified;
1280
_cache.SaveOriginalValues = (State ==
EntityState
.Unchanged || State ==
EntityState
.Modified) &&
1287
Debug.Assert(this.State !=
EntityState
.Detached, "Change tracking should not happen on detached entities.");
1562
Debug.Assert(this.State !=
EntityState
.Detached, "Change tracking should not happen on detached entities.");
1623
private void SetCachedChangingValues(string entityMemberName, object changingObject, string changingMember,
EntityState
changingState, object oldValue)
1630
if (changingState ==
EntityState
.Detached)
1642
Debug.Assert(
EntityState
.Modified == State ||
1643
EntityState
.Deleted == State ||
1644
EntityState
.Unchanged == State,
1677
if (this.State !=
EntityState
.Added)
1824
if (this.State !=
EntityState
.Deleted)
1888
if (this.State !=
EntityState
.Deleted && !detectOnly)
1907
Debug.Assert(this.State !=
EntityState
.Added, "This method should not be called for entries in Added state");
1952
if (this.State !=
EntityState
.Deleted)
2112
(principalEntry.State ==
EntityState
.Modified || principalEntry.State ==
EntityState
.Unchanged))
2190
if (relatedWrapper.ObjectStateEntry.State ==
EntityState
.Deleted)
2195
(State & (
EntityState
.Modified |
EntityState
.Unchanged)) != 0 &&
2196
(relatedWrapper.ObjectStateEntry.State & (
EntityState
.Modified |
EntityState
.Unchanged)) != 0)
2420
this.State !=
EntityState
.Added &&
2446
EntityState
state = State;
2463
_cache.ChangeState(this, this.State,
EntityState
.Detached);
2467
if (state !=
EntityState
.Added)
2483
if (doFixup && this.State !=
EntityState
.Deleted)
2492
case
EntityState
.Added:
2493
Debug.Assert(
EntityState
.Added == State, "Expected ObjectStateEntry state is Added; make sure FixupRelationship did not corrupt cache entry state");
2495
_cache.ChangeState(this,
EntityState
.Added,
EntityState
.Detached);
2500
case
EntityState
.Modified:
2508
Debug.Assert(
EntityState
.Modified == State, "Expected ObjectStateEntry state is Modified; make sure FixupRelationship did not corrupt cache entry state");
2509
_cache.ChangeState(this,
EntityState
.Modified,
EntityState
.Deleted);
2510
State =
EntityState
.Deleted;
2513
case
EntityState
.Unchanged:
2521
Debug.Assert(State ==
EntityState
.Unchanged, "Unexpected state");
2522
Debug.Assert(
EntityState
.Unchanged == State, "Expected ObjectStateEntry state is Unchanged; make sure FixupRelationship did not corrupt cache entry state");
2523
_cache.ChangeState(this,
EntityState
.Unchanged,
EntityState
.Deleted);
2525
State =
EntityState
.Deleted;
2528
case
EntityState
.Deleted:
2588
if (relationshipEntry.State !=
EntityState
.Deleted)
2605
if (relationshipEntry.State ==
EntityState
.Deleted)
2633
if (State !=
EntityState
.Detached)
2641
if ((relationshipEntry.State !=
EntityState
.Deleted) &&
2794
if (otherEnd.State ==
EntityState
.Unchanged || otherEnd.State ==
EntityState
.Modified)
2880
if (State ==
EntityState
.Added)
2886
if (State !=
EntityState
.Unchanged)
2888
_cache.ChangeState(this, this.State,
EntityState
.Unchanged);
2889
State =
EntityState
.Unchanged;
2985
if (this.State ==
EntityState
.Deleted)
2996
if (member.IsPartOfKey && State !=
EntityState
.Added)
3040
if (relationshipEntry.State ==
EntityState
.Unchanged)
3042
this.ObjectStateManager.ChangeState(relationshipEntry,
EntityState
.Unchanged,
EntityState
.Added);
3043
relationshipEntry.State =
EntityState
.Added;
3046
else if (relationshipEntry.State ==
EntityState
.Deleted)
3064
internal void ChangeObjectState(
EntityState
requestedState)
3068
if (requestedState ==
EntityState
.Unchanged)
3077
case
EntityState
.Added:
3080
case
EntityState
.Added:
3084
case
EntityState
.Unchanged:
3088
case
EntityState
.Modified:
3094
case
EntityState
.Deleted:
3103
case
EntityState
.Detached:
3111
case
EntityState
.Unchanged:
3114
case
EntityState
.Added:
3119
this.State =
EntityState
.Added;
3123
case
EntityState
.Unchanged:
3126
case
EntityState
.Modified:
3131
case
EntityState
.Deleted:
3136
case
EntityState
.Detached:
3144
case
EntityState
.Modified:
3147
case
EntityState
.Added:
3152
this.State =
EntityState
.Added;
3156
case
EntityState
.Unchanged:
3160
case
EntityState
.Modified:
3165
case
EntityState
.Deleted:
3170
case
EntityState
.Detached:
3178
case
EntityState
.Deleted:
3181
case
EntityState
.Added:
3189
this.State =
EntityState
.Added;
3193
case
EntityState
.Unchanged:
3200
this.ObjectStateManager.ChangeState(this,
EntityState
.Deleted,
EntityState
.Unchanged);
3201
this.State =
EntityState
.Unchanged;
3210
case
EntityState
.Modified:
3214
this.ObjectStateManager.ChangeState(this,
EntityState
.Deleted,
EntityState
.Modified);
3215
this.State =
EntityState
.Modified;
3222
case
EntityState
.Deleted:
3225
case
EntityState
.Detached:
3233
case
EntityState
.Detached:
3241
Debug.Assert(
EntityState
.Added != this.State, "Cannot change original values of an entity in the Added state");
3243
EntityState
oldState = this.State;
3247
if (oldState ==
EntityState
.Unchanged && this.State ==
EntityState
.Modified)
3250
this.ObjectStateManager.ChangeState(this, oldState,
EntityState
.Modified);
3346
if (this.State !=
EntityState
.Modified &&
3347
this.State !=
EntityState
.Unchanged)
3373
if (this.State !=
EntityState
.Modified &&
3374
this.State !=
EntityState
.Unchanged &&
3375
this.State !=
EntityState
.Deleted)
3532
relatedEnd.ReferenceValue.ObjectStateEntry.State !=
EntityState
.Added);
3546
principalEntry.State !=
EntityState
.Deleted &&
3573
if (setIsLoaded && principalEntry.State !=
EntityState
.Added)
3709
if (principalEntry != null && principalEntry.State ==
EntityState
.Added &&
3760
if (dependentEntry.State !=
EntityState
.Added && !dependentPropsChecked)
3780
if (dependentEntry.State ==
EntityState
.Added || (dependentEntry.State ==
EntityState
.Modified && !fkOverlapsPk))
3907
Debug.Assert(this.State ==
EntityState
.Added || this.State ==
EntityState
.Modified, "unexpected state");
System\Data\Objects\Internal\SnapshotChangeTrackingStrategy.cs (1)
88
if (entry.State !=
EntityState
.Added)
System\Data\Objects\ObjectContext.cs (21)
499
foreach (ObjectStateEntry entry in ObjectStateManager.GetObjectStateEntries(
EntityState
.Deleted))
504
foreach (ObjectStateEntry entry in ObjectStateManager.GetObjectStateEntries(
EntityState
.Added |
EntityState
.Modified))
577
EntityState
exptectedState = doAttach ?
EntityState
.Unchanged :
EntityState
.Added;
961
if (ose.State !=
EntityState
.Modified &&
962
ose.State !=
EntityState
.Unchanged &&
963
ose.State !=
EntityState
.Deleted)
2027
if (
EntityState
.Added == entry.State)
2031
Debug.Assert(
EntityState
.Added != entry.State, "not expecting added");
2032
Debug.Assert(
EntityState
.Detached != entry.State, "not expecting detached");
2101
Debug.Assert(
EntityState
.Added != item.Value.State, "should not be possible");
2102
if (
EntityState
.Detached != item.Value.State)
2118
Debug.Assert(
EntityState
.Detached != item.Value.State, "not expecting detached");
2131
Debug.Assert(
EntityState
.Added != item.Value.State, "should not be possible");
2132
if (item.Value.State ==
EntityState
.Deleted)
2248
if ((null != entry) && (
EntityState
.Modified == entry.State))
2345
Int32 entriesAffected = ObjectStateManager.GetObjectStateEntriesCount(
EntityState
.Added |
EntityState
.Deleted |
EntityState
.Modified);
System\Data\Objects\ObjectStateEntry.cs (7)
36
internal
EntityState
_state;
41
internal ObjectStateEntry(ObjectStateManager cache, EntitySet entitySet,
EntityState
state)
83
public
EntityState
State
221
abstract public void ChangeState(
EntityState
state);
308
EntityState
IEntityChangeTracker.EntityState
348
_state =
EntityState
.Detached;
353
if (_state ==
EntityState
.Detached)
System\Data\Objects\ObjectStateEntryDbDataRecord.cs (6)
35
case
EntityState
.Unchanged:
36
case
EntityState
.Modified:
37
case
EntityState
.Deleted:
53
case
EntityState
.Unchanged:
54
case
EntityState
.Modified:
55
case
EntityState
.Deleted:
System\Data\Objects\ObjectStateEntryDbUpdatableDataRecord.cs (6)
31
case
EntityState
.Unchanged:
32
case
EntityState
.Modified:
33
case
EntityState
.Added:
46
case
EntityState
.Unchanged:
47
case
EntityState
.Modified:
48
case
EntityState
.Added:
System\Data\Objects\ObjectStateEntryOriginalDbUpdatableDataRecord.cs (7)
33
case
EntityState
.Unchanged:
34
case
EntityState
.Modified:
35
case
EntityState
.Deleted:
91
EntityState
oldState = entry.State;
118
if (oldState ==
EntityState
.Unchanged && entry.State ==
EntityState
.Modified)
120
entry.ObjectStateManager.ChangeState(entry, oldState,
EntityState
.Modified);
System\Data\Objects\ObjectStateManager.cs (152)
99
private
EntityState
_changingState;
165
internal
EntityState
ChangingState
399
if (existingEntry.State !=
EntityState
.Added) // (state == DataRowState.Unchanged && state == DataRowState.Modified)
429
EntityEntry newEntry = new EntityEntry(wrappedObject, entityKey, entitySet, this, typeMetadata, isAdded ?
EntityState
.Added :
EntityState
.Unchanged);
498
if (!(dFkEntry.State ==
EntityState
.Detached || entry.State ==
EntityState
.Detached))
516
HashSet<ObjectStateEntry> validEntries = new HashSet<ObjectStateEntry>(GetObjectStateEntriesInternal(~
EntityState
.Detached));
520
Debug.Assert(validEntries.Contains(entry), "The entry in the dangling foreign key store is no longer in the ObjectStateManager. Key=" + (entry.State ==
EntityState
.Detached ? "detached" : entry.EntityKey != null ? "null" : entry.EntityKey.ConcatKeyValue()));
521
Debug.Assert(entry.State ==
EntityState
.Detached || !ForeignKeyFactory.IsConceptualNullKey(entry.EntityKey), "Found an entry with conceptual null Key=" + entry.EntityKey.ConcatKeyValue());
716
if (relationshipEntry.State !=
EntityState
.Deleted)
864
if (relationshipEntry.State ==
EntityState
.Deleted)
869
Debug.Assert(relationshipEntry.State ==
EntityState
.Detached, "relationshipEntry should be Detached");
998
EntityState
newEntryState;
1042
if (newEntryState !=
EntityState
.Deleted)
1059
manager.AddNewRelation(wrapper,
EntityState
.Deleted);
1133
relationshipEntry.State !=
EntityState
.Added)
1163
internal static bool TryUpdateExistingRelationships(ObjectContext context, MergeOption mergeOption, AssociationSet associationSet, AssociationEndMember sourceMember, EntityKey sourceKey, IEntityWrapper wrappedSource, AssociationEndMember targetMember, EntityKey targetKey, bool setIsLoaded, out
EntityState
newEntryState)
1171
newEntryState =
EntityState
.Unchanged;
1216
if (relationshipEntry.State !=
EntityState
.Deleted)
1218
Debug.Assert(relationshipEntry.State ==
EntityState
.Added || relationshipEntry.State ==
EntityState
.Unchanged, "Unexpected relationshipEntry state");
1233
case
EntityState
.Added:
1234
newEntryState =
EntityState
.Deleted;
1236
case
EntityState
.Unchanged:
1244
case
EntityState
.Deleted:
1245
newEntryState =
EntityState
.Deleted;
1280
if (entryToDetach.State !=
EntityState
.Detached)
1303
if (relationshipEntry.State ==
EntityState
.Added)
1307
else if (relationshipEntry.State ==
EntityState
.Deleted)
1314
if (targetEntry.State !=
EntityState
.Deleted)
1335
if (relationshipEntry.State ==
EntityState
.Added)
1364
if (relationshipToRemove.State !=
EntityState
.Deleted)
1371
if (relationshipToRemove.State !=
EntityState
.Detached)
1432
EntityEntry newEntry = new EntityEntry(wrappedObject, entityKey, entitySet, this, typeMetadata,
EntityState
.Unchanged);
1500
internal RelationshipEntry AddNewRelation(RelationshipWrapper wrapper,
EntityState
desiredState)
1510
internal RelationshipEntry AddRelation(RelationshipWrapper wrapper,
EntityState
desiredState)
1512
Debug.Assert(
EntityState
.Added == desiredState || // result entry should be added or left alone
1513
EntityState
.Unchanged == desiredState || // result entry should be that state
1514
EntityState
.Deleted == desiredState, // result entry should be in that state
1518
Debug.Assert(null == entry || (
EntityState
.Modified != entry.State), "relationship should never be modified");
1524
else if (
EntityState
.Deleted != entry.State)
1528
if (
EntityState
.Unchanged == desiredState)
1532
else if (
EntityState
.Deleted == desiredState)
1539
else if (
EntityState
.Deleted != desiredState)
1541
Debug.Assert(
EntityState
.Deleted == entry.State, "should be deleted state");
1547
EntityState
.Added == desiredState,
1597
Debug.Assert(relationship.State !=
EntityState
.Detached, "Cannot remove a detached cache entry.");
1650
ChangeState(keyEntry, keyEntry.State,
EntityState
.Detached);
1769
public IEnumerable<ObjectStateEntry> GetObjectStateEntries(
EntityState
state)
1771
if ((
EntityState
.Detached & state) != 0)
1782
IEnumerable<IEntityStateEntry> IEntityStateManager.GetEntityStateEntries(
EntityState
state)
1784
Debug.Assert((
EntityState
.Detached & state) == 0, "Cannot get state entries for detached entities");
1791
internal int GetObjectStateEntriesCount(
EntityState
state)
1794
if ((
EntityState
.Added & state) != 0)
1799
if ((
EntityState
.Modified & state) != 0)
1803
if ((
EntityState
.Deleted & state) != 0)
1808
if ((
EntityState
.Unchanged & state) != 0)
1838
private ObjectStateEntry[] GetObjectStateEntriesInternal(
EntityState
state)
1840
Debug.Assert((
EntityState
.Detached & state) == 0, "Cannot get state entries for detached entities");
1846
if (((
EntityState
.Added & state) != 0) && (null != _addedRelationshipStore))
1853
if (((
EntityState
.Deleted & state) != 0) && (null != _deletedRelationshipStore))
1860
if (((
EntityState
.Unchanged & state) != 0) && (null != _unchangedRelationshipStore))
1867
if (((
EntityState
.Added & state) != 0) && (null != _addedEntityStore))
1874
if (((
EntityState
.Modified & state) != 0) && (null != _modifiedEntityStore))
1881
if (((
EntityState
.Deleted & state) != 0) && (null != _deletedEntityStore))
1888
if (((
EntityState
.Unchanged & state) != 0) && (null != _unchangedEntityStore))
1960
Debug.Assert(entry.State ==
EntityState
.Added, "Cannot do key fixup for an entry not in the Added state.");
2015
RemoveObjectStateEntryFromDictionary(entry,
EntityState
.Added);
2037
Debug.Assert(existingEntry.State ==
EntityState
.Unchanged, "entity stub must be in unchanged state");
2049
AddEntityEntryToDictionary(entry,
EntityState
.Unchanged);
2069
Debug.Assert(entry.State !=
EntityState
.Added, "Cannot replace key with a temporary key if the entry is in Added state.");
2103
AddEntityEntryToDictionary(entry,
EntityState
.Added);
2151
public ObjectStateEntry ChangeObjectState(object entity,
EntityState
entityState)
2168
if (entityState ==
EntityState
.Detached)
2200
EntityState
relationshipState)
2228
EntityState
relationshipState) where TEntity : class
2262
EntityState
relationshipState)
2278
EntityState
relationshipState)
2288
if (relationshipEntry == null && relationshipState ==
EntityState
.Detached)
2311
Debug.Assert(relationshipState !=
EntityState
.Detached || relationshipEntry.State ==
EntityState
.Detached, "state should be detached");
2312
return relationshipState ==
EntityState
.Detached ? null : relationshipEntry;
2324
private void VerifyInitialStateForChangeRelationshipState(EntityEntry sourceEntry, EntityEntry targetEntry, RelatedEnd relatedEnd,
EntityState
relationshipState)
2335
if ((sourceEntry.State ==
EntityState
.Deleted || targetEntry.State ==
EntityState
.Deleted) &&
2336
(relationshipState !=
EntityState
.Deleted && relationshipState !=
EntityState
.Detached))
2341
if ((sourceEntry.State ==
EntityState
.Added || targetEntry.State ==
EntityState
.Added) &&
2342
(relationshipState !=
EntityState
.Added && relationshipState !=
EntityState
.Detached))
2348
private RelationshipEntry CreateRelationship(EntityEntry targetEntry, RelatedEnd relatedEnd, RelationshipWrapper relationshipWrapper,
EntityState
requestedState)
2350
Debug.Assert(requestedState !=
EntityState
.Modified, "relationship cannot be in Modified state");
2356
case
EntityState
.Added:
2366
case
EntityState
.Unchanged:
2376
case
EntityState
.Deleted:
2377
relationshipEntry = this.AddNewRelation(relationshipWrapper,
EntityState
.Deleted);
2379
case
EntityState
.Detached:
2680
internal void ChangeState(RelationshipEntry entry,
EntityState
oldState,
EntityState
newState)
2682
if (newState ==
EntityState
.Detached)
2704
internal void ChangeState(EntityEntry entry,
EntityState
oldState,
EntityState
newState)
2707
if (newState ==
EntityState
.Detached)
2716
ChangeState(relationshipEntry, relationshipEntry.State,
EntityState
.Detached);
2741
if (newState ==
EntityState
.Deleted)
2754
private void AddRelationshipEntryToDictionary(RelationshipEntry entry,
EntityState
state)
2762
case
EntityState
.Unchanged:
2769
case
EntityState
.Added:
2776
case
EntityState
.Deleted:
2791
private void AddEntityEntryToDictionary(EntityEntry entry,
EntityState
state)
2803
case
EntityState
.Unchanged:
2811
case
EntityState
.Added:
2819
case
EntityState
.Deleted:
2827
case
EntityState
.Modified:
2868
private void RemoveObjectStateEntryFromDictionary(RelationshipEntry entry,
EntityState
state)
2874
case
EntityState
.Unchanged:
2877
case
EntityState
.Added:
2880
case
EntityState
.Deleted:
2896
case
EntityState
.Unchanged:
2899
case
EntityState
.Added:
2902
case
EntityState
.Deleted:
2913
private void RemoveObjectStateEntryFromDictionary(EntityEntry entry,
EntityState
state)
2918
case
EntityState
.Unchanged:
2921
case
EntityState
.Added:
2924
case
EntityState
.Deleted:
2927
case
EntityState
.Modified:
2944
case
EntityState
.Unchanged:
2947
case
EntityState
.Added:
2950
case
EntityState
.Deleted:
2953
case
EntityState
.Modified:
3130
if (entry.State ==
EntityState
.Deleted)
3142
if (entry.State ==
EntityState
.Unchanged || entry.State ==
EntityState
.Modified)
3176
if (pair.Key.IsForeignKey && (entry.State ==
EntityState
.Unchanged || entry.State ==
EntityState
.Modified))
3258
(relatedEntry.State ==
EntityState
.Unchanged ||
3259
relatedEntry.State ==
EntityState
.Modified))
3321
if (entry.State ==
EntityState
.Added || entry.State ==
EntityState
.Modified)
3340
if (entry.State !=
EntityState
.Detached &&
3384
if (relatedEntry.State !=
EntityState
.Deleted)
3465
if (entry.State !=
EntityState
.Detached &&
3466
entry.State !=
EntityState
.Deleted &&
3547
if (entry.State ==
EntityState
.Detached || entry.State ==
EntityState
.Deleted || entry.IsKeyEntry)
3584
if (entry.State ==
EntityState
.Detached || entry.State ==
EntityState
.Deleted || entry.IsKeyEntry)
3592
if (entry.State ==
EntityState
.Detached || entry.State ==
EntityState
.Deleted || entry.IsKeyEntry)
3705
if (entry.State !=
EntityState
.Added)
System\Data\Objects\RelationshipEntry.cs (60)
35
internal RelationshipEntry(ObjectStateManager cache,
EntityState
state, RelationshipWrapper relationshipWrapper)
39
Debug.Assert(
EntityState
.Added == state ||
40
EntityState
.Unchanged == state ||
41
EntityState
.Deleted == state,
71
case
EntityState
.Deleted:
76
_cache.ChangeState(this,
EntityState
.Deleted,
EntityState
.Detached);
79
case
EntityState
.Added:
80
_cache.ChangeState(this,
EntityState
.Added,
EntityState
.Unchanged);
81
State =
EntityState
.Unchanged;
83
case
EntityState
.Modified:
86
case
EntityState
.Unchanged:
179
if (this.State ==
EntityState
.Added)
204
if (this.State ==
EntityState
.Deleted)
221
public override void ChangeState(
EntityState
state)
225
if (this.State ==
EntityState
.Detached && state ==
EntityState
.Detached)
319
State =
EntityState
.Unchanged;
320
_cache.ChangeState(this,
EntityState
.Deleted, State);
397
if (State ==
EntityState
.Deleted && throwException)
500
if (State !=
EntityState
.Deleted) //for deleted ObjectStateEntry its a no-op
548
if (this.State ==
EntityState
.Added)
561
_cache.ChangeState(this, this.State,
EntityState
.Deleted);
562
State =
EntityState
.Deleted;
571
case
EntityState
.Added:
580
case
EntityState
.Modified:
583
case
EntityState
.Unchanged:
584
_cache.ChangeState(this,
EntityState
.Unchanged,
EntityState
.Deleted);
585
State =
EntityState
.Deleted;
602
_cache.ChangeState(this, this.State,
EntityState
.Detached);
606
internal void ChangeRelationshipState(EntityEntry targetEntry, RelatedEnd relatedEnd,
EntityState
requestedState)
608
Debug.Assert(requestedState !=
EntityState
.Modified, "Invalid requested state for relationsihp");
609
Debug.Assert(this.State !=
EntityState
.Modified, "Invalid initial state for relationsihp");
611
EntityState
initialState = this.State;
615
case
EntityState
.Added:
618
case
EntityState
.Added:
621
case
EntityState
.Unchanged:
624
case
EntityState
.Deleted:
629
case
EntityState
.Detached:
638
case
EntityState
.Unchanged:
641
case
EntityState
.Added:
642
this.ObjectStateManager.ChangeState(this,
EntityState
.Unchanged,
EntityState
.Added);
643
this.State =
EntityState
.Added;
645
case
EntityState
.Unchanged:
648
case
EntityState
.Deleted:
652
case
EntityState
.Detached:
662
case
EntityState
.Deleted:
665
case
EntityState
.Added:
672
this.ObjectStateManager.ChangeState(this,
EntityState
.Deleted,
EntityState
.Added);
673
this.State =
EntityState
.Added;
675
case
EntityState
.Unchanged:
682
this.ObjectStateManager.ChangeState(this,
EntityState
.Deleted,
EntityState
.Unchanged);
683
this.State =
EntityState
.Unchanged;
685
case
EntityState
.Deleted:
688
case
EntityState
.Detached:
System.Data.Services (8)
System\Data\Services\Providers\ObjectContextServiceProvider.cs (8)
443
if (objectStateEntry.State ==
EntityState
.Added)
555
if (objectStateEntry.State ==
EntityState
.Added)
601
foreach (ObjectStateEntry entry in this.ObjectContext.ObjectStateManager.GetObjectStateEntries(
EntityState
.Added |
EntityState
.Deleted |
EntityState
.Modified |
EntityState
.Unchanged))
612
if (entry.State !=
EntityState
.Detached && !entry.IsRelationship && entry.Entity != null)
2420
if (stateEntry.State !=
EntityState
.Added && !relatedEnd.IsLoaded)