因此,我动态地以编程方式为我的SL应用程序中的不同屏幕设置单独的datacontexts。我这样做是因为有些数据需要在一个屏幕上显示,来自不同的数据库表。
我的挑战是这样的:在查询个人信息和近亲信息(不同的表格)之后,我需要将屏幕上的所有更新提交到相应的表格。
我编写了一个通过Ego加载(LINQ)获取数据的自定义查询,但是在设置了屏幕的datacontext之后,如何更新所做的更改?
以下是查询代码
public PersonalInfoModel GetPersonalInfo(string email)
{
var PersonalInfo = (from p in DataContext.OFFLINEAPPLICANTs
where p.EMAIL_ADDRESS == email
select new PersonalInfoModel
{
AppEmail = p.EMAIL_ADDRESS,
FirstName = p.FIRSTNAME,
LastName = p.LASTNAME,
MiddleName = p.MIDDLENAME,
Denomination = p.RELIGIOUSAFF,
DateOfBirth = p.DOB,
AppliedDate = p.CREATEDDATE.Value,
Gender = p.GENDER,
TrnOrSsn = p.SSN_TRN,
Nis = p.NIS,
NationalCountry = p.Country.Country1,
NokEmail = p.NEXT_OF_KINs.Where(q => q.email_address == p.EMAIL_ADDRESS)
.Select(q => q.email).FirstOrDefault(),
NokFax = p.NEXT_OF_KINs.Where(q => q.email_address == p.EMAIL_ADDRESS)
.Select(q => q.fax).FirstOrDefault(),
NokFirstName = p.NEXT_OF_KINs.Where(q => q.email_address == p.EMAIL_ADDRESS)
.Select(q => q.first_name).FirstOrDefault(),
NokLastName = p.NEXT_OF_KINs.Where(q => q.email_address == p.EMAIL_ADDRESS)
.Select(q => q.last_name).FirstOrDefault(),
NokPhone1 = p.NEXT_OF_KINs.Where(q => q.email_address == p.EMAIL_ADDRESS)
.Select(q => q.tel1).FirstOrDefault(),
NokPhone2 = p.NEXT_OF_KINs.Where(q => q.email_address == p.EMAIL_ADDRESS)
.Select(q => q.tel2).FirstOrDefault(),
NokRelationship = p.NEXT_OF_KINs.Where(q => q.email_address == p.EMAIL_ADDRESS)
.Select(q => q.relationship_id).FirstOrDefault(),
}).FirstOrDefault();
return PersonalInfo;
}
在加载数据后,从父SL控件,我将View的datacontext设置为该查询的数据返回。
如何提交更改,或者这样做?
我正在使用RIA Services btw
答案 0 :(得分:0)
我开始认识到不可能这样做。相反,我不得不回忆起容纳相应数据的原始表并相应地更新字段并将更改提交给上下文。