-
Notifications
You must be signed in to change notification settings - Fork 54
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Steps to reproduce:
class Program
{
static void Main(string[] args)
{
var config = new MapperConfiguration
(
cfg =>
{
cfg.AddExpressionMapping();
cfg.CreateMap<User, UserModel>()
.ForMember(d => d.Id, opt => opt.MapFrom(s => s.UserId))
.ForMember(d => d.FullName, opt => opt.MapFrom(s => string.Concat(s.FirstName, " ", s.LastName)))
.ForMember(d => d.AgeInYears, opt => opt.MapFrom(s => s.Age));
}
);
var mapper = new Mapper(config);
Expression<Func<IQueryable<UserModel>, IQueryable<UserModel>>> exp = q => q.OrderBy(s => s.Id).ThenBy(s => s.FullName).GroupBy(s => s.AgeInYears).SelectMany(grp => grp);
Expression<Func<IQueryable<User>, IQueryable<User>>> expMapped = mapper.Map<Expression<Func<IQueryable<User>, IQueryable<User>>>>(exp);
}
}
public class User
{
public int UserId { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public int Age { get; set; }
public bool Active { get; set; }
}
public class UserModel
{
public int Id { get; set; }
public string FullName { get; set; }
public string AccountName { get; set; }
public int AgeInYears { get; set; }
public bool IsActive { get; set; }
}Error:
AutoMapper.AutoMapperMappingException
HResult=0x80131500
Message=Error mapping types.
Source=<Cannot evaluate the exception source>
StackTrace:
<Cannot evaluate the exception stack trace>
Inner Exception 1:
InvalidOperationException: No generic method 'SelectMany' on type 'System.Linq.Queryable' is compatible with the supplied type arguments and arguments. No type arguments should be provided if the method is non-generic.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working