0

I have 3 classes inherited from an abstract base class:

abstract class PortTaskStep{
    public Guid TaskID { get; set; }
    [ForeignKey("TaskID")]
    public virtual PortChangeTask PortChangeTask { get; set; }
    public virtual String CompleteStep() { return string.Empty;}
}
class PortTaskStep_Add:TaskStep{}
class PortTaskStep_Modify:TaskStep{}
class PortTaskStep_Delete:TaskStep{}

public class HncNetScanContext : DbContext
{
    public DbSet<PortTaskStep> PortTaskSteps { get; set; }
}

When I try to get data from table 'PortTaskSteps', the query returns :

cannot calculate the value of the expression

Some more details:

public class PortChangeTask{
   public ICollection<PortTaskStep> PortTaskSteps { get; set; }
   public Boolean CompleteTask(){
     foreach (var portTaskStep in PortTaskSteps)
     {
       portTaskStep.CompleteStep();
     }
   }
}

The Domain assembly contains the classes mentioned above are referenced by a web project and a web site. And when I debug the function in the web site, everything goes well.However, when I debug the same function in the web project, the results is null.

The Snapshot

For another scene tested in the Web Project: As shown in the Snapshot, I try to get "PortTaskSteps". And the result is null. However, after I uncomment the "textQuery", the result is a list of PortTaskStep.

The Snapshot

I think something is going wrong in webconfig or environment of the Web Project, however, I cannot figure out the point...:(

How can I resolve the problem?

Thanks!

4

1 回答 1

0

也许正确的翻译可能是“无法评估表达式”。如果是这样,那么很可能是 Visual Studio 的问题。尝试从解决方案中删除所有断点并重新插入它们。如果这对您没有帮助,请查看此链接:Visual Studio 2013 'Could not evaluate Expression' Debugger Abnormality

如果您的问题总是出现在检索数据和尝试在调试模式下查看数据时,那么您可能需要检查您的配置(可能您错过了映射或此表的重要内容)。

于 2016-07-13T10:43:38.130 回答