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!

李陈峰
  • 1
  • 1

1 Answers1

0

Perhaps the right translation might be "Could not evaluate expression". If so, then most likely it's the problem with Visual Studio. Try to delete all your breakpoints from solution and reinsert them. If that doesn't help you, check this link: Visual Studio 2013 'Could not evaluate Expression' Debugger Abnormality.

If the problem for you appears always on both retrieving data and trying to see it in the debug mode then you might want to check your configuration (maybe you've missed mapping or something important for this table).

Ivan Yurchenko
  • 3,762
  • 1
  • 21
  • 35
  • Thanks, I've tried what you suggested. The problem is still there. And I've updated my question. Thanks again! – 李陈峰 Jul 14 '16 at 03:49