This is a migrated thread and some comments may be shown as answers.

Some question in your sample

1 Answer 29 Views
Development (API, general questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jin
Top achievements
Rank 1
Jin asked on 31 Aug 2012, 05:48 AM
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?

1 Answer, 1 is accepted

Sort by
0
Damyan Bogoev
Telerik team
answered on 04 Sep 2012, 04:11 PM
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!
Tags
Development (API, general questions)
Asked by
Jin
Top achievements
Rank 1
Answers by
Damyan Bogoev
Telerik team
Share this question
or