コード例 #1
0
        public static void Reload(this InternalEntityEntry internalEntry, DbContext context)
        {
            if (internalEntry.EntityState == EntityState.Detached)
            {
                throw new InvalidOperationException("Can't reload an unknown entity");
            }

            if (internalEntry.EntityState == EntityState.Added)
            {
                throw new InvalidOperationException("Can't reload an added entity");
            }

            var storeValues = internalEntry.GetDatabaseValues(context);

            if (storeValues == null)
            {
                internalEntry.SetEntityState(EntityState.Detached);
            }
            else
            {
                internalEntry.SetValues(storeValues);
                internalEntry.SetOriginalValues(storeValues);
                internalEntry.SetEntityState(EntityState.Unchanged);
            }
        }
コード例 #2
0
        public DbPropertyValues GetDatabaseValues()
        {
            var storeValues = _internalEntityEntry.GetDatabaseValues();

            return(storeValues == null ? null : new DbPropertyValues(storeValues));
        }