What kind of data in an Application Service with 3 different tables?

Asked

Viewed 30 times

0

I have an Application Service in ASP.NET Core that will fetch the database data from a table "Employees" that are number, name, departmentname and cityname... the last two fields I mentioned are data from two other tables "Department" and "City". And the "Employees" table has two foreign keys to "Department" and "City".

I made a method

namespace access.track.Logicpulse {
public interface IEmployeesAppService : IApplicationService 
{
    ListResultDto<EmployeesListDto> GetEmployees(GetEmployeesInput input); }

that will fetch all Employees by departmentname.

public ListResultDto<EmployeesListDto> GetEmployees(GetEmployeesInput input)
    {
        var emp = _employeesRepository
        .GetAll()
        .WhereIf(
            !input.Filter.IsNullOrEmpty(),
            p => p.DepartmentFk.name.Contains(input.Filter)
        )
        .OrderBy(p => p.DepartmentFk.name)
        .ToList();

        return new ListResultDto<EmployeesListDto>(ObjectMapper.Map<List<EmployeesListDto>>(emp));
    }

Now what happens is that the departmentname and cityname fields see the "null" of the Web API when I call the method.

I have an idea it’s because of this... but I don’t know what to do with the departmentname and cityname fields... what kind of data to use? (You’re probably asking the wrong question...)

namespace access.track.Logicpulse.Dtos {
public class EmployeesListDto
{
    public int number { get; set; }

    public string name { get; set; }

    public string departmentname { get; set; }

    public string cityname { get; set; }
}}

1 answer

0

Browser other questions tagged

You are not signed in. Login or sign up in order to post.