I am having 2 Entity to Dto map methods with the same parameter which is not allowed for the same name.
Is the only problem to solve give ToDto a better name? Actually I like ToDto
and having some methods with ToDto or another ToEditSchoolyearDto seems inconsistent here.
Is there any other solution?
public static BrowseSchoolyearDTO ToDto(this Schoolyear schoolyear)
{
return new BrowseSchoolyearDTO
{
// mapping props
};
}
public static EditSchoolyearDTO ToDto(this Schoolyear schoolyear)
{
return new EditSchoolyearDTO
{
// mapping props
};
}
How would you expect the compiler to work out which one you meant? Yes, if you're trying to create different methods with the same parameters, you need to give them different names.
I would suggest ToBrowseDto
and ToEditDto
. Then it's clear which you mean.
See more on this question at Stackoverflow