I am not using any ORM. So I am having a debate whether "Save" method actually belongs to a Business Domain entity or should be abstracted in some service that will be handed over the Business Domain Entity for saving ?
e.g.
class Employee
{
string Name;
DateTime Birth;
GetAge()
{
}
Save()
{
}
}
OR
class Employee
{
string Name;
DateTime Birth;
GetAge()
{
}
}
SomePersistenceService
{
Save(Employee emp)
{
}
}
Since this question is tagged with 'domain-driven-design', you'll need a repository to do it for you.
Just rename SomePersistenceService to EmployeeRepository. So you were on the right track with your second option. "abstracted in some service that will be handed over the Business Domain Entity" is called repository in domain driven design
A repository is a way to pretend that your datastore is a collection. So it has methods like Add
and Remove
instead of Save
and Delete
.