EF核心因空响应而超时 [英] EF Core Timing out on null response
问题描述
我的表格中有2个货币列。它们在我的模型中为:
I have 2 currency columns in my table. They are in my model as:
public decimal MSRP { get; set; }
public decimal Invoice { get; set; }
我发现当我对这些列进行注释时,一切正常。然后,我查看了它们与其他货币列的不同之处。我注意到它们是唯一实际具有NULL值的货币列。其他货币列允许使用NULL,但没有任何NULL列。
I've found that when I comment those columns out everything works fine. I then went through to see what was different about them as opposed to other currency columns. I noticed that they are the only currency columns that actually have NULL values. Other currency columns allow NULL, but do not have any NULL columns.
然后我将其更改为字符串,并且一切正常。
I then changed them to strings and everything loaded fine.
以下是输出调试错误:
Microsoft.EntityFrameworkCore.Query.Internal.SqlServerQueryCompilationContextFactory:Error:发生了异常
Microsoft.EntityFrameworkCore.Query.Internal.SqlServerQueryCompilationContextFactory:Error: An exception occurred in the database while iterating the results of a query.
如何构建模型,以便将其读取为小数,但仍然允许空值?还是不可能?
How do I build the model so that it reads it as a decimal but still allows nulls? Or is it not possible?
推荐答案
使用:
public decimal? MSRP { get; set; }
public decimal? Invoice { get; set; }
这篇关于EF核心因空响应而超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!