一个呼叫主体,ASP.NET MVC + angular 6中有多个响应 [英] One call main, multiple responses in ASP.NET MVC + angular 6
问题描述
首先,我不知道这是否可行!我正在努力寻找答案.我想我不知道要搜索什么!
First of all, I have no idea if this is possible! and I'm struggling to find an answer. I think I don't know what to search for!
我有一个返回IEnumerable
的端点,我想划分响应以便使用
I have an endpoint that returns IEnumerable
, I want to divide the response so I used
.Skip().Take()
现在,当我拿到第一张照片时,如何在不调用相同端点的情况下拿到第二张照片!
Now when I get the first take, how can I get the second one without invoking the same endpoint!
问题是IEnumerable
从不可能进行除法的另一个服务获取数据,因此我必须一次获取所有内容,然后必须调用另一个"SLOW"端点,该端点同时给我5个结果使用我从IEnumerable
获得的内容.
The problem is IEnumerable
gets the data from another service where it is not possible to divide, so I have to get everything at once and then I have to call another "SLOW" endpoint that gives me 5 results at the time using what I got from the IEnumerable
.
所以我要做的是,划分第一个列表,进行第二个调用,将结果放在一起,返回结果并重复直到列表完成.
So what I want to do is, divide the first list, do the second call, put the result together, return this and repeat until the list is completed.
有没有一种方法可以让用户保持倾听的态度,并在到达时追加它们?
Is there a way to keep angular listening for responses and append them as they arrive?
或者我可以在得到结果后又打另一个电话,但又不需要再次请求完整列表吗? 将它保存在某个地方!".
Or can I make another call after I get the result but without requesting the complete list again ? "save it somewhere!".
推荐答案
对我要实现的目标的简单答案是不可能!.更改必须在更深层次上进行(查询数据库).
The simple answer to what I was trying to achieve is NO it is not possible. The change has to be done on a deeper level (querying the DB).
使用静态方法,但是这是一个Web应用程序,因此会出现问题,因此再次出现问题.
Using static works but then this is a web application so that would be problematic so again its a NO.
我最终得到了整个列表,然后一个一个地循环遍历,以获得慢速数据,然后将其显示给用户.
I ended up getting the whole list, then looping through it one by one to get the slow data then show it to the user.
这篇关于一个呼叫主体,ASP.NET MVC + angular 6中有多个响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!