I've been looking for this on the web for 4 days, and i still have no clue why my code isn't working...
I'm using an ASP.NET MVC 4 application with a service reference to a sharepoint listData in order to CRUD datas.
Here is how i retrieve my DataContext :
var datacontext = new CogniTICDataContext(new Uri("http://my.service.url/_vti_bin/listdata.svc"));
datacontext.IgnoreResourceNotFoundException = true;
datacontext.Credentials = new NetworkCredential("user", "pass", "Domain");
datacontext.MergeOption = MergeOption.OverwriteChanges;
return datacontext;
It's perfectly working with single and multi lookup fields. But with multi choice fields, nothing is working.
Here is what i'm trying :
foreach (string domComp in jsonDomComp.Split(';'))
{
PrestatairesFormationsDomaineDeCompétencesValue domaineDeCompetence =
PrestatairesFormationsDomaineDeCompétencesValue
.CreatePrestatairesFormationsDomaineDeCompétencesValue(domComp);
prestataire.DomaineDeCompétences.Add(domaineDeCompetence);
//dc.AttachTo("DomainesDeCompétence", domaineDeCompetence);
//dc.AddLink(prestataire, "DomComp", domaineDeCompetence);
}
//SaveChanges in batch mode
dc.UpdateObject(prestataire);
dc.SaveChanges(System.Data.Services.Client.SaveChangesOptions.Batch);
I commented the AttachTo and AddLink because my "DomaineDeCompétences" are not entities ! It's not a multi lookup field and i have no power to change that. Though, if I try to add those two lines, I have a ResourceNotFoundException because the entity has no id, and that's because it's not an entity ! (I already tried : dc.IgnoreResourceNotFoundException = true;)
I have no errors, it just doesn't work... Can anyone help me ?
Best regards, Flavio