Results 1 to 2 of 2

Thread: Issue with deleting in linq?

  1. #1

    Thread Starter
    PowerPoster i00's Avatar
    Join Date
    Mar 2002
    Location
    1/2 way accross the galaxy.. and then some
    Posts
    2,388

    Issue with deleting in linq?

    If I add an entry to something bound with linq then delete it before having committed anything I get the following error:

    Code:
    System.InvalidOperationException (System.Data.Linq.dll) - Additional information: Cannot remove an entity that has not been attached.
    I searched on the internet and all of the stuff I found said to place an .Attach(DataObject), which made it work! .... kind of ...

    Now adding and then deleting the item right away works, but now when I try to delete an existing Item I get:

    Code:
    System.InvalidOperationException (System.Data.Linq.dll) - Additional information: Cannot attach an entity that already exists.
    Do I need to somehow see if the item was attached and if not call .Attach?

    Any ideas? ...
    Thanks in advance,
    Kris

  2. #2

    Thread Starter
    PowerPoster i00's Avatar
    Join Date
    Mar 2002
    Location
    1/2 way accross the galaxy.. and then some
    Posts
    2,388

    Re: Issue with deleting in linq?

    I just found this post:

    http://stackoverflow.com/questions/6...-a-datacontext

    That checks it ... is this the best method?

    Thanks
    Kris

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width