Skip to content

Cannot use Enumerable.Empty<T>() as default property value #42

@ike86

Description

@ike86

Problem
If I use Enumerable.Empty<T>() as a default value on properties (or fields) like IEnumerable<T> MyProp,
I get a System.Reflection.TargetException with message Object does not match target type.

Expected
MyProp should be overwritten by the mapped values.
or see #43

Code for repro
in ReadMeTests.cs

public class Customer
{
    public int CustomerId;
    public string FirstName;
    public string LastName;
    public IEnumerable<Order> Orders = Enumerable.Empty<Order>(); // note this
}

// ...

public void I_Can_Map_Nested_Types_And_Resolve_Duplicate_Entries_Properly_Using_Dynamics() // will fail

// ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions