在服务器上,我在名为MeasurementService的域服务类上有以下方法
public MeasurementPresentationModel GetSingleMeasurementPM(Guid Id)
{
var m = this.ObjectContext.Measurments.SingleOrDefault(t => t.ID == Id);
return new MeasurementPresentationModel()
{
ID = m.ID,
Objective = m.Objective.Code,
ObjectiveID = m.ObjectiveID,
MeasurementList = m.MeasurmentList.Code,
MeasurementListID = m.MeasurementListID,
Weight = m.Wieght,
HasEvaluation = m.HasEvaluation,
ValidityEndDate = m.ValidityEndDate,
ValidityStartDate = m.ValidityStartDate,
DataType = m.DataType
};
}
在我的ViewModel上,我实现了域服务MeasurementContext _context并尝试编写一个无法正常工作的加载方法:
public MeasurementEditViewModel(MeasurementPresentationModel model):this()
{
_context = new MeasurementContext();
var qry = _context.GetSingleMeasurementPMQuery(model.ID);
var lo = _context.Load(qry);
lo.Completed += (sender, e) =>
{
SelectedMeasurement = lo.Entities;
}
}
我做错了什么以及如何从ViewModels进行服务调用?
答案 0 :(得分:0)
Load方法是一种查询方法,它应该返回IQueryable或IEnumerable。尝试更改服务方法的合同,如:
public IEnumerable<MeasurementPresentationModel> GetSingleMeasurementPM(Guid Id)