0

I am unable to update the record in SharePoint 2010 using new linq feature. follwoing in my code please review it.

 AbsentTrackingSystemEntitiesDataContext ctx = new AbsentTrackingSystemEntitiesDataContext(spWeb.Url); 
            ctx.ObjectTrackingEnabled = true; 
            HolidaysItem Holidayobj = GetHolidays(HolidayID, ctx); // get the specific record to be update. 
            if (Holidayobj != null) 
            { 
                Holidayobj.Title = "test"; 
                Holidayobj.HolidayDate = DateTime.Today; 
                Holidayobj.Description = "test holiday";    
                ctx.Holidays.Attach(Holidayobj); 
                // or ctx.Holidays.Attach(Holidayobj, true); not working in 2010 
                ctx.SubmitChanges(); 
              } 

1 Answer 1

1

If your GetHolidays method retrieves the item using the context, you shouldn't need to call Attach, simply update changes.

Also, are you sure you have permission to update the list? LINQ to SharePoint is still subject to the item permissions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.