Załóżmy, że chciałbym zaktualizować dane w tabeli account
. Które podejście jest bardziej właściwe?
SELECT
encji + UPDATE
całej encji
public class AccountService : IAccountService
{
private readonly IAccountRepository accountRepository;
private readonly IAccountValidationService accountValidationService;
public AccountService(IAccountRepository accountRepository, IAccountValidationService accountValidationService)
{
this.accountRepository = accountRepository;
this.accountValidationService = accountValidationService;
}
public void SetName(int id, string name)
{
accountValidationService.ValidateName(name);
var entity = accountRepository.GetById(id);
entity.name = name;
accountRepository.Update(entity);
}
}
samo UPDATE
1 kolumny
public class AccountService : IAccountService
{
private readonly IAccountRepository accountRepository;
private readonly IAccountValidationService accountValidationService;
public AccountService(IAccountRepository accountRepository, IAccountValidationService accountValidationService)
{
this.accountRepository = accountRepository;
this.accountValidationService = accountValidationService;
}
public void SetName(int id, string name)
{
accountValidationService.ValidateName(name);
accountRepository.UpdateName(id, name);
}
}