trouble using Table<TEntity>.Attach Method (TEntity,TEntity)

trouble using Table<TEntity>.Attach Method (TEntity,TEntity)

Postby muthu » Thu 14 Oct 2010 11:29

You should be able to use Linq Table.Attach method(s) to update the table with a disconnected object, however I have not been able to figure out a way for this to work without getting a "Cannot add an entity with a key that is already in use" exception.
muthu
 
Posts: 10
Joined: Tue 28 Sep 2010 19:31

Postby AndreyR » Thu 14 Oct 2010 11:56

I recommend you to use the following approach:
1. Try to select the entity by ID from the context.
2. If it is present, use the attach method with this loaded entity as an Original.
3. If there is no such entity, attach the entity without the Original parameter.
AndreyR
Devart Team
 
Posts: 2919
Joined: Mon 07 Jul 2008 13:16


Return to dotConnect for PostgreSQL