I have this code:
public class InputMapper : BaseMapper<Input, InputDTO>
{
private Guid _CompanyId;
public InputMapper(Guid companyId)
{
_CompanyId=companyId;
}
public override Expression<Func<InputDTO, Input>> ToDomain()
{
return x=> new Input()
{
CompanyId => this._CompanyId, <--- HERE I GET AN ERROR
Id = x.Id,
Name = x.Name,
Deduction = x.Deduction
};
}
}
Why do I get error on the marked line:
Invalid initializer member declarator
?
Is there any workaround?
You’ve used a lambda expression, where I suspect you meant to just initialize a property:
should be
(Also note Brandon’s comment – the assignment in your constructor is the wrong way round.)