0

I use asp.net boilerplate for my back end

I created app service that inherits AsyncCrudAppService<GettingApproved, GettingApprovedDto, int, PagedGettingApprovedResultRequestDto, CreateGettingApprovedDto, GettingApprovedDto>

But my GettingApproved entity has foreign key to another entity. How I can Include this entity?

Or override GetAll() method?

Eugene Sukh
  • 2,357
  • 4
  • 42
  • 86

1 Answers1

1

Eugene,

You can override it like this:

If you are mot using the CreatedFilteredQuery method, you can override the GetAll like this,

    public override Task<PagedResultDto<GettingApprovedDto>> GetAllAsync(PagedGettingApprovedResultRequestDto input)
    {
        var lista = new List<GettingApproved>();
        var query = Repository.GetAllIncluding(x => x.YouEntity);

        query = ApplySorting(query, input);

        lista = query
            .Skip(input.SkipCount)
            .Take(input.MaxResultCount)
            .ToList();

        var result = new PagedResultDto<GettingApprovedDto>(query.Count(), ObjectMapper.Map<List<GettingApprovedDto>>(lista));
        return Task.FromResult(result);
    }

If you are using it you have to add the GetAllIncluding section too like this:

    protected override IQueryable<GettingApproved> CreateFilteredQuery(PagedGettingApprovedResultRequestDto input)
    {
        return Repository.GetAllIncluding(x => x.YourEntity);
    }
José Polanco
  • 574
  • 4
  • 19