Я довольно новичок в ServiceStack, и я стараюсь выяснить, как лучше всего работать с несколькими операциями получения по одному и тому же запросу. Ниже мой запрос объект:Работа с несколькими операциями получения
[Route("/Entity", Verbs = "GET", Notes = "Returns all the entities.")]
[Route("/Entity/{Id}", Verbs = "GET", Notes = "Returns a specific entity.")]
[Route("/Entity/{Id}/Child", Verbs = "GET", Notes = "Returns children of a specific entity.")]
public class EntityRequest {
public int Id { get; set; }
public int ChildId { get; set; }
}
И ниже моя служба:
public object Get(EntityRequest request) {
if (request.Id > 0) {
//returns a given entity
return _applicationService.getEntities(request.Id);
}
//How do I handle this? Check for the word "/Child" in the URL?
//returns children for a given entity
//return _applicationService.getChildren(request.Id);
//returns all the entities
return _applicationService.getEntities();
}
}
Как вы можете видеть, что я имею в обработку первых два маршрута "/ Entity" и "/ Entity/{Id}" со стороны обслуживания. Как лучше всего обработать маршрут «/ Entity/{Id]/Child»? В текущем состоянии третий URL-адрес возвращает все объекты. Любая помощь будет оценена?
Спасибо!