Kontroler Api deklarujący więcej niż jedną instrukcję Get
Korzystając z nowego kontrolera Api w MVC4, znalazłem problem. Jeśli mam następujące metody:
public IEnumberable<string> GetAll()
public IEnumberable<string> GetSpecific(int i)
To zadziała. Jeśli jednak chcę pobrać różne dane innego typu, domyślnie jest toGetAll
metoda, mimo że$.getJSON
jest ustawiony naGetAllIntegers
metoda:
public IEnumberable<int> GetAllIntergers()
(złe konwencje nazewnictwa)
Czy mogę to zrobić?
Czy mogę mieć tylko jeden singielGetAll
metoda w kontrolerze Web API?
Myślę, że łatwiej jest wyobrazić sobie to, co próbuję osiągnąć. Oto fragment kodu pokazujący, co chciałbym zrobić w jednymApiController
:
<code>public IEnumerable<string> GetClients() { // Get data } public IEnumerable<string> GetClient(int id) { // Get data } public IEnumerable<string> GetStaffMember(int id) { // Get data } public IEnumerable<string> GetStaffMembers() { // Get data } </code>