public static AccountDto ToAccountDto(this User entity) { if (entity == null) { return(null); } AccountDto dto = new AccountDto(); dto.CopyPropertiesFrom(entity); dto.UserName = entity.Accounts.FirstOrDefault().UserName; dto.Id = entity.Accounts.FirstOrDefault().Id; dto.UserId = entity.Id; return(dto); }