Exemplo n.º 1
0
        private EntityEntry AddEntityEntry(EFEntityInfo entityInfo)
        {
            var ose = GetEntityEntry(entityInfo.Entity, false);

            if (ose != null)
            {
                return(ose);
            }
            Context.Add(entityInfo.Entity);
            // Attach has lots of side effect - add has far fewer.
            return(GetEntityEntry(entityInfo));
        }
Exemplo n.º 2
0
        private EntityEntry HandleModified(EFEntityInfo entityInfo)
        {
            var entry = AddEntityEntry(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.State = Microsoft.EntityFrameworkCore.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 (entry.State != Microsoft.EntityFrameworkCore.EntityState.Modified || entityInfo.ForceUpdate)
            {
                // _originalValusMap can be null if we mark entity.SetModified but don't actually change anything.
                entry.State = Microsoft.EntityFrameworkCore.EntityState.Modified;
            }
            return(entry);
        }
Exemplo n.º 3
0
 private EntityEntry GetEntityEntry(EFEntityInfo entityInfo)
 {
     return(GetEntityEntry(entityInfo.Entity));
 }
Exemplo n.º 4
0
 private EntityEntry AttachEntityEntry(EFEntityInfo entityInfo)
 {
     Context.Attach(entityInfo.Entity);
     // Attach has lots of side effect - add has far fewer.
     return(GetEntityEntry(entityInfo));
 }