Some question in your sample

2 posts, 0 answers
  1. Jin
    Jin avatar
    80 posts
    Member since:
    Jun 2012

    Posted 31 Aug 2012 Link to this post

    I see your following sample in Document Explore about Building N-Tier Applications:

    using (EntitiesModel dbContext = new EntitiesModel())
    {
    Car attachedCar = dbContext.AttachCopy(carToDelete);
    dbContext.Delete( attachedCar );
    dbContext.SaveChanges();
    }

    using ( EntitiesModel dbContext = new EntitiesModel() )
    {
    dbContext.AttachCopy( carToUpdate );
    dbContext.SaveChanges();
    }

    My question is what's purpose of AttachCopy method? Whether this is the good practice for delete or update operation?
  2. Damyan Bogoev
    Admin
    Damyan Bogoev avatar
    581 posts

    Posted 04 Sep 2012 Link to this post

    Hello Jin,

    The AttachCopy method attaches a copy of an object graph to the context. If a new, deleted or changed instance already exists in the context for an object the operation will fail.

    Additional helpful information regarding the functionality can be found here.

    Hope that helps.

    All the best,
    Damyan Bogoev
    the Telerik team
    Follow @OpenAccessORM Twitter channel to be the first one to get the latest updates on new releases, tips and tricks and sneak peeks at our product labs!
  3. DevCraft banner
Back to Top