From 89f0ea742f1f46dce0914ebf865b69a888c0692b Mon Sep 17 00:00:00 2001 From: hello Date: Tue, 9 Apr 2024 07:58:42 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E9=A1=B5=E5=AE=9E=E7=8E=B0=E5=92=8C?= =?UTF-8?q?=E5=A4=9A=E6=9D=A1=E4=BB=B6=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- notes/helloshop/{pagging.md => paging.md} | 28 +++++++++++++++++++++++ 1 file changed, 28 insertions(+) rename notes/helloshop/{pagging.md => paging.md} (74%) diff --git a/notes/helloshop/pagging.md b/notes/helloshop/paging.md similarity index 74% rename from notes/helloshop/pagging.md rename to notes/helloshop/paging.md index c3ce78f..4b6aa88 100644 --- a/notes/helloshop/pagging.md +++ b/notes/helloshop/paging.md @@ -103,3 +103,31 @@ public async Task>> GetUsers([FromQuery return new PagedResponse(mapper.Map>(await pagedUsers.ToListAsync()), await users.CountAsync()); } ``` + +## 实现灵活的复杂查询 + +可以使用 OData 或者 GraphQL 来实现更复杂的查询。 + +OData 是一种基于 REST 的协议,它使用 URL 来查询和操作数据。OData 通过 URL 查询字符串参数来过滤、排序、分页和选择数据。示例: + +```shell +http://localhost:8080/api/products?$filter=price gt 100&$orderby=price desc&$top=5&$skip=10 +``` + +关于 OData 的更多信息请参考 [零度 OData 课程](https://www.xcode.me/Training?keyword=odata) + +GraphQL 是一种用于 API 的查询语言,它提供了一种更高效、强大和灵活的替代方案。GraphQL 通过一个单一的端点来查询和操作数据。示例: + +```shell +http://localhost:8080/graphql +``` + +```graphql +query { + products(filter: {price: {gt: 100}}, orderBy: {price: desc}, top: 5, skip: 10) { + id + name + price + } +} +``` \ No newline at end of file