当我运行以下代码时,最后一行
repository.Context.LoadProperty(userPatient.Patient.Practice, "Enterprise")抛出异常
上下文当前没有跟踪该实体。
如何加载导航属性Enterprise?我不知道我错过了什么。请帮帮忙。
public class QuickLaunch
{
private UserPatient userPatient = null;
private PortalRepository repository = null;
public QuickLaunch(PortalRepository repository)
{
this.repository = repository;
userPatient = MySession.Current.SelectedPatient;
repository.Context.LoadProperty(userPatient.Patient.Practice, "Enterprise");
}
}发布于 2018-01-17 14:42:24
嗯,我对这个问题有一个替代的解决办法。我可以将这个特定的上下文添加到会话变量中。然后,当我需要使用该上下文加载导航属性时,我总是可以使用我在会话中保存的上下文。我试过了而且成功了。但我不确定这是否正确或最好的做法。
https://stackoverflow.com/questions/48289871
复制相似问题