# 分页和排序

## Limit

`Limit` 将限制查询结果的实体数量为 `n`.

```go
users, err := client.User.
    Query().
    Limit(n).
    All(ctx)
```

## Offset

`Offset` 设置查询结果第一个顶点的位置。

```go
users, err := client.User.
    Query().
    Offset(10).
    All(ctx)
```

## Ordering

`Order` 返回按照一个或多个字段的值排序的结果。

```go
users, err := client.User.Query().
    Order(ent.Asc(user.FieldName)).
    All(ctx)
```


---

# Agent Instructions: 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:

```
GET https://3ks.gitbook.io/ent-zh_cn/dai-ma-sheng-cheng/paging.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
