> For the complete documentation index, see [llms.txt](https://abi.gitbook.io/net-core/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://abi.gitbook.io/net-core/6.2-configurar-tus-servicios-con-odata.md).

# 7. Crear servicios con OData

Como se explico en el [capítulo 2](/net-core/3.-servicios-rest.md) en la explicación de [servicios REST](/net-core/3.-servicios-rest/3.1-servicios-rest.md) tus servicios pueden filtrar la información o seleccionar solamente algunos campos de una tabla se puede utilizar [OData ](https://www.odata.org)(Open Data Protocol).&#x20;

Las opciones disponibles son:

| Opción                    | Descripción                                                                                                                             |
| ------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
| $select=clave,nombre      | Seleccionar los campos de la tabla que deseas obtener en el servicio. En este ejemplo solo se seleccionan los campos de clave y nombre. |
| $orderby=clave desc       | Ordenar el resultado por el campo clave de forma descendente                                                                            |
| $filter=clave gt 10       | Permite filtrar los resultados. En este ejemplo se regresan los registros en el cual la clave sea mayor a 1                             |
| $skip=4                   | Permite omitir los primeros 4 registros, lo puedes combinar con $orderby                                                                |
| $top=10                   | Obtiene los primeros 10 registros                                                                                                       |
| $count=true               | Regresa también el total de registros                                                                                                   |
| productos$expand=clientes | Permite además de obtener los productos obtener los datos de los clientes.                                                              |

Puedes ver la documentación de OData con todas las opciones disponibles [aquí](http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part2-url-conventions.html).

Puedes consultar la documentación oficial de Microsoft [aquí](https://docs.microsoft.com/en-us/odata/webapi/first-odata-api).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://abi.gitbook.io/net-core/6.2-configurar-tus-servicios-con-odata.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
