简体   繁体   中英

Include into GetAll method (ASP.NET Boilerplate)

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,

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);
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM