EntityChange
EntityChange copied to clipboard
Ignore does not appear to work
Given a model
public class Car
{
public Car()
{
Bag = new Dictionary<string, object>();
}
public IDictionary<string, object> Bag { get; }
}
I want to ignore all changes in the Bag. I expected this to work
[Fact]
public void Ignore_ShouldIgnoreCollections()
{
var original = new Car();
var current = new Car();
current.Bag["foo"] = "bar";
var configuration = new Configuration();
configuration.Configure(config => config
.Entity<Car>(e =>
{
e.Property(p => p.Bag).Ignore();
//e.Collection(p => p.Bag).Ignore();
}));
var comparer = new EntityComparer(configuration);
var changes = comparer.Compare(original, current);
changes.Count.Should().Be(0);
}
But I get 1 diff. The commented out Ignore() does not help either.
I believe the error may be in EntityComparer.CompareObject. Changing the loop as below fixes the issue, but I don't know if there are other ramifications.
foreach (var memberMapping in classMapping.Members)
{
if (memberMapping.Ignored)
continue;