So, here\'s my situation. I\'ve got a my two classes:
class FromClass
{
public string[] Foo { get; set; }
}
class ToClass
{
public string[] Foo { get; s
I would say: this is a bug: see Github Issue 159.
The AutoMapper.QueryableExtensions uses Mapper.CreateMapExpression
internally so if you write:
var expression = Mapper.CreateMapExpression();
It will also fail with the same exception.
It seems Mapper.CreateMapExpression
currently does not support:
List
etc.string[]
, Bar[]
etc.But if you make your Foo
to List
it can work:
public class FromClass
{
public List- Foo { get; set; }
}
public class ToClass
{
public List
- Foo { get; set; }
}
public class Item
{
public string Bar { get; set; }
}
var list = new List
- { new Item{ Bar = "a"}, new Item() { Bar= "b" }};
FromClass anObject = new FromClass() { Foo = list };
var queryableObjects = (new FromClass[] { anObject }).AsQueryable();
Mapper.CreateMap
();
Mapper.CreateMap- ();
var test2 = queryableObjects.Project().To
().ToArray();
You can comment on the above mentioned issue or create a new one with your code (it's a quite good repro of the bug)