riskfirst.hateoas icon indicating copy to clipboard operation
riskfirst.hateoas copied to clipboard

How to add links to collection of <Model>

Open Khaos66 opened this issue 4 years ago • 0 comments

In the README.MD is this example

    [HttpGet(Name="GetAllModelsRoute")]
    public async Task<IEnumerable<MyModel>> GetAllModels()
    {
         //... snip .. //
    }

But how would you implement the AddLinksAsync part?

As far as I can see ILinksService doesn't accept an IEnumerable<MyModel> as parameter for AddLinksAsync...

Something like this would be nice:

    [HttpGet(Name="GetAllModelsRoute")]
    public async Task<IEnumerable<MyModel>> GetAllModels()
    {
         var all = await _dbContext.Models.ToListAsync();
         await linksService.AddLinksAsync(all);
         return all;
    }

Khaos66 avatar Aug 13 '21 05:08 Khaos66