So I dynamically and programatically set separate datacontexts for different screens in my SL app. I did this because there was data that needed to be displayed in one screen, coming from different Database tables.
My challenge is this: After querying personal information and next of kin information (different tables), I need to submit all updates made on the screen to the respective tables.
I wrote a custom query getting the data via Ego loading (LINQ), but How do I sbumit the changes made, after I set the datacontext of the screen already?
Here is the query code
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;
}
and after loading the data, from a parent SL control, I set the View’s datacontext to the data returns from that query.
How do I submit the changes, or go about doing so?
I am using RIA Services btw
Well I came to the realization that it cannot be done that way. I instead, had to recall the original tables housing the respective data and update the fields accordingly and submit the changes to the context.