I am trying to replicate an issue we are seeing in our application where basically a doing a load or query returns an object with a duplication of the items in a list when it wasn't persisted that way.
Here is a simple test that demonstrates one of the ways where I can demonstrate this:
public class Foo
{
public Foo()
{
Id = Guid.NewGuid().ToString();
Bars = new List<Bar> { new Bar { Name = "Bar1" }, new Bar { Name = "Bar2" } };
}
public string Id { get; set; }
public string Name { get; set; }
public List<Bar> Bars { get; set; }
}
public class Bar
{
public Bar()
{
Id = Guid.NewGuid().ToString();
}
public string Id { get; set; }
public string Name { get; set; }
}
public class MysteriousDupes
{
[Fact]
private void WTF()
{
var ds = new EmbeddableDocumentStore { RunInMemory = true };
ds.Initialize();
string id;
var originalFoo = new Foo {Name = "Original Foo"};
Foo loadedFoo = null;
//store original
using (var rs = ds.OpenSession())
{
id = originalFoo.Id;
rs.Store(originalFoo);
rs.SaveChanges();
}
//load original
using (var rs = ds.OpenSession())
{
loadedFoo = rs.Load<Foo>(id);
}
//should have the same number of bars as when we stored it
Assert.Equal(loadedFoo.Bars.Count, originalFoo.Bars.Count);
}
}
Now we don't populate lists in constructors so this isn't exactly my issue but it is very similar and is easy to demonstrate in a test.
Lastly, this is the latest production 3.51
--
W