views:

91

answers:

1

I'm developing a dynamic data app, in which I'm trying perform insert RequestRevision during update of request (logging change of request, somthing like that)

public partial class ProjectDataContext  
    {
        partial void UpdateRequest(Request instance)
        {                
            RequestRevision rv = new RequestRevision(Requests.GetOriginalEntityState(instance));                 
            this.ExecuteDynamicInsert(rv);                
            this.ExecuteDynamicUpdate(instance);
        }
    }

this code error "The operation cannot be performed for the entity because it is not being change tracked."

when I added code for change tracking

public partial class ProjectStatusDataContext  
    {
        partial void UpdateRequest(Request instance)
        {
            bool tracking = ObjectTrackingEnabled;
            ObjectTrackingEnabled = true;
            RequestRevision rv = new RequestRevision(Requests.GetOriginalEntityState(instance));
            //instance.RequestRevisions.Add(rv); --not working 
            this.ExecuteDynamicInsert(rv);
            //this.RequestRevisions.InsertOnSubmit(rv); -- not working
            ObjectTrackingEnabled = tracking;
            this.ExecuteDynamicUpdate(instance);
        }
    }

Now I'm getting error "Data context options cannot be modified after results have been returned from a query."

A: 

I achieve this using sql triggers. Which fire when an update id performed on the request table.

Sharique