I searched this on the Internet for 4 days and I still don't know why my code is not working ...
I am using an ASP.NET MVC 4 application with a link to a sharepoint listData link for CRUD data.
This 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 works great with one and several search fields. But with multiple selection fields nothing works.
Here is what I am 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 on AttachTo and AddLink because my "DomaineDeCompétences" are not entities! This is not a search field much, and I can not change it. Although, if I try to add these two lines, I have a ResourceNotFoundException because the object does not have an identifier, and this is because it is not an entity! (I already tried: dc.IgnoreResourceNotFoundException = true;)
I have no errors, it just doesn't work ... Can someone help me?
Regards, Flavio
source share