示例#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.Entity.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)System.Data.Entity.EntityState.Modified || entityInfo.ForceUpdate)
            {
                // _originalValusMap can be null if we mark entity.SetModified but don't actually change anything.
                entry.ChangeState(System.Data.Entity.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));
 }