Description
When using UpdateDefinitionBuilder to update a document property of any enumerable parsing in an object, the serializer will change the property from type array to type object adding _t and _v.
Adding these unit tests to UpdateDefinitionBuilderTests will expose the problem:
[Fact] // This test succeeds |
public void Set_Untyped_String() |
{
|
var subject = CreateSubject<Person>(); |
var firstName = "Linus"; |
|
|
Assert(subject.Set(x => x.FirstName, firstName), "{$set: {fn: 'Linus'}}"); |
|
|
var subject2 = CreateSubject<Person>(); |
object firstName2 = "Julius"; |
|
|
Assert(subject2.Set(x => x.FirstName, firstName2), "{$set: {fn: 'Julius'}}"); |
}
|
|
|
[Fact] // This test fails on the second assert |
public void Set_Untyped_List() |
{
|
var subject = CreateSubject<Person>(); |
|
|
var pets = new List<Pet> { new Pet { Name = "Tiger" } }; |
Assert(subject.Set(x => x.Pets, pets), "{$set: { 'pets' : [{ 'name' : 'Tiger' }] }}"); |
|
|
var subject2 = CreateSubject<Person>(); |
|
|
object pets2 = new List<Pet> {new Pet {Name = "Tiger"}}; |
Assert(subject2.Set(x => x.Pets, pets2), "{$set: { 'pets' : [{ 'name' : 'Tiger' }] }}"); |
}
|
I have also attached a small .net program that simulates what I am doing in order to get this error.