entity tracking

  public async Task Update(Command command)
        {
            var p = await _repository.GetAsync(command.Id);
 
            foreach (var prop in command.GetType().GetProperties())
            {
                var value = prop.GetValue(command, null);
                var propertyInfo = p.GetType().GetProperty(prop.Name);
                if (propertyInfo != null)
                {
                    propertyInfo.SetValue(partner, value, null);
                }
            }
 
            _DbContext.ChangeTracker.DetectChanges();
            Console.WriteLine(_DbContext.ChangeTracker.DebugView.LongView);
 
            _DbContext.SaveChanges();
 
        }
<code>
Kategoria: