繁体   English   中英

Linq 查询无法在 AWS 中使用 .Net Core 和 EF Core

[英]Linq query not working in AWS with .Net Core and EF Core

我正在使用 EF Core 开发 .NET Core 3.1 Web API,并且此 API 已部署到 AWS Lambda。 下面的代码面临的问题是,它一直执行到控制台日志。 然后在 api 返回以下带有状态代码的消息之后

504网关超时:

"message": "端点请求超时"

CoreContext扩展了DbContext

public async Task<IList<ChannelsEnvelope>> GetChannels()
{
        using (var scope = _services.CreateScope())
        {
            Console.WriteLine("inside scope123");  // works till here.
            var _coreContext = scope.ServiceProvider.GetRequiredService<CoreContext>();

            var query = from a in _coreContext.DistributionChannels
                        where a.Active == true
                        orderby a.Channel ascending
                        select new ChannelsEnvelope
                        {
                            ID = a.Id,
                            Channel = a.Channel,
                            Description = a.Description
                        };

            return await query.AsNoTracking().ToListAsync();
        }
}

执行登录aws: 在此处输入图片说明

GetRequiredService方法是 .Net Platform Extensions 的一部分。 有关详细信息,请参阅Microsoft Docs

一方面,.Net Plateform Extensions 存在某些限制,另一方面 AWS Lambda 在 Linux 平台上运行并使用自定义运行时,该运行时可能不支持 .Net Core 运行时的所有功能。

请浏览上面的链接并确认 AWS Lambda 是否支持您的代码中使用的 API。

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM