Пример #1
0
        private ObjectStateEntry AddObjectStateEntry(EFEntityInfo entityInfo)
        {
            var ose = GetObjectStateEntry(entityInfo.Entity, false);

            if (ose != null)
            {
                return(ose);
            }
            ObjectContext.AddObject(entityInfo.EntitySetName, entityInfo.Entity);
            // Attach has lots of side effect - add has far fewer.
            return(GetObjectStateEntry(entityInfo));
        }
Пример #2
0
        private ObjectStateEntry HandleModified(EFEntityInfo entityInfo)
        {
            var entry = AddObjectStateEntry(entityInfo);

            // EntityState will be changed to modified during the update from the OriginalValuesMap
            // Do NOT change this to EntityState.Modified because this will cause the entire record to update.

            entry.ChangeState(System.Data.EntityState.Unchanged);

            // updating the original values is necessary under certain conditions when we change a foreign key field
            // because the before value is used to determine ordering.
            UpdateOriginalValues(entry, entityInfo);

            //foreach (var dep in GetModifiedComplexTypeProperties(entity, metadata)) {
            //  entry.SetModifiedProperty(dep.Name);
            //}

            if ((int)entry.State != (int)EntityState.Modified || entityInfo.ForceUpdate)
            {
                // _originalValusMap can be null if we mark entity.SetModified but don't actually change anything.
                entry.ChangeState(System.Data.EntityState.Modified);
            }
            return(entry);
        }
Пример #3
0
 private ObjectStateEntry GetObjectStateEntry(EFEntityInfo entityInfo)
 {
     return(GetObjectStateEntry(entityInfo.Entity));
 }
Пример #4
0
 private ObjectStateEntry AttachObjectStateEntry(EFEntityInfo entityInfo)
 {
     ObjectContext.AttachTo(entityInfo.EntitySetName, entityInfo.Entity);
     // Attach has lots of side effect - add has far fewer.
     return(GetObjectStateEntry(entityInfo));
 }