JZTXT
  • 首页
  • Ai
  • Java
  • Python
  • Android
  • Mysql
  • JavaScript
  • Html
  • CSS

net-core Action返回IAsyncEnumerable的案例

发布时间 2023-05-30 10:19:43作者: 斯蒂芬斯
[HttpGet("asyncsale")]
public async IAsyncEnumerable<Product> GetOnSaleProductsAsync()
{
    var products = _repository.GetProductsAsync();

    await foreach (var product in products)
    {
        if (product.IsOnSale)
        {
            yield return product;
        }
    }
}

 

    本栏目推荐文章
  • .Net Core 系列: 集成 CORS跨域配置
  • .Net Core 系列: 集成 Consul 实现 服务注册与健康检查
  • 聊一聊如何结合Microsoft.Extensions.DependenyInjection和Castle.Core
  • 聊一聊如何整合Microsoft.Extensions.DependencyInjection和Castle.Core(二)
  • 聊一聊如何整合Microsoft.Extensions.DependencyInjection和Castle.Core(三)
  • 聊一聊如何整合Microsoft.Extensions.DependencyInjection和Castle.Core(完结篇)
  • 4- if 流程语句和案例
  • 案例分享:游戏行业各岗位的KPI绩效指标制定
  • 聊一聊如何整合Microsoft.Extensions.DependencyInjection和Castle.Core(完结篇)
  • [转][C#][.net Core]
版权声明:本网站为非赢利性站点,本网站所有内容均来源于互联网相关站点自动搜索采集信息,相关链接已经注明来源。
联系我们