简体   繁体   English

Azure 移动应用程序 - 使用表 Controller 中的自定义代码覆盖 QueryAsync 方法

[英]Azure Mobile Apps - Overriding the QueryAsync method with custom code in Table Controller

I would like to override the Query Async Method with some Custom code, so I can access an external api, get some data and then use this data to query the db tables to get the results, this should support all the default sync and paging features provided by the base method.我想用一些自定义代码覆盖查询异步方法,这样我就可以访问外部 api,获取一些数据,然后使用这些数据查询数据库表以获得结果,这应该支持所有默认的同步和分页功能由基本方法提供。 I'm using the latest 5.0 DataSync library.我正在使用最新的 5.0 DataSync 库。 Old versions returned a IQueryable so this was easy to do, but now it returns an action result.旧版本返回一个 IQueryable,所以这很容易做到,但现在它返回一个操作结果。 Is there any solution?有什么解决办法吗? Could not find any docs.找不到任何文档。

eg I get a set of guids from api. I query the db tables with these guids and get all the matching rows and return back to client.例如,我从 api 获得了一组 guid。我使用这些 guid 查询数据库表并获取所有匹配的行并返回给客户端。

I know how to override the method, call external api's, get data and query the db tables, but this provides me with a custom data format not the one that the query async gives by default with paging support.我知道如何覆盖该方法、调用外部 api、获取数据和查询数据库表,但这为我提供了一种自定义数据格式,而不是查询异步默认提供的具有分页支持的格式。

The way to accomplish this is to create a new repository, swapping out the various CRUD elements with your own implementation.实现这一点的方法是创建一个新的存储库,用您自己的实现替换各种 CRUD 元素。 You can use the EntityTableRepository as an example.您可以使用 EntityTableRepository 作为示例。 You will note that the "list" operation just returns an IQueryable, so you can do what you need to do and then return the updated IQueryable.你会注意到“列表”操作只返回一个 IQueryable,所以你可以做你需要做的,然后返回更新后的 IQueryable。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 调用invokeApi时azure-mobile-apps出现401错误 - azure-mobile-apps getting 401 error when calling invokeApi 如何在asp net core中将自定义授权过滤器添加到方法不是controller? - How to add custom authorization filter to method not controller in asp net core? Web API controller 自定义名称触发错误 - Web API controller with custom name trigger error 如何像 Azure 函数一样通过 Azure 存储队列触发控制器操作? - How to trigger controller action by Azure storage queue like in Azure functions? 如何在控制器中为以下方法编写测试用例 - How to write test case for below method in controller 控制器中的相同方法接受 GET 和 POST - Same method in controller accept GET and POST 如何从 controller 方法访问 Token 数据? - How to access Token data from controller method? 如何在 controller 动作上使用多态性一种方法 - How to use polymorphism one method on controller actions .NET Controller Class 运行 GET 的第一个方法 - .NET Controller Class runs first method for GET Azure AD将多个应用程序连接到单个Web API - Azure AD connect multiple apps to single Web API
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM