[英]How to wait until a process finishes in EntityFramework?
I'm working with EntityFramework
and Silverlight, and I'm dealing with this situation. 我正在使用
EntityFramework
和Silverlight,并且正在处理这种情况。 When I try to load the data from a EntitySet
, I have to get the data from a callback. 当我尝试从
EntitySet
加载数据时,我必须从回调中获取数据。
Now, I need to get the data inmediately, I mean wait until the process finished. 现在,我需要立即获取数据,我的意思是等到过程完成。
In the next code, the part which I'd like to wait the process is Objectives
property. 在下一个代码中,我要等待该过程的部分是
Objectives
属性。 Or I don't know if I can convert the callback method into a IAsyncResult
, or something like that. 或者我不知道是否可以将回调方法转换为
IAsyncResult
或类似的东西。
public class EntityService : IEntityService
{
public EntityService()
{
_entities = new DatabaseDomainContext();
}
private DatabaseDomainContext _entities;
public DatabaseDomainContext Entities
{
get { return _entities; }
set { _entities = value; }
}
private EntityList<Objective> _objectives;
public ObservableCollection<Objective> Objectives
{
get
{
if (_objectives == null)
{
var loadOp = _entities.Load(_entities.GetObjectivesQuery()/*, Callback, true*/);
_objectives = new EntityList<Objective>(_entities.Objectives, loadOp.Entities);
}
return _objectives;
}
}
}
Implement INotifyPropertyChanged. 实现INotifyPropertyChanged。 When the results return, raise NotifyPropertyChanged.
结果返回时,请引发NotifyPropertyChanged。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.