I feel stupid. Can you guys help me to replace GetCamp(x) with anonymous?
This code:
aspnet_Users.ForEach(x =>
{
usersVm.Add(new User{
Camp = Mapper.Map<DbCamp, Camp>(GetCamp(x)),
});
});
private DbCamp GetCamp(aspnet_Users x)
{
//... some code ...
return someDbCamp;
}
Should be something like this:
aspnet_Users.ForEach(x =>
{
usersVm.Add(new User{
Camp = Mapper.Map<DbCamp, Camp>
(
Func<DbCamp>(aspnet_Users u) =>
{
//... some code ...
return someDbCamp;
}
),
});
});
That doesn't work because Mapper.Map<Database.Camp, Camp>
expects an object typeof(DbCamp)
as a parameter, not a delegate. I can use a normal function of course but from academical standpoint, I wonder if it's possible to use anonymous method here.