gpt4 book ai didi

c# - 如何从 Azure 移动服务获取请求返回所有行?

转载 作者:行者123 更新时间:2023-12-03 05:08:00 26 4
gpt4 key购买 nike

所以我有一个 Azure 移动 Web 服务,它从我的数据库返回行。

但目前它不会返回所有行,并且似乎受到限制。

来自this page我读了引文:

Paging considerations for a .NET backend mobile service

To override the 50 row limit in a .NET backend mobile service, you must also apply the EnableQueryAttribute to the public GET method and specify the paging behavior. When applied to the method, the following sets the maximum returned rows to 1000:

[EnableQuery(MaxTop=1000)]

这很好,返回 1000 而不是默认的 50。

有没有办法使用 EnableQueryAttribute 返回所有行而不是一组数字?

最佳答案

如果您将该属性中的属性设置为 int.MaxValue(即 [EnableQuery(MaxTop = int.MaxValue)]`,那么您将获得您想要的行为。

另一种方法是不返回应用 MaxTop 行为的 IQueryable,而是返回 IList (但是您将会失去其他 IQueryable 功能,例如过滤):

    public IList<TodoItem> GetAllTodoItems()
{
return Query().ToList();
}

请注意,您应该了解返回大量项目对内存的影响。我不确定,但整个响应在返回到客户端之前可能会被缓冲(您应该测试一下),如果您返回大量元素,则可能会在服务器中遇到性能问题。

关于c# - 如何从 Azure 移动服务获取请求返回所有行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35039743/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com