tag:blogger.com,1999:blog-4001838553487258943.post5092742680770803805..comments2023-09-03T15:07:19.549+01:00Comments on Radimaging Ltd - Paul Beck's Technical Working Notes for Microsoft Technology: Linq to SharePoint - CRUD operationsUnknownnoreply@blogger.comBlogger5125tag:blogger.com,1999:blog-4001838553487258943.post-88575938225071613372012-06-15T10:00:57.697+01:002012-06-15T10:00:57.697+01:00Hi Kunaal, pls post the code and the error message...Hi Kunaal, pls post the code and the error message stack.Paul Beckhttps://www.blogger.com/profile/12907433036016293795noreply@blogger.comtag:blogger.com,1999:blog-4001838553487258943.post-75175538689486947462012-06-15T04:35:26.456+01:002012-06-15T04:35:26.456+01:00Hi Paul,
I am getting some issues with a similar ...Hi Paul,<br /><br />I am getting some issues with a similar functionality. And get the following error: <br /><br />'All new entities within an object graph must be added/attached before changes are submitted'<br /><br />This is after I'm setting a look up as a part of insertonsubmit, it gives me an error on submitchanges()Kunaalhttps://www.blogger.com/profile/00435141175146614499noreply@blogger.comtag:blogger.com,1999:blog-4001838553487258943.post-68997699040360079912011-03-13T19:09:06.740+00:002011-03-13T19:09:06.740+00:00In summary, find the entity that will be your fore...In summary, find the entity that will be your foreign key using Linq to SharePoint and in your insert operation add the retrieved entity to your insert.Paul Beckhttps://www.blogger.com/profile/12907433036016293795noreply@blogger.comtag:blogger.com,1999:blog-4001838553487258943.post-76844637603156977982011-03-13T19:07:20.403+00:002011-03-13T19:07:20.403+00:00Hi Raymund, applogies for the delayed reply I'...Hi Raymund, applogies for the delayed reply I've been little busy but here is my answer: <br /><br /> DataContext dc = new DataContext();<br /> EntityList CustomerOccupationList = dc.GetList("Customer Occupation");<br /> var coQuery = (from b in CustomerOccupationList .ToList()<br /> where b.Id == 5<br /> select new<br /> {<br /> b<br /> }).Single();<br /><br /><br />DataContext dc = new DataContext();<br />CustomersItem Customer = new CustomersItem();<br />Customer.Title = "Title";<br />Customer.Occupation = coQuery.b;<br />dc.Customers.InsertOnSubmit(Customer);<br />dc.SubmitChanges();Paul Beckhttps://www.blogger.com/profile/12907433036016293795noreply@blogger.comtag:blogger.com,1999:blog-4001838553487258943.post-47506296270151404562011-03-02T21:52:55.040+00:002011-03-02T21:52:55.040+00:00Great article but I have a question on InsertOnSub...Great article but I have a question on InsertOnSubmit.<br /><br />What if you have a Lookup field on Customer List which is for example CustomerOccupation that looks up on CustomerOccupation List how would I do this now?<br /><br />DataContext dc = new DataContext();<br />CustomersItem Customer = new CustomersItem();<br />Customer.Title = "Title";<br />Customer.Occupation = ????????????<br />dc.Customers.InsertOnSubmit(Customer);<br />dc.SubmitChanges(); <br /><br /><br />db.SubmitChanges();<br /><br />as CustomerOccupation will be an CustomerOccupationItem type.Raymund | angsarap.nethttps://www.blogger.com/profile/10835526020984646382noreply@blogger.com