You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I get the following error using Automapper 5.0.2 on .NET Core RTM (netcoreapp1.0 only)
TryExpression is not supported as a child expression when accessing a member on type 'System.Guid' >because it is a value type. Construct the tree so the TryExpression is not nested inside of this expression.
I had no problem with previous 4.2.1 version
The text was updated successfully, but these errors were encountered:
alecrt
changed the title
Automapper 5.0.2 error
Automapper 5.0.2: System.Guid and TryExpression
Jul 8, 2016
I get the same error when trying to map an object like this:
public class MyObject
{
public Guid Id { get; set; }
public string Name { get; set; }
public override string ToString() => Name;
}
to a System.Web.Mvc.SelectListItem.
Mapping:
CreateMap<MyObject, SelectListItem>()
.ForMember(d => d.Text, o => o.MapFrom(s => s.Name))
.ForMember(d => d.Value, o => o.MapFrom(s => s.Id))
.ForMember(d => d.Group, o => o.Ignore())
.ForMember(d => d.Disabled, o => o.Ignore())
.ForMember(d => d.Selected, o => o.Ignore());
Note that changing the third line of the mapping to o.MapFrom(s => s.Id.ToString())) (i.e., explicitly mapping as a string) fixed the error for me.
So is it correct to say that AutoMapper <= 4.x automatically converted to a string, whereas you must be explicit about your mappings in AutoMapper >= 5.x?
I get the following error using Automapper 5.0.2 on .NET Core RTM (netcoreapp1.0 only)
I had no problem with previous 4.2.1 version
The text was updated successfully, but these errors were encountered: