gpt4 book ai didi

c# - Entity Framework 在工作量大的情况下抛出意外异常

转载 作者:太空宇宙 更新时间:2023-11-03 14:54:03 25 4
gpt4 key购买 nike

我们在IIS上有一个使用MSSQL2016、EntityFramework和WCF Services的运行项目。在正常情况下,一切都很好,但当工作量增加时,EntityFramework 会在 linq 查询上抛出异常异常:

... ToList -> .ctor -> MoveNext -> TryReadToNextElement -> MoveNext -> MaterializeRow -> HasNextElement -> lambda_method-> IsDBNull -> CheckHeaderIsReady

System.IndexOutOfRangeException: Index was outside the bounds of the array.

-

... FirstOrDefault -> MoveNext -> TryReadToNextElement -> MoveNext -> MaterializeRow -> HasNextElement -> lambda_method -> GetGuid -> get_SqlGuid

System.InvalidCastException: Specified cast is not valid.

-

... FirstOrDefault -> MoveNext -> ReadNextElement -> lambda_method -> GetValue

System.InvalidOperationException: The specified cast from a materialized 'System.Int32' type to the 'System.Guid' type is not valid.

****注意:数据库表的列和数据模型的属性具有相同的类型。这个错误与类型转换无关。**

最佳答案

问题可能出在您处理工作量的方式上吗?因为您正在尝试访问列表中不存在或尚不存在(延迟)的索引。我在这里找到了一些文章 WCF - IndexOutOfRange exception when instantiating ChannelFactory

关于c# - Entity Framework 在工作量大的情况下抛出意外异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50560257/

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